VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxSDL/Framebuffer.h@ 3576

Last change on this file since 3576 was 3576, checked in by vboxsync, 18 years ago

Main: Beautified method/property names in COM interfaces.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 KB
Line 
1/** @file
2 *
3 * VBox frontends: VBoxSDL (simple frontend based on SDL):
4 * Declaration of VBoxSDLFB (SDL framebuffer) class
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.215389.xyz. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23#ifndef __H_FRAMEBUFFER
24#define __H_FRAMEBUFFER
25
26#include "VBoxSDL.h"
27#include <iprt/thread.h>
28
29#include <iprt/critsect.h>
30
31#ifdef VBOX_SECURELABEL
32#include <SDL_ttf.h>
33/* function pointers */
34extern "C"
35{
36extern DECLSPEC int (SDLCALL *pTTF_Init)(void);
37extern DECLSPEC TTF_Font* (SDLCALL *pTTF_OpenFont)(const char *file, int ptsize);
38extern DECLSPEC SDL_Surface* (SDLCALL *pTTF_RenderUTF8_Solid)(TTF_Font *font, const char *text, SDL_Color fg);
39extern DECLSPEC void (SDLCALL *pTTF_CloseFont)(TTF_Font *font);
40extern DECLSPEC void (SDLCALL *pTTF_Quit)(void);
41}
42#endif /* VBOX_SECURELABEL */
43
44class VBoxSDLFBOverlay;
45
46class VBoxSDLFB :
47 public IFramebuffer
48{
49public:
50 VBoxSDLFB(bool fFullscreen = false, bool fResizable = true, bool fShowSDLConfig = false,
51 uint32_t u32FixedWidth = ~(uint32_t)0, uint32_t u32FixedHeight = ~(uint32_t)0, uint32_t u32FixedBPP = ~(uint32_t)0);
52 virtual ~VBoxSDLFB();
53
54#ifdef __WIN__
55 STDMETHOD_(ULONG, AddRef)()
56 {
57 return ::InterlockedIncrement (&refcnt);
58 }
59 STDMETHOD_(ULONG, Release)()
60 {
61 long cnt = ::InterlockedDecrement (&refcnt);
62 if (cnt == 0)
63 delete this;
64 return cnt;
65 }
66 STDMETHOD(QueryInterface) (REFIID riid , void **ppObj)
67 {
68 if (riid == IID_IUnknown)
69 {
70 *ppObj = this;
71 AddRef();
72 return S_OK;
73 }
74 if (riid == IID_IFramebuffer)
75 {
76 *ppObj = this;
77 AddRef();
78 return S_OK;
79 }
80 *ppObj = NULL;
81 return E_NOINTERFACE;
82 }
83#endif
84
85 NS_DECL_ISUPPORTS
86
87 STDMETHOD(COMGETTER(Width))(ULONG *width);
88 STDMETHOD(COMGETTER(Height))(ULONG *height);
89 STDMETHOD(Lock)();
90 STDMETHOD(Unlock)();
91 STDMETHOD(COMGETTER(Address))(BYTE **address);
92 STDMETHOD(COMGETTER(ColorDepth))(ULONG *colorDepth);
93 STDMETHOD(COMGETTER(LineSize))(ULONG *lineSize);
94 STDMETHOD(COMGETTER(PixelFormat)) (FramebufferPixelFormat_T *pixelFormat);
95 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *heightReduction);
96 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay);
97 STDMETHOD(COMGETTER(RenderMode)) (FramebufferRenderMode_T *renderMode);
98 STDMETHOD(COMSETTER(RenderMode)) (FramebufferRenderMode_T renderMode);
99
100 STDMETHOD(NotifyUpdate)(ULONG x, ULONG y,
101 ULONG w, ULONG h, BOOL *finished);
102 STDMETHOD(RequestResize)(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, BYTE *vram,
103 ULONG lineSize, ULONG w, ULONG h, BOOL *finished);
104 STDMETHOD(OperationSupported)(FramebufferAccelerationOperation_T operation, BOOL *supported);
105 STDMETHOD(VideoModeSupported)(ULONG width, ULONG height, ULONG bpp, BOOL *supported);
106 STDMETHOD(SolidFill)(ULONG x, ULONG y, ULONG width, ULONG height,
107 ULONG color, BOOL *handled);
108 STDMETHOD(CopyScreenBits)(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
109 ULONG width, ULONG height, BOOL *handled);
110
111 STDMETHOD(GetVisibleRegion)(BYTE *aRectangles, ULONG aCount, ULONG *aCountCopied);
112 STDMETHOD(SetVisibleRegion)(BYTE *aRectangles, ULONG aCount);
113
114 // internal public methods
115 bool initialized() { return mfInitialized; }
116 void resizeGuest();
117 void resizeSDL();
118 void update(int x, int y, int w, int h, bool fGuestRelative);
119 void repaint();
120 bool getFullscreen();
121 void setFullscreen(bool fFullscreen);
122 int getXOffset();
123 int getYOffset();
124 uint32_t getGuestXRes() { return mGuestXRes; }
125 uint32_t getGuestYRes() { return mGuestYRes; }
126#ifdef VBOX_SECURELABEL
127 int initSecureLabel(uint32_t height, char *font, uint32_t pointsize);
128 void setSecureLabelText(const char *text);
129 void setSecureLabelColor(uint32_t colorFG, uint32_t colorBG);
130 void paintSecureLabel(int x, int y, int w, int h, bool fForce);
131#endif
132 void uninit();
133
134private:
135 /** the sdl thread */
136 RTNATIVETHREAD mSdlNativeThread;
137 /** current SDL framebuffer pointer (also includes screen width/height) */
138 SDL_Surface *mScreen;
139 /** false if constructor failed */
140 bool mfInitialized;
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 ULONG mGuestXRes;
147 /** current guest screen height in pixels */
148 ULONG mGuestYRes;
149 /** fixed SDL screen width (~0 = not set) */
150 uint32_t mFixedSDLWidth;
151 /** fixed SDL screen height (~0 = not set) */
152 uint32_t mFixedSDLHeight;
153 /** fixed SDL bits per pixel (~0 = not set) */
154 uint32_t mFixedSDLBPP;
155 /** default BPP */
156 uint32_t mDefaultSDLBPP;
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 /** framebuffer update semaphore */
166 RTCRITSECT mUpdateLock;
167 /** flag whether the SDL window should be resizable */
168 bool mfResizable;
169 /** flag whether we print out SDL information */
170 bool mfShowSDLConfig;
171#ifdef VBOX_SECURELABEL
172 /** current secure label text */
173 Utf8Str mSecureLabelText;
174 /** current secure label foreground color (RGB) */
175 uint32_t mSecureLabelColorFG;
176 /** current secure label background color (RGB) */
177 uint32_t mSecureLabelColorBG;
178 /** secure label font handle */
179 TTF_Font *mLabelFont;
180 /** secure label height in pixels */
181 uint32_t mLabelHeight;
182#endif
183#ifdef __WIN__
184 long refcnt;
185#endif
186 SDL_Surface *mSurfVRAM;
187
188 BYTE *mPtrVRAM;
189 ULONG mLineSize;
190 FramebufferPixelFormat_T mPixelFormat;
191
192 /* Framebuffer render mode */
193 FramebufferRenderMode_T mRenderMode;
194
195 /** the application Icon */
196 SDL_Surface *mWMIcon;
197};
198
199class VBoxSDLFBOverlay :
200 public IFramebufferOverlay
201{
202public:
203 VBoxSDLFBOverlay(ULONG x, ULONG y, ULONG width, ULONG height, BOOL visible,
204 VBoxSDLFB *aParent);
205 virtual ~VBoxSDLFBOverlay();
206
207#ifdef __WIN__
208 STDMETHOD_(ULONG, AddRef)()
209 {
210 return ::InterlockedIncrement (&refcnt);
211 }
212 STDMETHOD_(ULONG, Release)()
213 {
214 long cnt = ::InterlockedDecrement (&refcnt);
215 if (cnt == 0)
216 delete this;
217 return cnt;
218 }
219 STDMETHOD(QueryInterface) (REFIID riid , void **ppObj)
220 {
221 if (riid == IID_IUnknown)
222 {
223 *ppObj = this;
224 AddRef();
225 return S_OK;
226 }
227 if (riid == IID_IFramebuffer)
228 {
229 *ppObj = this;
230 AddRef();
231 return S_OK;
232 }
233 *ppObj = NULL;
234 return E_NOINTERFACE;
235 }
236#endif
237
238 NS_DECL_ISUPPORTS
239
240 STDMETHOD(COMGETTER(X))(ULONG *x);
241 STDMETHOD(COMGETTER(Y))(ULONG *y);
242 STDMETHOD(COMGETTER(Width))(ULONG *width);
243 STDMETHOD(COMGETTER(Height))(ULONG *height);
244 STDMETHOD(COMGETTER(Visible))(BOOL *visible);
245 STDMETHOD(COMSETTER(Visible))(BOOL visible);
246 STDMETHOD(COMGETTER(Alpha))(ULONG *alpha);
247 STDMETHOD(COMSETTER(Alpha))(ULONG alpha);
248 STDMETHOD(COMGETTER(Address))(ULONG *address);
249 STDMETHOD(COMGETTER(LineSize))(ULONG *lineSize);
250
251 /* These are not used, or return standard values. */
252 STDMETHOD(COMGETTER(ColorDepth))(ULONG *colorDepth);
253 STDMETHOD(COMGETTER(PixelFormat)) (FramebufferPixelFormat_T *pixelFormat);
254 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *heightReduction);
255 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay);
256
257 STDMETHOD(Lock)();
258 STDMETHOD(Unlock)();
259 STDMETHOD(Move)(ULONG x, ULONG y);
260 STDMETHOD(NotifyUpdate)(ULONG x, ULONG y,
261 ULONG w, ULONG h, BOOL *finished);
262 STDMETHOD(RequestResize)(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, ULONG vram,
263 ULONG lineSize, ULONG w, ULONG h, BOOL *finished);
264 STDMETHOD(OperationSupported)(FramebufferAccelerationOperation_T operation,
265 BOOL *supported);
266 STDMETHOD(VideoModeSupported)(ULONG width, ULONG height, ULONG bpp, BOOL *supported);
267 STDMETHOD(SolidFill)(ULONG x, ULONG y, ULONG width, ULONG height,
268 ULONG color, BOOL *handled);
269 STDMETHOD(CopyScreenBits)(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
270 ULONG width, ULONG height, BOOL *handled);
271
272 // internal public methods
273 HRESULT init();
274
275private:
276 /** Overlay X offset */
277 ULONG mOverlayX;
278 /** Overlay Y offset */
279 ULONG mOverlayY;
280 /** Overlay width */
281 ULONG mOverlayWidth;
282 /** Overlay height */
283 ULONG mOverlayHeight;
284 /** Whether the overlay is currently active */
285 BOOL mOverlayVisible;
286 /** The parent IFramebuffer */
287 VBoxSDLFB *mParent;
288 /** SDL surface containing the actual framebuffer bits */
289 SDL_Surface *mOverlayBits;
290 /** Additional SDL surface used for combining the framebuffer and the overlay */
291 SDL_Surface *mBlendedBits;
292#ifdef __WIN__
293 long refcnt;
294#endif
295};
296
297#endif // __H_FRAMEBUFFER
Note: See TracBrowser for help on using the repository browser.

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