VirtualBox

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

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.4 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 InnoTek Systemberatung GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. 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 int ulFixedWidth = ~0, int ulFixedHeight = ~0, int ulFixedBPP = ~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))(ULONG *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
98 STDMETHOD(NotifyUpdate)(ULONG x, ULONG y,
99 ULONG w, ULONG h, BOOL *finished);
100 STDMETHOD(RequestResize)(FramebufferPixelFormat_T pixelFormat, ULONG vram, ULONG lineSize, ULONG w, ULONG h,
101 BOOL *finished);
102 STDMETHOD(OperationSupported)(FramebufferAccelerationOperation_T operation, BOOL *supported);
103 STDMETHOD(VideoModeSupported)(ULONG width, ULONG height, ULONG bpp, BOOL *supported);
104 STDMETHOD(SolidFill)(ULONG x, ULONG y, ULONG width, ULONG height,
105 ULONG color, BOOL *handled);
106 STDMETHOD(CopyScreenBits)(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
107 ULONG width, ULONG height, BOOL *handled);
108
109 // internal public methods
110 bool initialized() { return mfInitialized; }
111 void resizeGuest();
112 void resizeSDL();
113 void update(int x, int y, int w, int h, bool fGuestRelative);
114 void repaint();
115 bool getFullscreen();
116 void setFullscreen(bool fFullscreen);
117 int getXOffset();
118 int getYOffset();
119 uint32_t getGuestXRes() { return mGuestXRes; }
120 uint32_t getGuestYRes() { return mGuestYRes; }
121#ifdef VBOX_SECURELABEL
122 int initSecureLabel(uint32_t height, char *font, uint32_t pointsize);
123 void setSecureLabelText(const char *text);
124 void setSecureLabelColor(uint32_t colorFG, uint32_t colorBG);
125 void paintSecureLabel(int x, int y, int w, int h, bool fForce);
126#endif
127 void uninit();
128
129private:
130 /** the sdl thread */
131 RTNATIVETHREAD mSdlNativeThread;
132 /** current SDL framebuffer pointer (also includes screen width/height) */
133 SDL_Surface *mScreen;
134 /** false if constructor failed */
135 bool mfInitialized;
136 /** maximum possible screen width in pixels (~0 = no restriction) */
137 uint32_t mMaxScreenWidth;
138 /** maximum possible screen height in pixels (~0 = no restriction) */
139 uint32_t mMaxScreenHeight;
140 /** current guest screen width in pixels */
141 ULONG mGuestXRes;
142 /** current guest screen height in pixels */
143 ULONG mGuestYRes;
144 /** fixed SDL screen width (~0 = not set) */
145 uint32_t mFixedSDLWidth;
146 /** fixed SDL screen height (~0 = not set) */
147 uint32_t mFixedSDLHeight;
148 /** fixed SDL bits per pixel (~0 = not set) */
149 uint32_t mFixedSDLBPP;
150 /** Y offset in pixels, i.e. guest-nondrawable area at the top */
151 uint32_t mTopOffset;
152 /** X offset for guest screen centering */
153 uint32_t mCenterXOffset;
154 /** Y offset for guest screen centering */
155 uint32_t mCenterYOffset;
156 /** flag whether we're in fullscreen mode */
157 bool mfFullscreen;
158 /** framebuffer update semaphore */
159 RTCRITSECT mUpdateLock;
160 /** flag whether the SDL window should be resizable */
161 bool mfResizable;
162 /** flag whether we print out SDL information */
163 bool mfShowSDLConfig;
164#ifdef VBOX_SECURELABEL
165 /** current secure label text */
166 Utf8Str mSecureLabelText;
167 /** current secure label foreground color (RGB) */
168 uint32_t mSecureLabelColorFG;
169 /** current secure label background color (RGB) */
170 uint32_t mSecureLabelColorBG;
171 /** secure label font handle */
172 TTF_Font *mLabelFont;
173 /** secure label height in pixels */
174 uint32_t mLabelHeight;
175#endif
176#ifdef __WIN__
177 long refcnt;
178#endif
179 SDL_Surface *mSurfVRAM;
180
181 void *mPtrVRAM;
182 ULONG mLineSize;
183 FramebufferPixelFormat_T mPixelFormat;
184
185 /** the application Icon */
186 SDL_Surface *mWMIcon;
187
188};
189
190class VBoxSDLFBOverlay :
191 public IFramebufferOverlay
192{
193public:
194 VBoxSDLFBOverlay(ULONG x, ULONG y, ULONG width, ULONG height, BOOL visible,
195 VBoxSDLFB *aParent);
196 virtual ~VBoxSDLFBOverlay();
197
198#ifdef __WIN__
199 STDMETHOD_(ULONG, AddRef)()
200 {
201 return ::InterlockedIncrement (&refcnt);
202 }
203 STDMETHOD_(ULONG, Release)()
204 {
205 long cnt = ::InterlockedDecrement (&refcnt);
206 if (cnt == 0)
207 delete this;
208 return cnt;
209 }
210 STDMETHOD(QueryInterface) (REFIID riid , void **ppObj)
211 {
212 if (riid == IID_IUnknown)
213 {
214 *ppObj = this;
215 AddRef();
216 return S_OK;
217 }
218 if (riid == IID_IFramebuffer)
219 {
220 *ppObj = this;
221 AddRef();
222 return S_OK;
223 }
224 *ppObj = NULL;
225 return E_NOINTERFACE;
226 }
227#endif
228
229 NS_DECL_ISUPPORTS
230
231 STDMETHOD(COMGETTER(X))(ULONG *x);
232 STDMETHOD(COMGETTER(Y))(ULONG *y);
233 STDMETHOD(COMGETTER(Width))(ULONG *width);
234 STDMETHOD(COMGETTER(Height))(ULONG *height);
235 STDMETHOD(COMGETTER(Visible))(BOOL *visible);
236 STDMETHOD(COMSETTER(Visible))(BOOL visible);
237 STDMETHOD(COMGETTER(Alpha))(ULONG *alpha);
238 STDMETHOD(COMSETTER(Alpha))(ULONG alpha);
239 STDMETHOD(COMGETTER(Address))(ULONG *address);
240 STDMETHOD(COMGETTER(LineSize))(ULONG *lineSize);
241
242 /* These are not used, or return standard values. */
243 STDMETHOD(COMGETTER(ColorDepth))(ULONG *colorDepth);
244 STDMETHOD(COMGETTER(PixelFormat)) (FramebufferPixelFormat_T *pixelFormat);
245 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *heightReduction);
246 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay);
247
248 STDMETHOD(Lock)();
249 STDMETHOD(Unlock)();
250 STDMETHOD(Move)(ULONG x, ULONG y);
251 STDMETHOD(NotifyUpdate)(ULONG x, ULONG y,
252 ULONG w, ULONG h, BOOL *finished);
253 STDMETHOD(RequestResize)(FramebufferPixelFormat_T pixelFormat, ULONG vram,
254 ULONG lineSize, ULONG w, ULONG h, BOOL *finished);
255 STDMETHOD(OperationSupported)(FramebufferAccelerationOperation_T operation,
256 BOOL *supported);
257 STDMETHOD(VideoModeSupported)(ULONG width, ULONG height, ULONG bpp, BOOL *supported);
258 STDMETHOD(SolidFill)(ULONG x, ULONG y, ULONG width, ULONG height,
259 ULONG color, BOOL *handled);
260 STDMETHOD(CopyScreenBits)(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
261 ULONG width, ULONG height, BOOL *handled);
262
263 // internal public methods
264 HRESULT init();
265
266private:
267 /** Overlay X offset */
268 ULONG mOverlayX;
269 /** Overlay Y offset */
270 ULONG mOverlayY;
271 /** Overlay width */
272 ULONG mOverlayWidth;
273 /** Overlay height */
274 ULONG mOverlayHeight;
275 /** Whether the overlay is currently active */
276 BOOL mOverlayVisible;
277 /** The parent IFramebuffer */
278 VBoxSDLFB *mParent;
279 /** SDL surface containing the actual framebuffer bits */
280 SDL_Surface *mOverlayBits;
281 /** Additional SDL surface used for combining the framebuffer and the overlay */
282 SDL_Surface *mBlendedBits;
283#ifdef __WIN__
284 long refcnt;
285#endif
286};
287
288#endif // __H_FRAMEBUFFER
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