1 | /** @file
|
---|
2 | *
|
---|
3 | * VBox frontends: VBoxSDL (simple frontend based on SDL):
|
---|
4 | * Implementation 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.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 | #include <VBox/com/com.h>
|
---|
24 | #include <VBox/com/string.h>
|
---|
25 | #include <VBox/com/Guid.h>
|
---|
26 | #include <VBox/com/ErrorInfo.h>
|
---|
27 | #include <VBox/com/EventQueue.h>
|
---|
28 | #include <VBox/com/VirtualBox.h>
|
---|
29 |
|
---|
30 | #include <iprt/stream.h>
|
---|
31 |
|
---|
32 | #ifdef __OS2__
|
---|
33 | # undef RT_MAX
|
---|
34 | // from <iprt/cdefs.h>
|
---|
35 | # define RT_MAX(Value1, Value2) ((Value1) >= (Value2) ? (Value1) : (Value2))
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | using namespace com;
|
---|
39 |
|
---|
40 | #define LOG_GROUP LOG_GROUP_GUI
|
---|
41 | #include <VBox/err.h>
|
---|
42 | #include <VBox/log.h>
|
---|
43 | #include <stdlib.h>
|
---|
44 | #include <signal.h>
|
---|
45 |
|
---|
46 | #include "VBoxSDL.h"
|
---|
47 | #include "Framebuffer.h"
|
---|
48 | #include "Ico64x01.h"
|
---|
49 |
|
---|
50 | #if defined(VBOX_WITH_XPCOM)
|
---|
51 | NS_IMPL_ISUPPORTS1_CI(VBoxSDLFB, IFramebuffer)
|
---|
52 | NS_DECL_CLASSINFO(VBoxSDLFB)
|
---|
53 | NS_IMPL_ISUPPORTS1_CI(VBoxSDLFBOverlay, IFramebufferOverlay)
|
---|
54 | NS_DECL_CLASSINFO(VBoxSDLFBOverlay)
|
---|
55 | #endif
|
---|
56 |
|
---|
57 | #ifdef VBOX_SECURELABEL
|
---|
58 | /* function pointers */
|
---|
59 | extern "C"
|
---|
60 | {
|
---|
61 | DECLSPEC int (SDLCALL *pTTF_Init)(void);
|
---|
62 | DECLSPEC TTF_Font* (SDLCALL *pTTF_OpenFont)(const char *file, int ptsize);
|
---|
63 | DECLSPEC SDL_Surface* (SDLCALL *pTTF_RenderUTF8_Solid)(TTF_Font *font, const char *text, SDL_Color fg);
|
---|
64 | DECLSPEC void (SDLCALL *pTTF_CloseFont)(TTF_Font *font);
|
---|
65 | DECLSPEC void (SDLCALL *pTTF_Quit)(void);
|
---|
66 | }
|
---|
67 | #endif /* VBOX_SECURELABEL */
|
---|
68 |
|
---|
69 | //
|
---|
70 | // Constructor / destructor
|
---|
71 | //
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * SDL framebuffer constructor. It is called from the main
|
---|
75 | * (i.e. SDL) thread. Therefore it is safe to use SDL calls
|
---|
76 | * here.
|
---|
77 | * @param fFullscreen flag whether we start in fullscreen mode
|
---|
78 | * @param fResizable flag whether the SDL window should be resizable
|
---|
79 | * @param fShowSDLConfig flag whether we print out SDL settings
|
---|
80 | * @param iFixedWidth fixed SDL width (-1 means not set)
|
---|
81 | * @param iFixedHeight fixed SDL height (-1 means not set)
|
---|
82 | */
|
---|
83 | VBoxSDLFB::VBoxSDLFB(bool fFullscreen, bool fResizable, bool fShowSDLConfig,
|
---|
84 | uint32_t u32FixedWidth, uint32_t u32FixedHeight, uint32_t u32FixedBPP)
|
---|
85 | {
|
---|
86 | int rc;
|
---|
87 | LogFlow(("VBoxSDLFB::VBoxSDLFB\n"));
|
---|
88 |
|
---|
89 | #if defined (__WIN__)
|
---|
90 | refcnt = 0;
|
---|
91 | #endif
|
---|
92 |
|
---|
93 | mScreen = NULL;
|
---|
94 | mSurfVRAM = NULL;
|
---|
95 | mfInitialized = false;
|
---|
96 | mfFullscreen = fFullscreen;
|
---|
97 | mTopOffset = 0;
|
---|
98 | mfResizable = fResizable;
|
---|
99 | mfShowSDLConfig = fShowSDLConfig;
|
---|
100 | mFixedSDLWidth = u32FixedWidth;
|
---|
101 | mFixedSDLHeight = u32FixedHeight;
|
---|
102 | mFixedSDLBPP = u32FixedBPP;
|
---|
103 | mDefaultSDLBPP = 32;
|
---|
104 | mCenterXOffset = 0;
|
---|
105 | mCenterYOffset = 0;
|
---|
106 | /* Start with standard screen dimensions. */
|
---|
107 | mGuestXRes = 640;
|
---|
108 | mGuestYRes = 480;
|
---|
109 | mPixelFormat = FramebufferPixelFormat_PixelFormatDefault;
|
---|
110 | mPtrVRAM = NULL;
|
---|
111 | mLineSize = 0;
|
---|
112 | #ifdef VBOX_SECURELABEL
|
---|
113 | mLabelFont = NULL;
|
---|
114 | mLabelHeight = 0;
|
---|
115 | #endif
|
---|
116 | mWMIcon = NULL;
|
---|
117 |
|
---|
118 | /* memorize the thread that inited us, that's the SDL thread */
|
---|
119 | mSdlNativeThread = RTThreadNativeSelf();
|
---|
120 |
|
---|
121 | rc = RTCritSectInit(&mUpdateLock);
|
---|
122 | AssertMsg(rc == VINF_SUCCESS, ("Error from RTCritSectInit!\n"));
|
---|
123 |
|
---|
124 | #ifdef __WIN__
|
---|
125 | /* default to DirectX if nothing else set */
|
---|
126 | if (!getenv("SDL_VIDEODRIVER"))
|
---|
127 | {
|
---|
128 | _putenv("SDL_VIDEODRIVER=directx");
|
---|
129 | // _putenv("SDL_VIDEODRIVER=windib");
|
---|
130 | }
|
---|
131 | #endif
|
---|
132 | #ifdef __LINUX__
|
---|
133 | /* On some X servers the mouse is stuck inside the bottom right corner.
|
---|
134 | * See http://wiki.clug.org.za/wiki/QEMU_mouse_not_working */
|
---|
135 | setenv("SDL_VIDEO_X11_DGAMOUSE", "0", 1);
|
---|
136 | #endif
|
---|
137 | rc = SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE);
|
---|
138 | if (rc != 0)
|
---|
139 | {
|
---|
140 | RTPrintf("SDL Error: '%s'\n", SDL_GetError());
|
---|
141 | return;
|
---|
142 | }
|
---|
143 |
|
---|
144 | #ifdef __LINUX__
|
---|
145 | /* NOTE: we still want Ctrl-C to work, so we undo the SDL redirections */
|
---|
146 | signal(SIGINT, SIG_DFL);
|
---|
147 | signal(SIGQUIT, SIG_DFL);
|
---|
148 | #endif
|
---|
149 |
|
---|
150 | const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
|
---|
151 | Assert(videoInfo);
|
---|
152 | if (videoInfo)
|
---|
153 | {
|
---|
154 | switch (videoInfo->vfmt->BitsPerPixel)
|
---|
155 | {
|
---|
156 | case 16: mDefaultSDLBPP = 16; break;
|
---|
157 | case 24: mDefaultSDLBPP = 24; break;
|
---|
158 | default:
|
---|
159 | case 32: mDefaultSDLBPP = 32; break;
|
---|
160 | }
|
---|
161 |
|
---|
162 | /* output what SDL is capable of */
|
---|
163 | if (mfShowSDLConfig)
|
---|
164 | RTPrintf("SDL capabilities:\n"
|
---|
165 | " Hardware surface support: %s\n"
|
---|
166 | " Window manager available: %s\n"
|
---|
167 | " Screen to screen blits accelerated: %s\n"
|
---|
168 | " Screen to screen colorkey blits accelerated: %s\n"
|
---|
169 | " Screen to screen alpha blits accelerated: %s\n"
|
---|
170 | " Memory to screen blits accelerated: %s\n"
|
---|
171 | " Memory to screen colorkey blits accelerated: %s\n"
|
---|
172 | " Memory to screen alpha blits accelerated: %s\n"
|
---|
173 | " Color fills accelerated: %s\n"
|
---|
174 | " Video memory in kilobytes: %d\n"
|
---|
175 | " Optimal bpp mode: %d\n"
|
---|
176 | "SDL video driver: %s\n",
|
---|
177 | videoInfo->hw_available ? "yes" : "no",
|
---|
178 | videoInfo->wm_available ? "yes" : "no",
|
---|
179 | videoInfo->blit_hw ? "yes" : "no",
|
---|
180 | videoInfo->blit_hw_CC ? "yes" : "no",
|
---|
181 | videoInfo->blit_hw_A ? "yes" : "no",
|
---|
182 | videoInfo->blit_sw ? "yes" : "no",
|
---|
183 | videoInfo->blit_sw_CC ? "yes" : "no",
|
---|
184 | videoInfo->blit_sw_A ? "yes" : "no",
|
---|
185 | videoInfo->blit_fill ? "yes" : "no",
|
---|
186 | videoInfo->video_mem,
|
---|
187 | videoInfo->vfmt->BitsPerPixel,
|
---|
188 | getenv("SDL_VIDEODRIVER"));
|
---|
189 | }
|
---|
190 |
|
---|
191 | if (12320 == g_cbIco64x01)
|
---|
192 | {
|
---|
193 | mWMIcon = SDL_AllocSurface(SDL_SWSURFACE, 64, 64, 24, 0xff, 0xff00, 0xff0000, 0);
|
---|
194 | /** @todo make it as simple as possible. No PNM interpreter here... */
|
---|
195 | if (mWMIcon)
|
---|
196 | {
|
---|
197 | memcpy(mWMIcon->pixels, g_abIco64x01+32, g_cbIco64x01-32);
|
---|
198 | SDL_WM_SetIcon(mWMIcon, NULL);
|
---|
199 | }
|
---|
200 | }
|
---|
201 |
|
---|
202 | resizeGuest();
|
---|
203 | Assert(mScreen);
|
---|
204 | mfInitialized = true;
|
---|
205 | }
|
---|
206 |
|
---|
207 | VBoxSDLFB::~VBoxSDLFB()
|
---|
208 | {
|
---|
209 | LogFlow(("VBoxSDLFB::~VBoxSDLFB\n"));
|
---|
210 | RTCritSectDelete(&mUpdateLock);
|
---|
211 | }
|
---|
212 |
|
---|
213 |
|
---|
214 | /**
|
---|
215 | * Returns the current framebuffer width in pixels.
|
---|
216 | *
|
---|
217 | * @returns COM status code
|
---|
218 | * @param width Address of result buffer.
|
---|
219 | */
|
---|
220 | STDMETHODIMP VBoxSDLFB::COMGETTER(Width)(ULONG *width)
|
---|
221 | {
|
---|
222 | LogFlow(("VBoxSDLFB::GetWidth\n"));
|
---|
223 | if (!width)
|
---|
224 | return E_INVALIDARG;
|
---|
225 | *width = mGuestXRes;
|
---|
226 | return S_OK;
|
---|
227 | }
|
---|
228 |
|
---|
229 | /**
|
---|
230 | * Returns the current framebuffer height in pixels.
|
---|
231 | *
|
---|
232 | * @returns COM status code
|
---|
233 | * @param height Address of result buffer.
|
---|
234 | */
|
---|
235 | STDMETHODIMP VBoxSDLFB::COMGETTER(Height)(ULONG *height)
|
---|
236 | {
|
---|
237 | LogFlow(("VBoxSDLFB::GetHeight\n"));
|
---|
238 | if (!height)
|
---|
239 | return E_INVALIDARG;
|
---|
240 | *height = mGuestYRes;
|
---|
241 | return S_OK;
|
---|
242 | }
|
---|
243 |
|
---|
244 | /**
|
---|
245 | * Lock the framebuffer (make its address immutable).
|
---|
246 | *
|
---|
247 | * @returns COM status code
|
---|
248 | */
|
---|
249 | STDMETHODIMP VBoxSDLFB::Lock()
|
---|
250 | {
|
---|
251 | LogFlow(("VBoxSDLFB::Lock\n"));
|
---|
252 | RTCritSectEnter(&mUpdateLock);
|
---|
253 | return S_OK;
|
---|
254 | }
|
---|
255 |
|
---|
256 | /**
|
---|
257 | * Unlock the framebuffer.
|
---|
258 | *
|
---|
259 | * @returns COM status code
|
---|
260 | */
|
---|
261 | STDMETHODIMP VBoxSDLFB::Unlock()
|
---|
262 | {
|
---|
263 | LogFlow(("VBoxSDLFB::Unlock\n"));
|
---|
264 | RTCritSectLeave(&mUpdateLock);
|
---|
265 | return S_OK;
|
---|
266 | }
|
---|
267 |
|
---|
268 | /**
|
---|
269 | * Return the framebuffer start address.
|
---|
270 | *
|
---|
271 | * @returns COM status code.
|
---|
272 | * @param address Pointer to result variable.
|
---|
273 | */
|
---|
274 | STDMETHODIMP VBoxSDLFB::COMGETTER(Address)(BYTE **address)
|
---|
275 | {
|
---|
276 | LogFlow(("VBoxSDLFB::GetAddress\n"));
|
---|
277 | if (!address)
|
---|
278 | return E_INVALIDARG;
|
---|
279 |
|
---|
280 | if (mSurfVRAM)
|
---|
281 | {
|
---|
282 | *address = (BYTE *) mSurfVRAM->pixels;
|
---|
283 | }
|
---|
284 | else
|
---|
285 | {
|
---|
286 | /* That's actually rather bad. */
|
---|
287 | AssertMsgFailed(("mSurfVRAM is NULL!\n"));
|
---|
288 | return E_FAIL;
|
---|
289 | }
|
---|
290 | LogFlow(("VBoxSDL::GetAddress returning %p\n", *address));
|
---|
291 | return S_OK;
|
---|
292 | }
|
---|
293 |
|
---|
294 | /**
|
---|
295 | * Return the current framebuffer color depth.
|
---|
296 | *
|
---|
297 | * @returns COM status code
|
---|
298 | * @param colorDepth Address of result variable
|
---|
299 | */
|
---|
300 | STDMETHODIMP VBoxSDLFB::COMGETTER(ColorDepth)(ULONG *colorDepth)
|
---|
301 | {
|
---|
302 | LogFlow(("VBoxSDLFB::GetColorDepth\n"));
|
---|
303 | if (!colorDepth)
|
---|
304 | return E_INVALIDARG;
|
---|
305 | /* get the information directly from the surface in use */
|
---|
306 | Assert(mSurfVRAM);
|
---|
307 | *colorDepth = (ULONG)(mSurfVRAM ? mSurfVRAM->format->BitsPerPixel : 0);
|
---|
308 | return S_OK;
|
---|
309 | }
|
---|
310 |
|
---|
311 | /**
|
---|
312 | * Return the current framebuffer line size in bytes.
|
---|
313 | *
|
---|
314 | * @returns COM status code.
|
---|
315 | * @param lineSize Address of result variable.
|
---|
316 | */
|
---|
317 | STDMETHODIMP VBoxSDLFB::COMGETTER(LineSize)(ULONG *lineSize)
|
---|
318 | {
|
---|
319 | LogFlow(("VBoxSDLFB::GetLineSize\n"));
|
---|
320 | if (!lineSize)
|
---|
321 | return E_INVALIDARG;
|
---|
322 | /* get the information directly from the surface */
|
---|
323 | Assert(mSurfVRAM);
|
---|
324 | *lineSize = (ULONG)(mSurfVRAM ? mSurfVRAM->pitch : 0);
|
---|
325 | return S_OK;
|
---|
326 | }
|
---|
327 |
|
---|
328 | STDMETHODIMP VBoxSDLFB::COMGETTER(PixelFormat) (FramebufferPixelFormat_T *pixelFormat)
|
---|
329 | {
|
---|
330 | if (!pixelFormat)
|
---|
331 | return E_POINTER;
|
---|
332 | *pixelFormat = mPixelFormat;
|
---|
333 | return S_OK;
|
---|
334 | }
|
---|
335 |
|
---|
336 | /**
|
---|
337 | * Returns by how many pixels the guest should shrink its
|
---|
338 | * video mode height values.
|
---|
339 | *
|
---|
340 | * @returns COM status code.
|
---|
341 | * @param heightReduction Address of result variable.
|
---|
342 | */
|
---|
343 | STDMETHODIMP VBoxSDLFB::COMGETTER(HeightReduction)(ULONG *heightReduction)
|
---|
344 | {
|
---|
345 | if (!heightReduction)
|
---|
346 | return E_POINTER;
|
---|
347 | #ifdef VBOX_SECURELABEL
|
---|
348 | *heightReduction = mLabelHeight;
|
---|
349 | #else
|
---|
350 | *heightReduction = 0;
|
---|
351 | #endif
|
---|
352 | return S_OK;
|
---|
353 | }
|
---|
354 |
|
---|
355 | /**
|
---|
356 | * Returns a pointer to an alpha-blended overlay used for displaying status
|
---|
357 | * icons above the framebuffer.
|
---|
358 | *
|
---|
359 | * @returns COM status code.
|
---|
360 | * @param aOverlay The overlay framebuffer.
|
---|
361 | */
|
---|
362 | STDMETHODIMP VBoxSDLFB::COMGETTER(Overlay)(IFramebufferOverlay **aOverlay)
|
---|
363 | {
|
---|
364 | if (!aOverlay)
|
---|
365 | return E_POINTER;
|
---|
366 | /* Not yet implemented */
|
---|
367 | *aOverlay = 0;
|
---|
368 | return S_OK;
|
---|
369 | }
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * Notify framebuffer of an update.
|
---|
373 | *
|
---|
374 | * @returns COM status code
|
---|
375 | * @param x Update region upper left corner x value.
|
---|
376 | * @param y Update region upper left corner y value.
|
---|
377 | * @param w Update region width in pixels.
|
---|
378 | * @param h Update region height in pixels.
|
---|
379 | * @param finished Address of output flag whether the update
|
---|
380 | * could be fully processed in this call (which
|
---|
381 | * has to return immediately) or VBox should wait
|
---|
382 | * for a call to the update complete API before
|
---|
383 | * continuing with display updates.
|
---|
384 | */
|
---|
385 | STDMETHODIMP VBoxSDLFB::NotifyUpdate(ULONG x, ULONG y,
|
---|
386 | ULONG w, ULONG h, BOOL *finished)
|
---|
387 | {
|
---|
388 | /*
|
---|
389 | * The input values are in guest screen coordinates.
|
---|
390 | */
|
---|
391 | LogFlow(("VBoxSDLFB::NotifyUpdate: x = %d, y = %d, w = %d, h = %d\n",
|
---|
392 | x, y, w, h));
|
---|
393 |
|
---|
394 | #ifdef __LINUX__
|
---|
395 | /*
|
---|
396 | * SDL does not allow us to make this call from any other thread than
|
---|
397 | * the main SDL thread (which initialized the video mode). So we have
|
---|
398 | * to send an event to the main SDL thread and process it there. For
|
---|
399 | * sake of simplicity, we encode all information in the event parameters.
|
---|
400 | */
|
---|
401 | SDL_Event event;
|
---|
402 | event.type = SDL_USEREVENT;
|
---|
403 | event.user.type = SDL_USER_EVENT_UPDATERECT;
|
---|
404 | // 16 bit is enough for coordinates
|
---|
405 | event.user.data1 = (void*)(x << 16 | y);
|
---|
406 | event.user.data2 = (void*)(w << 16 | h);
|
---|
407 | PushNotifyUpdateEvent(&event);
|
---|
408 | #else /* !__LINUX__ */
|
---|
409 | update(x, y, w, h, true /* fGuestRelative */);
|
---|
410 | #endif /* !__LINUX__ */
|
---|
411 |
|
---|
412 | /*
|
---|
413 | * The Display thread can continue as we will lock the framebuffer
|
---|
414 | * from the SDL thread when we get to actually doing the update.
|
---|
415 | */
|
---|
416 | if (finished)
|
---|
417 | *finished = TRUE;
|
---|
418 | return S_OK;
|
---|
419 | }
|
---|
420 |
|
---|
421 | /**
|
---|
422 | * Request a display resize from the framebuffer.
|
---|
423 | *
|
---|
424 | * @returns COM status code.
|
---|
425 | * @param pixelFormat The requested pixel format.
|
---|
426 | * @param vram Pointer to the guest VRAM buffer (can be NULL).
|
---|
427 | * @param lineSize Size of a scanline in bytes.
|
---|
428 | * @param w New display width in pixels.
|
---|
429 | * @param h New display height in pixels.
|
---|
430 | * @param finished Address of output flag whether the update
|
---|
431 | * could be fully processed in this call (which
|
---|
432 | * has to return immediately) or VBox should wait
|
---|
433 | * for all call to the resize complete API before
|
---|
434 | * continuing with display updates.
|
---|
435 | */
|
---|
436 | STDMETHODIMP VBoxSDLFB::RequestResize(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat, BYTE *vram,
|
---|
437 | ULONG lineSize, ULONG w, ULONG h, BOOL *finished)
|
---|
438 | {
|
---|
439 | LogFlow(("VBoxSDLFB::RequestResize: w = %d, h = %d, pixelFormat: %d, vram = %p, lineSize = %d\n",
|
---|
440 | w, h, pixelFormat, vram, lineSize));
|
---|
441 |
|
---|
442 | /*
|
---|
443 | * SDL does not allow us to make this call from any other thread than
|
---|
444 | * the main thread (the one which initialized the video mode). So we
|
---|
445 | * have to send an event to the main SDL thread and tell VBox to wait.
|
---|
446 | */
|
---|
447 | if (!finished)
|
---|
448 | {
|
---|
449 | AssertMsgFailed(("RequestResize requires the finished flag!\n"));
|
---|
450 | return E_FAIL;
|
---|
451 | }
|
---|
452 | mGuestXRes = w;
|
---|
453 | mGuestYRes = h;
|
---|
454 | mPixelFormat = pixelFormat;
|
---|
455 | mPtrVRAM = vram;
|
---|
456 | mLineSize = lineSize;
|
---|
457 |
|
---|
458 | SDL_Event event;
|
---|
459 | event.type = SDL_USEREVENT;
|
---|
460 | event.user.type = SDL_USER_EVENT_RESIZE;
|
---|
461 |
|
---|
462 | /* Try multiple times if necessary */
|
---|
463 | PushSDLEventForSure(&event);
|
---|
464 |
|
---|
465 | /* we want this request to be processed quickly, so yield the CPU */
|
---|
466 | RTThreadYield();
|
---|
467 |
|
---|
468 | *finished = false;
|
---|
469 |
|
---|
470 | return S_OK;
|
---|
471 | }
|
---|
472 |
|
---|
473 | /**
|
---|
474 | * Returns which acceleration operations are supported
|
---|
475 | *
|
---|
476 | * @returns COM status code
|
---|
477 | * @param operation acceleration operation code
|
---|
478 | * @supported result
|
---|
479 | */
|
---|
480 | STDMETHODIMP VBoxSDLFB::OperationSupported(FramebufferAccelerationOperation_T operation, BOOL *supported)
|
---|
481 | {
|
---|
482 | if (!supported)
|
---|
483 | return E_POINTER;
|
---|
484 |
|
---|
485 | // SDL gives us software surfaces, futile
|
---|
486 | *supported = false;
|
---|
487 | #if 0
|
---|
488 | switch (operation)
|
---|
489 | {
|
---|
490 | case FramebufferAccelerationOperation_SolidFillAcceleration:
|
---|
491 | *supported = true;
|
---|
492 | break;
|
---|
493 | case FramebufferAccelerationOperation_ScreenCopyAcceleration:
|
---|
494 | *supported = true;
|
---|
495 | break;
|
---|
496 | default:
|
---|
497 | *supported = false;
|
---|
498 | }
|
---|
499 | #endif
|
---|
500 | return S_OK;
|
---|
501 | }
|
---|
502 |
|
---|
503 | /**
|
---|
504 | * Returns whether we like the given video mode.
|
---|
505 | *
|
---|
506 | * @returns COM status code
|
---|
507 | * @param width video mode width in pixels
|
---|
508 | * @param height video mode height in pixels
|
---|
509 | * @param bpp video mode bit depth in bits per pixel
|
---|
510 | * @param supported pointer to result variable
|
---|
511 | */
|
---|
512 | STDMETHODIMP VBoxSDLFB::VideoModeSupported(ULONG width, ULONG height, ULONG bpp, BOOL *supported)
|
---|
513 | {
|
---|
514 | if (!supported)
|
---|
515 | return E_POINTER;
|
---|
516 |
|
---|
517 | /* are constraints set? */
|
---|
518 | if ( ( (mMaxScreenWidth != ~(uint32_t)0)
|
---|
519 | && (width > mMaxScreenWidth)
|
---|
520 | || ( (mMaxScreenHeight != ~(uint32_t)0)
|
---|
521 | && (height > mMaxScreenHeight))))
|
---|
522 | {
|
---|
523 | /* nope, we don't want that (but still don't freak out if it is set) */
|
---|
524 | #ifdef DEBUG
|
---|
525 | printf("VBoxSDL::VideoModeSupported: we refused mode %dx%dx%d\n", width, height, bpp);
|
---|
526 | #endif
|
---|
527 | *supported = false;
|
---|
528 | }
|
---|
529 | else
|
---|
530 | {
|
---|
531 | /* anything will do */
|
---|
532 | *supported = true;
|
---|
533 | }
|
---|
534 | return S_OK;
|
---|
535 | }
|
---|
536 |
|
---|
537 | STDMETHODIMP VBoxSDLFB::SolidFill(ULONG x, ULONG y, ULONG width, ULONG height,
|
---|
538 | ULONG color, BOOL *handled)
|
---|
539 | {
|
---|
540 | if (!handled)
|
---|
541 | return E_POINTER;
|
---|
542 | // SDL gives us software surfaces, futile
|
---|
543 | #if 0
|
---|
544 | printf("SolidFill: x: %d, y: %d, w: %d, h: %d, color: %d\n", x, y, width, height, color);
|
---|
545 | SDL_Rect rect = { (Sint16)x, (Sint16)y, (Sint16)width, (Sint16)height };
|
---|
546 | SDL_FillRect(mScreen, &rect, color);
|
---|
547 | //SDL_UpdateRect(mScreen, x, y, width, height);
|
---|
548 | *handled = true;
|
---|
549 | #else
|
---|
550 | *handled = false;
|
---|
551 | #endif
|
---|
552 | return S_OK;
|
---|
553 | }
|
---|
554 |
|
---|
555 | STDMETHODIMP VBoxSDLFB::CopyScreenBits(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
|
---|
556 | ULONG width, ULONG height, BOOL *handled)
|
---|
557 | {
|
---|
558 | if (!handled)
|
---|
559 | return E_POINTER;
|
---|
560 | // SDL gives us software surfaces, futile
|
---|
561 | #if 0
|
---|
562 | SDL_Rect srcRect = { (Sint16)xSrc, (Sint16)ySrc, (Sint16)width, (Sint16)height };
|
---|
563 | SDL_Rect dstRect = { (Sint16)xDst, (Sint16)yDst, (Sint16)width, (Sint16)height };
|
---|
564 | SDL_BlitSurface(mScreen, &srcRect, mScreen, &dstRect);
|
---|
565 | *handled = true;
|
---|
566 | #else
|
---|
567 | *handled = false;
|
---|
568 | #endif
|
---|
569 | return S_OK;
|
---|
570 | }
|
---|
571 |
|
---|
572 | STDMETHODIMP VBoxSDLFB::QueryVisibleRegion(ULONG * aPcRect, BYTE * aPRect)
|
---|
573 | {
|
---|
574 | PRTRECT paRect = (PRTRECT)aPRect;
|
---|
575 |
|
---|
576 | if (!aPcRect)
|
---|
577 | return E_POINTER;
|
---|
578 |
|
---|
579 | /* @todo */
|
---|
580 | return S_OK;
|
---|
581 | }
|
---|
582 |
|
---|
583 | STDMETHODIMP VBoxSDLFB::SetVisibleRegion(ULONG aCRect, BYTE * aPRect)
|
---|
584 | {
|
---|
585 | PRTRECT paRect = (PRTRECT)aPRect;
|
---|
586 |
|
---|
587 | if (!paRect)
|
---|
588 | return E_POINTER;
|
---|
589 |
|
---|
590 | /* @todo */
|
---|
591 | return S_OK;
|
---|
592 | }
|
---|
593 |
|
---|
594 | //
|
---|
595 | // Internal public methods
|
---|
596 | //
|
---|
597 |
|
---|
598 | /**
|
---|
599 | * Method that does the actual resize of the guest framebuffer and
|
---|
600 | * then changes the SDL framebuffer setup.
|
---|
601 | */
|
---|
602 | void VBoxSDLFB::resizeGuest()
|
---|
603 | {
|
---|
604 | LogFlow(("VBoxSDL::resizeGuest() mGuestXRes: %d, mGuestYRes: %d\n", mGuestXRes, mGuestYRes));
|
---|
605 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
606 |
|
---|
607 | int cBitsPerPixel = 32;
|
---|
608 | uint32_t Rmask, Gmask, Bmask, Amask = 0;
|
---|
609 |
|
---|
610 | /* pixel characteristics, default to fallback 32bpp format */
|
---|
611 | if (mPixelFormat == FramebufferPixelFormat_PixelFormatRGB16)
|
---|
612 | cBitsPerPixel = 16;
|
---|
613 | else if (mPixelFormat == FramebufferPixelFormat_PixelFormatRGB24)
|
---|
614 | cBitsPerPixel = 24;
|
---|
615 |
|
---|
616 | switch (cBitsPerPixel)
|
---|
617 | {
|
---|
618 | case 16: Rmask = 0x0000F800; Gmask = 0x000007E0; Bmask = 0x0000001F; break;
|
---|
619 | default: Rmask = 0x00FF0000; Gmask = 0x0000FF00; Bmask = 0x000000FF; break;
|
---|
620 | }
|
---|
621 |
|
---|
622 | /* first free the current surface */
|
---|
623 | if (mSurfVRAM)
|
---|
624 | {
|
---|
625 | SDL_FreeSurface(mSurfVRAM);
|
---|
626 | mSurfVRAM = NULL;
|
---|
627 | }
|
---|
628 |
|
---|
629 | /* is the guest in a linear framebuffer mode we support? */
|
---|
630 | if (mPixelFormat != FramebufferPixelFormat_PixelFormatDefault)
|
---|
631 | {
|
---|
632 | /* Create a source surface from guest VRAM. */
|
---|
633 | mSurfVRAM = SDL_CreateRGBSurfaceFrom(mPtrVRAM, mGuestXRes, mGuestYRes, cBitsPerPixel,
|
---|
634 | mLineSize, Rmask, Gmask, Bmask, Amask);
|
---|
635 | }
|
---|
636 | else
|
---|
637 | {
|
---|
638 | /* Create a software surface for which SDL allocates the RAM */
|
---|
639 | mSurfVRAM = SDL_CreateRGBSurface(SDL_SWSURFACE, mGuestXRes, mGuestYRes, cBitsPerPixel,
|
---|
640 | Rmask, Gmask, Bmask, Amask);
|
---|
641 | }
|
---|
642 | LogFlow(("VBoxSDL:: created VRAM surface %p\n", mSurfVRAM));
|
---|
643 |
|
---|
644 | /* now adjust the SDL resolution */
|
---|
645 | resizeSDL();
|
---|
646 | }
|
---|
647 |
|
---|
648 | /**
|
---|
649 | * Sets SDL video mode. This is independent from guest video
|
---|
650 | * mode changes.
|
---|
651 | *
|
---|
652 | * @remarks Must be called from the SDL thread!
|
---|
653 | */
|
---|
654 | void VBoxSDLFB::resizeSDL(void)
|
---|
655 | {
|
---|
656 | LogFlow(("VBoxSDL:resizeSDL\n"));
|
---|
657 |
|
---|
658 | /*
|
---|
659 | * We request a hardware surface from SDL so that we can perform
|
---|
660 | * accelerated system memory to VRAM blits. The way video handling
|
---|
661 | * works it that on the one hand we have the screen surface from SDL
|
---|
662 | * and on the other hand we have a software surface that we create
|
---|
663 | * using guest VRAM memory for linear modes and using SDL allocated
|
---|
664 | * system memory for text and non linear graphics modes. We never
|
---|
665 | * directly write to the screen surface but always use SDL blitting
|
---|
666 | * functions to blit from our system memory surface to the VRAM.
|
---|
667 | * Therefore, SDL can take advantage of hardware acceleration.
|
---|
668 | */
|
---|
669 | int sdlFlags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
|
---|
670 | if (mfResizable)
|
---|
671 | sdlFlags |= SDL_RESIZABLE;
|
---|
672 | if (mfFullscreen)
|
---|
673 | sdlFlags |= SDL_FULLSCREEN;
|
---|
674 |
|
---|
675 | /*
|
---|
676 | * Now we have to check whether there are video mode restrictions
|
---|
677 | */
|
---|
678 | SDL_Rect **modes;
|
---|
679 | /* Get available fullscreen/hardware modes */
|
---|
680 | modes = SDL_ListModes(NULL, sdlFlags);
|
---|
681 | Assert(modes != NULL);
|
---|
682 | /* -1 means that any mode is possible (usually non fullscreen) */
|
---|
683 | if (modes != (SDL_Rect **)-1)
|
---|
684 | {
|
---|
685 | /*
|
---|
686 | * according to the SDL documentation, the API guarantees that
|
---|
687 | * the modes are sorted from larger to smaller, so we just
|
---|
688 | * take the first entry as the maximum.
|
---|
689 | */
|
---|
690 | mMaxScreenWidth = modes[0]->w;
|
---|
691 | mMaxScreenHeight = modes[0]->h;
|
---|
692 | }
|
---|
693 | else
|
---|
694 | {
|
---|
695 | /* no restriction */
|
---|
696 | mMaxScreenWidth = ~(uint32_t)0;
|
---|
697 | mMaxScreenHeight = ~(uint32_t)0;
|
---|
698 | }
|
---|
699 |
|
---|
700 | uint32_t newWidth;
|
---|
701 | uint32_t newHeight;
|
---|
702 |
|
---|
703 | /* reset the centering offsets */
|
---|
704 | mCenterXOffset = 0;
|
---|
705 | mCenterYOffset = 0;
|
---|
706 |
|
---|
707 | /* we either have a fixed SDL resolution or we take the guest's */
|
---|
708 | if (mFixedSDLWidth != ~(uint32_t)0)
|
---|
709 | {
|
---|
710 | newWidth = mFixedSDLWidth;
|
---|
711 | newHeight = mFixedSDLHeight;
|
---|
712 | }
|
---|
713 | else
|
---|
714 | {
|
---|
715 | newWidth = RT_MIN(mGuestXRes, mMaxScreenWidth);
|
---|
716 | #ifdef VBOX_SECURELABEL
|
---|
717 | newHeight = RT_MIN(mGuestYRes + mLabelHeight, mMaxScreenHeight);
|
---|
718 | #else
|
---|
719 | newHeight = RT_MIN(mGuestYRes, mMaxScreenHeight);
|
---|
720 | #endif
|
---|
721 | }
|
---|
722 |
|
---|
723 | /* we don't have any extra space by default */
|
---|
724 | mTopOffset = 0;
|
---|
725 |
|
---|
726 | /*
|
---|
727 | * Now set the screen resolution and get the surface pointer
|
---|
728 | * @todo BPP is not supported!
|
---|
729 | */
|
---|
730 | mScreen = SDL_SetVideoMode(newWidth, newHeight, 0, sdlFlags);
|
---|
731 | #ifdef VBOX_SECURELABEL
|
---|
732 | /*
|
---|
733 | * For non fixed SDL resolution, the above call tried to add the label height
|
---|
734 | * to the guest height. If it worked, we have an offset. If it didn't the below
|
---|
735 | * code will try again with the original guest resolution.
|
---|
736 | */
|
---|
737 | if (mFixedSDLWidth == ~(uint32_t)0)
|
---|
738 | {
|
---|
739 | /* if it didn't work, then we have to go for the original resolution and paint over the guest */
|
---|
740 | if (!mScreen)
|
---|
741 | {
|
---|
742 | mScreen = SDL_SetVideoMode(newWidth, newHeight - mLabelHeight, 0, sdlFlags);
|
---|
743 | }
|
---|
744 | else
|
---|
745 | {
|
---|
746 | /* we now have some extra space */
|
---|
747 | mTopOffset = mLabelHeight;
|
---|
748 | }
|
---|
749 | }
|
---|
750 | else
|
---|
751 | {
|
---|
752 | /* in case the guest resolution is small enough, we do have a top offset */
|
---|
753 | if (mFixedSDLHeight - mGuestYRes >= mLabelHeight)
|
---|
754 | mTopOffset = mLabelHeight;
|
---|
755 |
|
---|
756 | /* we also might have to center the guest picture */
|
---|
757 | if (mFixedSDLWidth > mGuestXRes)
|
---|
758 | mCenterXOffset = (mFixedSDLWidth - mGuestXRes) / 2;
|
---|
759 | if (mFixedSDLHeight > mGuestYRes + mLabelHeight)
|
---|
760 | mCenterYOffset = (mFixedSDLHeight - (mGuestYRes + mLabelHeight)) / 2;
|
---|
761 | }
|
---|
762 | #endif
|
---|
763 | AssertMsg(mScreen, ("Error: SDL_SetVideoMode failed!\n"));
|
---|
764 | if (mScreen)
|
---|
765 | {
|
---|
766 | #ifdef VBOX_WIN32_UI
|
---|
767 | /* inform the UI code */
|
---|
768 | resizeUI(mScreen->w, mScreen->h);
|
---|
769 | #endif
|
---|
770 | if (mfShowSDLConfig)
|
---|
771 | RTPrintf("Resized to %dx%d, screen surface type: %s\n", mScreen->w, mScreen->h,
|
---|
772 | ((mScreen->flags & SDL_HWSURFACE) == 0) ? "software" : "hardware");
|
---|
773 | }
|
---|
774 | repaint();
|
---|
775 | }
|
---|
776 |
|
---|
777 | /**
|
---|
778 | * Update specified framebuffer area. The coordinates can either be
|
---|
779 | * relative to the guest framebuffer or relative to the screen.
|
---|
780 | *
|
---|
781 | * @remarks Must be called from the SDL thread on Linux!
|
---|
782 | * @param x left column
|
---|
783 | * @param y top row
|
---|
784 | * @param w width in pixels
|
---|
785 | * @param h height in pixels
|
---|
786 | * @param fGuestRelative flag whether the above values are guest relative or screen relative;
|
---|
787 | */
|
---|
788 | void VBoxSDLFB::update(int x, int y, int w, int h, bool fGuestRelative)
|
---|
789 | {
|
---|
790 | #ifdef __LINUX__
|
---|
791 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
792 | #endif
|
---|
793 | Assert(mScreen);
|
---|
794 | Assert(mSurfVRAM);
|
---|
795 | if (!mScreen || !mSurfVRAM)
|
---|
796 | return;
|
---|
797 |
|
---|
798 | /* the source and destination rectangles */
|
---|
799 | SDL_Rect srcRect;
|
---|
800 | SDL_Rect dstRect;
|
---|
801 |
|
---|
802 | /* this is how many pixels we have to cut off from the height for this specific blit */
|
---|
803 | int yCutoffGuest = 0;
|
---|
804 |
|
---|
805 | #ifdef VBOX_SECURELABEL
|
---|
806 | bool fPaintLabel = false;
|
---|
807 | /* if we have a label and no space for it, we have to cut off a bit */
|
---|
808 | if (mLabelHeight && !mTopOffset)
|
---|
809 | {
|
---|
810 | if (y < (int)mLabelHeight)
|
---|
811 | yCutoffGuest = mLabelHeight - y;
|
---|
812 | }
|
---|
813 | #endif
|
---|
814 |
|
---|
815 | /**
|
---|
816 | * If we get a SDL window relative update, we
|
---|
817 | * just perform a full screen update to keep things simple.
|
---|
818 | *
|
---|
819 | * @todo improve
|
---|
820 | */
|
---|
821 | if (!fGuestRelative)
|
---|
822 | {
|
---|
823 | #ifdef VBOX_SECURELABEL
|
---|
824 | /* repaint the label if necessary */
|
---|
825 | if (y < (int)mLabelHeight)
|
---|
826 | fPaintLabel = true;
|
---|
827 | #endif
|
---|
828 | x = 0;
|
---|
829 | w = mGuestXRes;
|
---|
830 | y = 0;
|
---|
831 | h = mGuestYRes;
|
---|
832 | }
|
---|
833 |
|
---|
834 | srcRect.x = x;
|
---|
835 | srcRect.y = y + yCutoffGuest;
|
---|
836 | srcRect.w = w;
|
---|
837 | srcRect.h = RT_MAX(0, h - yCutoffGuest);
|
---|
838 |
|
---|
839 | /*
|
---|
840 | * Destination rectangle is just offset by the label height.
|
---|
841 | * There are two cases though: label height is added to the
|
---|
842 | * guest resolution (mTopOffset == mLabelHeight; yCutoffGuest == 0)
|
---|
843 | * or the label cuts off a portion of the guest screen (mTopOffset == 0;
|
---|
844 | * yCutoffGuest >= 0)
|
---|
845 | */
|
---|
846 | dstRect.x = x + mCenterXOffset;
|
---|
847 | #ifdef VBOX_SECURELABEL
|
---|
848 | dstRect.y = RT_MAX(mLabelHeight, y + yCutoffGuest + mTopOffset) + mCenterYOffset;
|
---|
849 | #else
|
---|
850 | dstRect.y = y + yCutoffGuest + mTopOffset + mCenterYOffset;
|
---|
851 | #endif
|
---|
852 | dstRect.w = w;
|
---|
853 | dstRect.h = RT_MAX(0, h - yCutoffGuest);
|
---|
854 |
|
---|
855 | //RTPrintf("y = %d h = %d mapped to srcY %d srcH %d mapped to dstY = %d dstH %d (guestrel: %d, mLabelHeight: %d, mTopOffset: %d)\n",
|
---|
856 | // y, h, srcRect.y, srcRect.h, dstRect.y, dstRect.h, fGuestRelative, mLabelHeight, mTopOffset);
|
---|
857 |
|
---|
858 | /*
|
---|
859 | * Now we just blit
|
---|
860 | */
|
---|
861 | SDL_BlitSurface(mSurfVRAM, &srcRect, mScreen, &dstRect);
|
---|
862 | /* hardware surfaces don't need update notifications */
|
---|
863 | if ((mScreen->flags & SDL_HWSURFACE) == 0)
|
---|
864 | SDL_UpdateRect(mScreen, dstRect.x, dstRect.y, dstRect.w, dstRect.h);
|
---|
865 |
|
---|
866 | #ifdef VBOX_SECURELABEL
|
---|
867 | if (fPaintLabel)
|
---|
868 | paintSecureLabel(0, 0, 0, 0, false);
|
---|
869 | #endif
|
---|
870 | }
|
---|
871 |
|
---|
872 | /**
|
---|
873 | * Repaint the whole framebuffer
|
---|
874 | *
|
---|
875 | * @remarks Must be called from the SDL thread!
|
---|
876 | */
|
---|
877 | void VBoxSDLFB::repaint()
|
---|
878 | {
|
---|
879 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
880 | LogFlow(("VBoxSDLFB::repaint\n"));
|
---|
881 | update(0, 0, mScreen->w, mScreen->h, false /* fGuestRelative */);
|
---|
882 | }
|
---|
883 |
|
---|
884 | bool VBoxSDLFB::getFullscreen()
|
---|
885 | {
|
---|
886 | LogFlow(("VBoxSDLFB::getFullscreen\n"));
|
---|
887 | return mfFullscreen;
|
---|
888 | }
|
---|
889 |
|
---|
890 | /**
|
---|
891 | * Toggle fullscreen mode
|
---|
892 | *
|
---|
893 | * @remarks Must be called from the SDL thread!
|
---|
894 | */
|
---|
895 | void VBoxSDLFB::setFullscreen(bool fFullscreen)
|
---|
896 | {
|
---|
897 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
898 | LogFlow(("VBoxSDLFB::SetFullscreen: fullscreen: %d\n", fFullscreen));
|
---|
899 | mfFullscreen = fFullscreen;
|
---|
900 | /* only change the SDL resolution, do not touch the guest framebuffer */
|
---|
901 | resizeSDL();
|
---|
902 | }
|
---|
903 |
|
---|
904 |
|
---|
905 | /**
|
---|
906 | * Returns the current x offset of the start of the guest screen
|
---|
907 | *
|
---|
908 | * @returns current x offset in pixels
|
---|
909 | */
|
---|
910 | int VBoxSDLFB::getXOffset()
|
---|
911 | {
|
---|
912 | /* there can only be an offset for centering */
|
---|
913 | return mCenterXOffset;
|
---|
914 | }
|
---|
915 |
|
---|
916 | /**
|
---|
917 | * Returns the current y offset of the start of the guest screen
|
---|
918 | *
|
---|
919 | * @returns current y offset in pixels
|
---|
920 | */
|
---|
921 | int VBoxSDLFB::getYOffset()
|
---|
922 | {
|
---|
923 | /* we might have a top offset and a center offset */
|
---|
924 | return mTopOffset + mCenterYOffset;
|
---|
925 | }
|
---|
926 |
|
---|
927 | #ifdef VBOX_SECURELABEL
|
---|
928 | /**
|
---|
929 | * Setup the secure labeling parameters
|
---|
930 | *
|
---|
931 | * @returns VBox status code
|
---|
932 | * @param height height of the secure label area in pixels
|
---|
933 | * @param font file path fo the TrueType font file
|
---|
934 | * @param pointsize font size in points
|
---|
935 | */
|
---|
936 | int VBoxSDLFB::initSecureLabel(uint32_t height, char *font, uint32_t pointsize)
|
---|
937 | {
|
---|
938 | LogFlow(("VBoxSDLFB:initSecureLabel: new offset: %d pixels, new font: %s, new pointsize: %d\n",
|
---|
939 | height, font, pointsize));
|
---|
940 | mLabelHeight = height;
|
---|
941 | Assert(font);
|
---|
942 | pTTF_Init();
|
---|
943 | mLabelFont = pTTF_OpenFont(font, pointsize);
|
---|
944 | if (!mLabelFont)
|
---|
945 | {
|
---|
946 | AssertMsgFailed(("Failed to open TTF font file %s\n", font));
|
---|
947 | return VERR_OPEN_FAILED;
|
---|
948 | }
|
---|
949 | mSecureLabelColorFG = 0x0000FF00;
|
---|
950 | mSecureLabelColorBG = 0x00FFFF00;
|
---|
951 | repaint();
|
---|
952 | return VINF_SUCCESS;
|
---|
953 | }
|
---|
954 |
|
---|
955 | /**
|
---|
956 | * Set the secure label text and repaint the label
|
---|
957 | *
|
---|
958 | * @param text UTF-8 string of new label
|
---|
959 | * @remarks must be called from the SDL thread!
|
---|
960 | */
|
---|
961 | void VBoxSDLFB::setSecureLabelText(const char *text)
|
---|
962 | {
|
---|
963 | mSecureLabelText = text;
|
---|
964 | paintSecureLabel(0, 0, 0, 0, true);
|
---|
965 | }
|
---|
966 |
|
---|
967 | /**
|
---|
968 | * Sets the secure label background color.
|
---|
969 | *
|
---|
970 | * @param colorFG encoded RGB value for text
|
---|
971 | * @param colorBG encored RGB value for background
|
---|
972 | * @remarks must be called from the SDL thread!
|
---|
973 | */
|
---|
974 | void VBoxSDLFB::setSecureLabelColor(uint32_t colorFG, uint32_t colorBG)
|
---|
975 | {
|
---|
976 | mSecureLabelColorFG = colorFG;
|
---|
977 | mSecureLabelColorBG = colorBG;
|
---|
978 | paintSecureLabel(0, 0, 0, 0, true);
|
---|
979 | }
|
---|
980 |
|
---|
981 | /**
|
---|
982 | * Paint the secure label if required
|
---|
983 | *
|
---|
984 | * @param fForce Force the repaint
|
---|
985 | * @remarks must be called from the SDL thread!
|
---|
986 | */
|
---|
987 | void VBoxSDLFB::paintSecureLabel(int x, int y, int w, int h, bool fForce)
|
---|
988 | {
|
---|
989 | #ifdef __LINUX__
|
---|
990 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
991 | #endif
|
---|
992 | /* only when the function is present */
|
---|
993 | if (!pTTF_RenderUTF8_Solid)
|
---|
994 | return;
|
---|
995 | /* check if we can skip the paint */
|
---|
996 | if (!fForce && ((uint32_t)y > mLabelHeight))
|
---|
997 | {
|
---|
998 | return;
|
---|
999 | }
|
---|
1000 | /* first fill the background */
|
---|
1001 | SDL_Rect rect = {0, 0, (Uint16)mScreen->w, (Uint16)mLabelHeight};
|
---|
1002 | SDL_FillRect(mScreen, &rect, SDL_MapRGB(mScreen->format,
|
---|
1003 | (mSecureLabelColorBG & 0x00FF0000) >> 16, /* red */
|
---|
1004 | (mSecureLabelColorBG & 0x0000FF00) >> 8, /* green */
|
---|
1005 | mSecureLabelColorBG & 0x000000FF)); /* blue */
|
---|
1006 |
|
---|
1007 | /* now the text */
|
---|
1008 | if (mLabelFont != NULL && mSecureLabelText)
|
---|
1009 | {
|
---|
1010 | SDL_Color clrFg = {(mSecureLabelColorFG & 0x00FF0000) >> 16,
|
---|
1011 | (mSecureLabelColorFG & 0x0000FF00) >> 8,
|
---|
1012 | mSecureLabelColorFG & 0x000000FF, 0};
|
---|
1013 | SDL_Surface *sText = pTTF_RenderUTF8_Solid(mLabelFont, mSecureLabelText.raw(), clrFg);
|
---|
1014 | rect.x = 10;
|
---|
1015 | SDL_BlitSurface(sText, NULL, mScreen, &rect);
|
---|
1016 | SDL_FreeSurface(sText);
|
---|
1017 | }
|
---|
1018 | /* make sure to update the screen */
|
---|
1019 | SDL_UpdateRect(mScreen, 0, 0, mScreen->w, mLabelHeight);
|
---|
1020 | }
|
---|
1021 | #endif /* VBOX_SECURELABEL */
|
---|
1022 |
|
---|
1023 | /**
|
---|
1024 | * Terminate SDL
|
---|
1025 | *
|
---|
1026 | * @remarks must be called from the SDL thread!
|
---|
1027 | */
|
---|
1028 | void VBoxSDLFB::uninit()
|
---|
1029 | {
|
---|
1030 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
1031 | if (mSurfVRAM)
|
---|
1032 | {
|
---|
1033 | SDL_FreeSurface(mSurfVRAM);
|
---|
1034 | mSurfVRAM = NULL;
|
---|
1035 | }
|
---|
1036 | SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
---|
1037 | #ifdef VBOX_SECURELABEL
|
---|
1038 | if (mLabelFont)
|
---|
1039 | pTTF_CloseFont(mLabelFont);
|
---|
1040 | if (pTTF_Quit)
|
---|
1041 | pTTF_Quit();
|
---|
1042 | #endif
|
---|
1043 | mScreen = NULL;
|
---|
1044 | if (mWMIcon)
|
---|
1045 | {
|
---|
1046 | SDL_FreeSurface(mWMIcon);
|
---|
1047 | mWMIcon = NULL;
|
---|
1048 | }
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | // IFramebufferOverlay
|
---|
1052 | ///////////////////////////////////////////////////////////////////////////////////
|
---|
1053 |
|
---|
1054 | /**
|
---|
1055 | * Constructor for the VBoxSDLFBOverlay class (IFramebufferOverlay implementation)
|
---|
1056 | *
|
---|
1057 | * @param x Initial X offset for the overlay
|
---|
1058 | * @param y Initial Y offset for the overlay
|
---|
1059 | * @param width Initial width for the overlay
|
---|
1060 | * @param height Initial height for the overlay
|
---|
1061 | * @param visible Whether the overlay is initially visible
|
---|
1062 | * @param alpha Initial alpha channel value for the overlay
|
---|
1063 | */
|
---|
1064 | VBoxSDLFBOverlay::VBoxSDLFBOverlay(ULONG x, ULONG y, ULONG width, ULONG height,
|
---|
1065 | BOOL visible, VBoxSDLFB *aParent) :
|
---|
1066 | mOverlayX(x), mOverlayY(y), mOverlayWidth(width),
|
---|
1067 | mOverlayHeight(height), mOverlayVisible(visible),
|
---|
1068 | mParent(aParent)
|
---|
1069 | {}
|
---|
1070 |
|
---|
1071 | /**
|
---|
1072 | * Destructor for the VBoxSDLFBOverlay class.
|
---|
1073 | */
|
---|
1074 | VBoxSDLFBOverlay::~VBoxSDLFBOverlay()
|
---|
1075 | {
|
---|
1076 | SDL_FreeSurface(mBlendedBits);
|
---|
1077 | SDL_FreeSurface(mOverlayBits);
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | /**
|
---|
1081 | * Perform any initialisation of the overlay that can potentially fail
|
---|
1082 | *
|
---|
1083 | * @returns S_OK on success or the reason for the failure
|
---|
1084 | */
|
---|
1085 | HRESULT VBoxSDLFBOverlay::init()
|
---|
1086 | {
|
---|
1087 | mBlendedBits = SDL_CreateRGBSurface(SDL_ANYFORMAT, mOverlayWidth, mOverlayHeight, 32,
|
---|
1088 | 0x00ff0000, 0x0000ff00, 0x000000ff, 0);
|
---|
1089 | AssertMsgReturn(mBlendedBits != NULL, ("Failed to create an SDL surface\n"),
|
---|
1090 | E_OUTOFMEMORY);
|
---|
1091 | mOverlayBits = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, mOverlayWidth,
|
---|
1092 | mOverlayHeight, 32, 0x00ff0000, 0x0000ff00,
|
---|
1093 | 0x000000ff, 0xff000000);
|
---|
1094 | AssertMsgReturn(mOverlayBits != NULL, ("Failed to create an SDL surface\n"),
|
---|
1095 | E_OUTOFMEMORY);
|
---|
1096 | return S_OK;
|
---|
1097 | }
|
---|
1098 |
|
---|
1099 | /**
|
---|
1100 | * Returns the current overlay X offset in pixels.
|
---|
1101 | *
|
---|
1102 | * @returns COM status code
|
---|
1103 | * @param x Address of result buffer.
|
---|
1104 | */
|
---|
1105 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(X)(ULONG *x)
|
---|
1106 | {
|
---|
1107 | LogFlow(("VBoxSDLFBOverlay::GetX\n"));
|
---|
1108 | if (!x)
|
---|
1109 | return E_INVALIDARG;
|
---|
1110 | *x = mOverlayX;
|
---|
1111 | return S_OK;
|
---|
1112 | }
|
---|
1113 |
|
---|
1114 | /**
|
---|
1115 | * Returns the current overlay height in pixels.
|
---|
1116 | *
|
---|
1117 | * @returns COM status code
|
---|
1118 | * @param height Address of result buffer.
|
---|
1119 | */
|
---|
1120 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Y)(ULONG *y)
|
---|
1121 | {
|
---|
1122 | LogFlow(("VBoxSDLFBOverlay::GetY\n"));
|
---|
1123 | if (!y)
|
---|
1124 | return E_INVALIDARG;
|
---|
1125 | *y = mOverlayY;
|
---|
1126 | return S_OK;
|
---|
1127 | }
|
---|
1128 |
|
---|
1129 | /**
|
---|
1130 | * Returns the current overlay width in pixels. In fact, this returns the line size.
|
---|
1131 | *
|
---|
1132 | * @returns COM status code
|
---|
1133 | * @param width Address of result buffer.
|
---|
1134 | */
|
---|
1135 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Width)(ULONG *width)
|
---|
1136 | {
|
---|
1137 | LogFlow(("VBoxSDLFBOverlay::GetWidth\n"));
|
---|
1138 | if (!width)
|
---|
1139 | return E_INVALIDARG;
|
---|
1140 | *width = mOverlayBits->pitch;
|
---|
1141 | return S_OK;
|
---|
1142 | }
|
---|
1143 |
|
---|
1144 | /**
|
---|
1145 | * Returns the current overlay line size in pixels.
|
---|
1146 | *
|
---|
1147 | * @returns COM status code
|
---|
1148 | * @param lineSize Address of result buffer.
|
---|
1149 | */
|
---|
1150 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(LineSize)(ULONG *lineSize)
|
---|
1151 | {
|
---|
1152 | LogFlow(("VBoxSDLFBOverlay::GetLineSize\n"));
|
---|
1153 | if (!lineSize)
|
---|
1154 | return E_INVALIDARG;
|
---|
1155 | *lineSize = mOverlayBits->pitch;
|
---|
1156 | return S_OK;
|
---|
1157 | }
|
---|
1158 |
|
---|
1159 | /**
|
---|
1160 | * Returns the current overlay height in pixels.
|
---|
1161 | *
|
---|
1162 | * @returns COM status code
|
---|
1163 | * @param height Address of result buffer.
|
---|
1164 | */
|
---|
1165 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Height)(ULONG *height)
|
---|
1166 | {
|
---|
1167 | LogFlow(("VBoxSDLFBOverlay::GetHeight\n"));
|
---|
1168 | if (!height)
|
---|
1169 | return E_INVALIDARG;
|
---|
1170 | *height = mOverlayHeight;
|
---|
1171 | return S_OK;
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | /**
|
---|
1175 | * Returns whether the overlay is currently visible.
|
---|
1176 | *
|
---|
1177 | * @returns COM status code
|
---|
1178 | * @param visible Address of result buffer.
|
---|
1179 | */
|
---|
1180 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Visible)(BOOL *visible)
|
---|
1181 | {
|
---|
1182 | LogFlow(("VBoxSDLFBOverlay::GetVisible\n"));
|
---|
1183 | if (!visible)
|
---|
1184 | return E_INVALIDARG;
|
---|
1185 | *visible = mOverlayVisible;
|
---|
1186 | return S_OK;
|
---|
1187 | }
|
---|
1188 |
|
---|
1189 | /**
|
---|
1190 | * Sets whether the overlay is currently visible.
|
---|
1191 | *
|
---|
1192 | * @returns COM status code
|
---|
1193 | * @param visible New value.
|
---|
1194 | */
|
---|
1195 | STDMETHODIMP VBoxSDLFBOverlay::COMSETTER(Visible)(BOOL visible)
|
---|
1196 | {
|
---|
1197 | LogFlow(("VBoxSDLFBOverlay::SetVisible\n"));
|
---|
1198 | mOverlayVisible = visible;
|
---|
1199 | return S_OK;
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | /**
|
---|
1203 | * Returns the value of the global alpha channel.
|
---|
1204 | *
|
---|
1205 | * @returns COM status code
|
---|
1206 | * @param alpha Address of result buffer.
|
---|
1207 | */
|
---|
1208 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Alpha)(ULONG *alpha)
|
---|
1209 | {
|
---|
1210 | LogFlow(("VBoxSDLFBOverlay::GetAlpha\n"));
|
---|
1211 | return E_NOTIMPL;
|
---|
1212 | }
|
---|
1213 |
|
---|
1214 | /**
|
---|
1215 | * Sets whether the overlay is currently visible.
|
---|
1216 | *
|
---|
1217 | * @returns COM status code
|
---|
1218 | * @param alpha new value.
|
---|
1219 | */
|
---|
1220 | STDMETHODIMP VBoxSDLFBOverlay::COMSETTER(Alpha)(ULONG alpha)
|
---|
1221 | {
|
---|
1222 | LogFlow(("VBoxSDLFBOverlay::SetAlpha\n"));
|
---|
1223 | return E_NOTIMPL;
|
---|
1224 | }
|
---|
1225 |
|
---|
1226 | /**
|
---|
1227 | * Returns the address of the framebuffer bits for writing to.
|
---|
1228 | *
|
---|
1229 | * @returns COM status code
|
---|
1230 | * @param alpha Address of result buffer.
|
---|
1231 | */
|
---|
1232 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Address)(ULONG *address)
|
---|
1233 | {
|
---|
1234 | LogFlow(("VBoxSDLFBOverlay::GetAddress\n"));
|
---|
1235 | if (!address)
|
---|
1236 | return E_INVALIDARG;
|
---|
1237 | *address = (uintptr_t) mOverlayBits->pixels;
|
---|
1238 | return S_OK;
|
---|
1239 | }
|
---|
1240 |
|
---|
1241 | /**
|
---|
1242 | * Returns the current colour depth. In fact, this is always 32bpp.
|
---|
1243 | *
|
---|
1244 | * @returns COM status code
|
---|
1245 | * @param colorDepth Address of result buffer.
|
---|
1246 | */
|
---|
1247 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(ColorDepth)(ULONG *colorDepth)
|
---|
1248 | {
|
---|
1249 | LogFlow(("VBoxSDLFBOverlay::GetColorDepth\n"));
|
---|
1250 | if (!colorDepth)
|
---|
1251 | return E_INVALIDARG;
|
---|
1252 | *colorDepth = 32;
|
---|
1253 | return S_OK;
|
---|
1254 | }
|
---|
1255 |
|
---|
1256 | /**
|
---|
1257 | * Returns the current pixel format. In fact, this is always RGB32.
|
---|
1258 | *
|
---|
1259 | * @returns COM status code
|
---|
1260 | * @param pixelFormat Address of result buffer.
|
---|
1261 | */
|
---|
1262 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(PixelFormat)(FramebufferPixelFormat_T *pixelFormat)
|
---|
1263 | {
|
---|
1264 | LogFlow(("VBoxSDLFBOverlay::GetPixelFormat\n"));
|
---|
1265 | if (!pixelFormat)
|
---|
1266 | return E_INVALIDARG;
|
---|
1267 | *pixelFormat = FramebufferPixelFormat_PixelFormatRGB32;
|
---|
1268 | return S_OK;
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 | /**
|
---|
1272 | * Returns the height reduction. In fact, this is always 0.
|
---|
1273 | *
|
---|
1274 | * @returns COM status code
|
---|
1275 | * @param heightReduction Address of result buffer.
|
---|
1276 | */
|
---|
1277 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(HeightReduction)(ULONG *heightReduction)
|
---|
1278 | {
|
---|
1279 | LogFlow(("VBoxSDLFBOverlay::GetHeightReduction\n"));
|
---|
1280 | if (!heightReduction)
|
---|
1281 | return E_INVALIDARG;
|
---|
1282 | *heightReduction = 0;
|
---|
1283 | return S_OK;
|
---|
1284 | }
|
---|
1285 |
|
---|
1286 | /**
|
---|
1287 | * Returns the overlay for this framebuffer. Obviously, we return NULL here.
|
---|
1288 | *
|
---|
1289 | * @returns COM status code
|
---|
1290 | * @param overlay Address of result buffer.
|
---|
1291 | */
|
---|
1292 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Overlay)(IFramebufferOverlay **aOverlay)
|
---|
1293 | {
|
---|
1294 | LogFlow(("VBoxSDLFBOverlay::GetOverlay\n"));
|
---|
1295 | if (!aOverlay)
|
---|
1296 | return E_INVALIDARG;
|
---|
1297 | *aOverlay = 0;
|
---|
1298 | return S_OK;
|
---|
1299 | }
|
---|
1300 |
|
---|
1301 | /**
|
---|
1302 | * Lock the overlay. This should not be used - lock the parent IFramebuffer instead.
|
---|
1303 | *
|
---|
1304 | * @returns COM status code
|
---|
1305 | */
|
---|
1306 | STDMETHODIMP VBoxSDLFBOverlay::Lock()
|
---|
1307 | {
|
---|
1308 | LogFlow(("VBoxSDLFBOverlay::Lock\n"));
|
---|
1309 | AssertMsgFailed(("You should not attempt to lock an IFramebufferOverlay object -\n"
|
---|
1310 | "lock the parent IFramebuffer object instead.\n"));
|
---|
1311 | return E_NOTIMPL;
|
---|
1312 | }
|
---|
1313 |
|
---|
1314 | /**
|
---|
1315 | * Unlock the overlay.
|
---|
1316 | *
|
---|
1317 | * @returns COM status code
|
---|
1318 | */
|
---|
1319 | STDMETHODIMP VBoxSDLFBOverlay::Unlock()
|
---|
1320 | {
|
---|
1321 | LogFlow(("VBoxSDLFBOverlay::Unlock\n"));
|
---|
1322 | AssertMsgFailed(("You should not attempt to lock an IFramebufferOverlay object -\n"
|
---|
1323 | "lock the parent IFramebuffer object instead.\n"));
|
---|
1324 | return E_NOTIMPL;
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 | /**
|
---|
1328 | * Change the X and Y co-ordinates of the overlay area.
|
---|
1329 | *
|
---|
1330 | * @returns COM status code
|
---|
1331 | * @param x New X co-ordinate.
|
---|
1332 | * @param y New Y co-ordinate.
|
---|
1333 | */
|
---|
1334 | STDMETHODIMP VBoxSDLFBOverlay::Move(ULONG x, ULONG y)
|
---|
1335 | {
|
---|
1336 | mOverlayX = x;
|
---|
1337 | mOverlayY = y;
|
---|
1338 | return S_OK;
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 | /**
|
---|
1342 | * Notify the overlay that a section of the framebuffer has been redrawn.
|
---|
1343 | *
|
---|
1344 | * @returns COM status code
|
---|
1345 | * @param x X co-ordinate of upper left corner of modified area.
|
---|
1346 | * @param y Y co-ordinate of upper left corner of modified area.
|
---|
1347 | * @param w Width of modified area.
|
---|
1348 | * @param h Height of modified area.
|
---|
1349 | * @retval finished Set if the operation has completed.
|
---|
1350 | *
|
---|
1351 | * All we do here is to send a request to the parent to update the affected area,
|
---|
1352 | * translating between our co-ordinate system and the parent's. It would be have
|
---|
1353 | * been better to call the parent directly, but such is life. We leave bounds
|
---|
1354 | * checking to the parent.
|
---|
1355 | */
|
---|
1356 | STDMETHODIMP VBoxSDLFBOverlay::NotifyUpdate(ULONG x, ULONG y,
|
---|
1357 | ULONG w, ULONG h, BOOL *finished)
|
---|
1358 | {
|
---|
1359 | return mParent->NotifyUpdate(x + mOverlayX, y + mOverlayY, w, h, finished);
|
---|
1360 | }
|
---|
1361 |
|
---|
1362 | /**
|
---|
1363 | * Change the dimensions of the overlay.
|
---|
1364 | *
|
---|
1365 | * @returns COM status code
|
---|
1366 | * @param pixelFormat Must be FramebufferPixelFormat_PixelFormatRGB32.
|
---|
1367 | * @param vram Must be NULL.
|
---|
1368 | * @param lineSize Ignored.
|
---|
1369 | * @param w New overlay width.
|
---|
1370 | * @param h New overlay height.
|
---|
1371 | * @retval finished Set if the operation has completed.
|
---|
1372 | */
|
---|
1373 | STDMETHODIMP VBoxSDLFBOverlay::RequestResize(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat,
|
---|
1374 | ULONG vram, ULONG lineSize, ULONG w,
|
---|
1375 | ULONG h, BOOL *finished)
|
---|
1376 | {
|
---|
1377 | AssertReturn(pixelFormat == FramebufferPixelFormat_PixelFormatRGB32, E_INVALIDARG);
|
---|
1378 | AssertReturn(vram == 0, E_INVALIDARG);
|
---|
1379 | mOverlayWidth = w;
|
---|
1380 | mOverlayHeight = h;
|
---|
1381 | SDL_FreeSurface(mOverlayBits);
|
---|
1382 | mBlendedBits = SDL_CreateRGBSurface(SDL_ANYFORMAT, mOverlayWidth, mOverlayHeight, 32,
|
---|
1383 | 0x00ff0000, 0x0000ff00, 0x000000ff, 0);
|
---|
1384 | AssertMsgReturn(mBlendedBits != NULL, ("Failed to create an SDL surface\n"),
|
---|
1385 | E_OUTOFMEMORY);
|
---|
1386 | mOverlayBits = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, mOverlayWidth,
|
---|
1387 | mOverlayHeight, 32, 0x00ff0000, 0x0000ff00,
|
---|
1388 | 0x000000ff, 0xff000000);
|
---|
1389 | AssertMsgReturn(mOverlayBits != NULL, ("Failed to create an SDL surface\n"),
|
---|
1390 | E_OUTOFMEMORY);
|
---|
1391 | return S_OK;
|
---|
1392 | }
|
---|
1393 |
|
---|
1394 | /**
|
---|
1395 | * Queries whether we support a given accelerated opperation. Since we do not currently
|
---|
1396 | * support any accelerated operations, we always return false in supported.
|
---|
1397 | *
|
---|
1398 | * @returns COM status code
|
---|
1399 | * @param operation The operation being queried
|
---|
1400 | * @retval supported Whether or not we support that operation
|
---|
1401 | */
|
---|
1402 | STDMETHODIMP VBoxSDLFBOverlay::OperationSupported(FramebufferAccelerationOperation_T
|
---|
1403 | operation, BOOL *supported)
|
---|
1404 | {
|
---|
1405 | if (!supported)
|
---|
1406 | return E_POINTER;
|
---|
1407 | /* We currently do not support any acceleration here, and will probably not in
|
---|
1408 | the forseeable future. */
|
---|
1409 | *supported = false;
|
---|
1410 | return S_OK;
|
---|
1411 | }
|
---|
1412 |
|
---|
1413 | /**
|
---|
1414 | * Returns whether we like the given video mode.
|
---|
1415 | *
|
---|
1416 | * @returns COM status code
|
---|
1417 | * @param width video mode width in pixels
|
---|
1418 | * @param height video mode height in pixels
|
---|
1419 | * @param bpp video mode bit depth in bits per pixel
|
---|
1420 | * @retval supported pointer to result variable
|
---|
1421 | *
|
---|
1422 | * Basically, we support anything with 32bpp.
|
---|
1423 | */
|
---|
1424 | STDMETHODIMP VBoxSDLFBOverlay::VideoModeSupported(ULONG width, ULONG height, ULONG bpp,
|
---|
1425 | BOOL *supported)
|
---|
1426 | {
|
---|
1427 | if (!supported)
|
---|
1428 | return E_POINTER;
|
---|
1429 | if (bpp == 32)
|
---|
1430 | *supported = true;
|
---|
1431 | else
|
---|
1432 | *supported = false;
|
---|
1433 | return S_OK;
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | /**
|
---|
1437 | * Fill an area of the framebuffer with solid colour
|
---|
1438 | *
|
---|
1439 | * @returns COM status code
|
---|
1440 | * @param x X co-ordinate of the area to fill, top-left corner
|
---|
1441 | * @param y Y co-ordinate of the area to fill, top-left corner
|
---|
1442 | * @param width width of the area to fill
|
---|
1443 | * @param height height of the area to fill
|
---|
1444 | * @param color colour with which to fill the area
|
---|
1445 | * @retval handled whether we support this operation or not
|
---|
1446 | *
|
---|
1447 | * Since we currently do not have any way of doing this faster than
|
---|
1448 | * the VGA device, we simply false in handled.
|
---|
1449 | */
|
---|
1450 | STDMETHODIMP VBoxSDLFBOverlay::SolidFill(ULONG x, ULONG y, ULONG width,
|
---|
1451 | ULONG height, ULONG color, BOOL *handled)
|
---|
1452 | {
|
---|
1453 | LogFlow(("VBoxSDLFBOverlay::SolidFill called\n"));
|
---|
1454 | if (!handled)
|
---|
1455 | return E_POINTER;
|
---|
1456 | *handled = false;
|
---|
1457 | return S_OK;
|
---|
1458 | }
|
---|
1459 |
|
---|
1460 | /**
|
---|
1461 | * Since we currently do not have any way of doing this faster than
|
---|
1462 | * the VGA device, we simply false in handled.
|
---|
1463 | */
|
---|
1464 | STDMETHODIMP VBoxSDLFBOverlay::CopyScreenBits(ULONG xDst, ULONG yDst, ULONG xSrc,
|
---|
1465 | ULONG ySrc, ULONG width,
|
---|
1466 | ULONG height, BOOL *handled)
|
---|
1467 | {
|
---|
1468 | LogFlow(("VBoxSDLFBOverlay::CopyScreenBits called.\n"));
|
---|
1469 | if (!handled)
|
---|
1470 | return E_POINTER;
|
---|
1471 | *handled = false;
|
---|
1472 | return S_OK;
|
---|
1473 | }
|
---|
1474 |
|
---|