VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBFE/Framebuffer.h@ 99548

Last change on this file since 99548 was 99548, checked in by vboxsync, 22 months ago

FE/VBoxBFE: Some very simple SDL based display output and add more devices, bugref:10397 [scm fixes]

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
1/** @file
2 *
3 * VBox frontends: Basic Frontend (BFE):
4 * Declaration of Framebuffer class
5 */
6
7/*
8 * Copyright (C) 2023 Oracle and/or its affiliates.
9 *
10 * This file is part of VirtualBox base platform packages, as
11 * available from https://www.virtualbox.org.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation, in version 3 of the
16 * License.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see <https://www.gnu.org/licenses>.
25 *
26 * SPDX-License-Identifier: GPL-3.0-only
27 */
28
29#ifndef VBOX_INCLUDED_SRC_VBoxBFE_Framebuffer_h
30#define VBOX_INCLUDED_SRC_VBoxBFE_Framebuffer_h
31
32#include <VBox/types.h>
33#include <iprt/critsect.h>
34
35#include <SDL.h>
36
37/** custom SDL event for display update handling */
38#define SDL_USER_EVENT_UPDATERECT (SDL_USEREVENT + 4)
39/** custom SDL event for changing the guest resolution */
40#define SDL_USER_EVENT_NOTIFYCHANGE (SDL_USEREVENT + 5)
41/** custom SDL for XPCOM event queue processing */
42#define SDL_USER_EVENT_XPCOM_EVENTQUEUE (SDL_USEREVENT + 6)
43/** custom SDL event for updating the titlebar */
44#define SDL_USER_EVENT_UPDATE_TITLEBAR (SDL_USEREVENT + 7)
45/** custom SDL user event for terminating the session */
46#define SDL_USER_EVENT_TERMINATE (SDL_USEREVENT + 8)
47/** custom SDL user event for pointer shape change request */
48#define SDL_USER_EVENT_POINTER_CHANGE (SDL_USEREVENT + 9)
49/** custom SDL user event for a regular timer */
50#define SDL_USER_EVENT_TIMER (SDL_USEREVENT + 10)
51/** custom SDL user event for resetting mouse cursor */
52#define SDL_USER_EVENT_GUEST_CAP_CHANGED (SDL_USEREVENT + 11)
53/** custom SDL user event for window resize done */
54#define SDL_USER_EVENT_WINDOW_RESIZE_DONE (SDL_USEREVENT + 12)
55
56
57/** The user.code field of the SDL_USER_EVENT_TERMINATE event.
58 * @{
59 */
60/** Normal termination. */
61#define VBOXSDL_TERM_NORMAL 0
62/** Abnormal termination. */
63#define VBOXSDL_TERM_ABEND 1
64/** @} */
65
66#if defined(VBOXSDL_WITH_X11) || defined(RT_OS_DARWIN)
67void PushNotifyUpdateEvent(SDL_Event *event);
68#endif
69int PushSDLEventForSure(SDL_Event *event);
70
71class Display;
72
73class Framebuffer
74{
75public:
76 Framebuffer(Display *pDisplay, uint32_t uScreenId,
77 bool fFullscreen, bool fResizable, bool fShowSDLConfig,
78 bool fKeepHostRes, uint32_t u32FixedWidth,
79 uint32_t u32FixedHeight, uint32_t u32FixedBPP,
80 bool fUpdateImage);
81 Framebuffer(bool fShowSDLConfig);
82 virtual ~Framebuffer();
83
84 static bool init(bool fShowSDLConfig);
85 static void uninit();
86
87 uint32_t getWidth();
88 uint32_t getHeight();
89 uint32_t getBitsPerPixel();
90 uint32_t getBytesPerLine();
91 uint8_t *getPixelData();
92
93 int notifyUpdate(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
94 int notifyChange(uint32_t idScreen, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
95
96 int NotifyUpdateImage(uint32_t aX,
97 uint32_t aY,
98 uint32_t aWidth,
99 uint32_t aHeight,
100 void *pvImage);
101
102 // internal public methods
103 bool initialized() { return mfInitialized; }
104 void notifyChange(uint32_t aScreenId);
105 void resizeGuest();
106 void resizeSDL();
107 void update(int x, int y, int w, int h, bool fGuestRelative);
108 void repaint();
109 void setFullscreen(bool fFullscreen);
110 void getFullscreenGeometry(uint32_t *width, uint32_t *height);
111 uint32_t getScreenId() { return mScreenId; }
112 uint32_t getGuestXRes() { return mGuestXRes; }
113 uint32_t getGuestYRes() { return mGuestYRes; }
114 int32_t getOriginX() { return mOriginX; }
115 int32_t getOriginY() { return mOriginY; }
116 int32_t getXOffset() { return mCenterXOffset; }
117 int32_t getYOffset() { return mCenterYOffset; }
118 SDL_Window *getWindow() { return mpWindow; }
119 bool hasWindow(uint32_t id) { return SDL_GetWindowID(mpWindow) == id; }
120 int setWindowTitle(const char *pcszTitle);
121 void setWinId(int64_t winId) { mWinId = winId; }
122 void setOrigin(int32_t axOrigin, int32_t ayOrigin) { mOriginX = axOrigin; mOriginY = ayOrigin; }
123 bool getFullscreen() { return mfFullscreen; }
124
125private:
126
127 /** the SDL window */
128 SDL_Window *mpWindow;
129 /** the texture */
130 SDL_Texture *mpTexture;
131 /** renderer */
132 SDL_Renderer *mpRenderer;
133 /** render info */
134 SDL_RendererInfo mRenderInfo;
135 /** false if constructor failed */
136 bool mfInitialized;
137 /** the screen number of this framebuffer */
138 uint32_t mScreenId;
139 /** use NotifyUpdateImage */
140 bool mfUpdateImage;
141 /** maximum possible screen width in pixels (~0 = no restriction) */
142 uint32_t mMaxScreenWidth;
143 /** maximum possible screen height in pixels (~0 = no restriction) */
144 uint32_t mMaxScreenHeight;
145 /** current guest screen width in pixels */
146 uint32_t mGuestXRes;
147 /** current guest screen height in pixels */
148 uint32_t mGuestYRes;
149 int32_t mOriginX;
150 int32_t mOriginY;
151 /** fixed SDL screen width (~0 = not set) */
152 uint32_t mFixedSDLWidth;
153 /** fixed SDL screen height (~0 = not set) */
154 uint32_t mFixedSDLHeight;
155 /** fixed SDL bits per pixel (~0 = not set) */
156 uint32_t mFixedSDLBPP;
157 /** Y offset in pixels, i.e. guest-nondrawable area at the top */
158 uint32_t mTopOffset;
159 /** X offset for guest screen centering */
160 uint32_t mCenterXOffset;
161 /** Y offset for guest screen centering */
162 uint32_t mCenterYOffset;
163 /** flag whether we're in fullscreen mode */
164 bool mfFullscreen;
165 /** flag whether we keep the host screen resolution when switching to
166 * fullscreen or not */
167 bool mfKeepHostRes;
168 /** framebuffer update semaphore */
169 RTCRITSECT mUpdateLock;
170 /** flag whether the SDL window should be resizable */
171 bool mfResizable;
172 /** flag whether we print out SDL information */
173 bool mfShowSDLConfig;
174 /** handle to window where framebuffer context is being drawn*/
175 int64_t mWinId;
176 SDL_Surface *mSurfVRAM;
177 bool mfUpdates;
178
179 uint8_t *mPtrVRAM;
180 uint32_t mBitsPerPixel;
181 uint32_t mBytesPerLine;
182 bool mfSameSizeRequested;
183 Display *m_pDisplay;
184};
185
186#endif /* !VBOX_INCLUDED_SRC_VBoxBFE_Framebuffer_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette