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 |
|
---|
573 | //
|
---|
574 | // Internal public methods
|
---|
575 | //
|
---|
576 |
|
---|
577 | /**
|
---|
578 | * Method that does the actual resize of the guest framebuffer and
|
---|
579 | * then changes the SDL framebuffer setup.
|
---|
580 | */
|
---|
581 | void VBoxSDLFB::resizeGuest()
|
---|
582 | {
|
---|
583 | LogFlow(("VBoxSDL::resizeGuest() mGuestXRes: %d, mGuestYRes: %d\n", mGuestXRes, mGuestYRes));
|
---|
584 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
585 |
|
---|
586 | int cBitsPerPixel = 32;
|
---|
587 | uint32_t Rmask, Gmask, Bmask, Amask = 0;
|
---|
588 |
|
---|
589 | /* pixel characteristics, default to fallback 32bpp format */
|
---|
590 | if (mPixelFormat == FramebufferPixelFormat_PixelFormatRGB16)
|
---|
591 | cBitsPerPixel = 16;
|
---|
592 | else if (mPixelFormat == FramebufferPixelFormat_PixelFormatRGB24)
|
---|
593 | cBitsPerPixel = 24;
|
---|
594 |
|
---|
595 | switch (cBitsPerPixel)
|
---|
596 | {
|
---|
597 | case 16: Rmask = 0x0000F800; Gmask = 0x000007E0; Bmask = 0x0000001F; break;
|
---|
598 | default: Rmask = 0x00FF0000; Gmask = 0x0000FF00; Bmask = 0x000000FF; break;
|
---|
599 | }
|
---|
600 |
|
---|
601 | /* first free the current surface */
|
---|
602 | if (mSurfVRAM)
|
---|
603 | {
|
---|
604 | SDL_FreeSurface(mSurfVRAM);
|
---|
605 | mSurfVRAM = NULL;
|
---|
606 | }
|
---|
607 |
|
---|
608 | /* is the guest in a linear framebuffer mode we support? */
|
---|
609 | if (mPixelFormat != FramebufferPixelFormat_PixelFormatDefault)
|
---|
610 | {
|
---|
611 | /* Create a source surface from guest VRAM. */
|
---|
612 | mSurfVRAM = SDL_CreateRGBSurfaceFrom(mPtrVRAM, mGuestXRes, mGuestYRes, cBitsPerPixel,
|
---|
613 | mLineSize, Rmask, Gmask, Bmask, Amask);
|
---|
614 | }
|
---|
615 | else
|
---|
616 | {
|
---|
617 | /* Create a software surface for which SDL allocates the RAM */
|
---|
618 | mSurfVRAM = SDL_CreateRGBSurface(SDL_SWSURFACE, mGuestXRes, mGuestYRes, cBitsPerPixel,
|
---|
619 | Rmask, Gmask, Bmask, Amask);
|
---|
620 | }
|
---|
621 | LogFlow(("VBoxSDL:: created VRAM surface %p\n", mSurfVRAM));
|
---|
622 |
|
---|
623 | /* now adjust the SDL resolution */
|
---|
624 | resizeSDL();
|
---|
625 | }
|
---|
626 |
|
---|
627 | /**
|
---|
628 | * Sets SDL video mode. This is independent from guest video
|
---|
629 | * mode changes.
|
---|
630 | *
|
---|
631 | * @remarks Must be called from the SDL thread!
|
---|
632 | */
|
---|
633 | void VBoxSDLFB::resizeSDL(void)
|
---|
634 | {
|
---|
635 | LogFlow(("VBoxSDL:resizeSDL\n"));
|
---|
636 |
|
---|
637 | /*
|
---|
638 | * We request a hardware surface from SDL so that we can perform
|
---|
639 | * accelerated system memory to VRAM blits. The way video handling
|
---|
640 | * works it that on the one hand we have the screen surface from SDL
|
---|
641 | * and on the other hand we have a software surface that we create
|
---|
642 | * using guest VRAM memory for linear modes and using SDL allocated
|
---|
643 | * system memory for text and non linear graphics modes. We never
|
---|
644 | * directly write to the screen surface but always use SDL blitting
|
---|
645 | * functions to blit from our system memory surface to the VRAM.
|
---|
646 | * Therefore, SDL can take advantage of hardware acceleration.
|
---|
647 | */
|
---|
648 | int sdlFlags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
|
---|
649 | if (mfResizable)
|
---|
650 | sdlFlags |= SDL_RESIZABLE;
|
---|
651 | if (mfFullscreen)
|
---|
652 | sdlFlags |= SDL_FULLSCREEN;
|
---|
653 |
|
---|
654 | /*
|
---|
655 | * Now we have to check whether there are video mode restrictions
|
---|
656 | */
|
---|
657 | SDL_Rect **modes;
|
---|
658 | /* Get available fullscreen/hardware modes */
|
---|
659 | modes = SDL_ListModes(NULL, sdlFlags);
|
---|
660 | Assert(modes != NULL);
|
---|
661 | /* -1 means that any mode is possible (usually non fullscreen) */
|
---|
662 | if (modes != (SDL_Rect **)-1)
|
---|
663 | {
|
---|
664 | /*
|
---|
665 | * according to the SDL documentation, the API guarantees that
|
---|
666 | * the modes are sorted from larger to smaller, so we just
|
---|
667 | * take the first entry as the maximum.
|
---|
668 | */
|
---|
669 | mMaxScreenWidth = modes[0]->w;
|
---|
670 | mMaxScreenHeight = modes[0]->h;
|
---|
671 | }
|
---|
672 | else
|
---|
673 | {
|
---|
674 | /* no restriction */
|
---|
675 | mMaxScreenWidth = ~(uint32_t)0;
|
---|
676 | mMaxScreenHeight = ~(uint32_t)0;
|
---|
677 | }
|
---|
678 |
|
---|
679 | uint32_t newWidth;
|
---|
680 | uint32_t newHeight;
|
---|
681 |
|
---|
682 | /* reset the centering offsets */
|
---|
683 | mCenterXOffset = 0;
|
---|
684 | mCenterYOffset = 0;
|
---|
685 |
|
---|
686 | /* we either have a fixed SDL resolution or we take the guest's */
|
---|
687 | if (mFixedSDLWidth != ~(uint32_t)0)
|
---|
688 | {
|
---|
689 | newWidth = mFixedSDLWidth;
|
---|
690 | newHeight = mFixedSDLHeight;
|
---|
691 | }
|
---|
692 | else
|
---|
693 | {
|
---|
694 | newWidth = RT_MIN(mGuestXRes, mMaxScreenWidth);
|
---|
695 | #ifdef VBOX_SECURELABEL
|
---|
696 | newHeight = RT_MIN(mGuestYRes + mLabelHeight, mMaxScreenHeight);
|
---|
697 | #else
|
---|
698 | newHeight = RT_MIN(mGuestYRes, mMaxScreenHeight);
|
---|
699 | #endif
|
---|
700 | }
|
---|
701 |
|
---|
702 | /* we don't have any extra space by default */
|
---|
703 | mTopOffset = 0;
|
---|
704 |
|
---|
705 | /*
|
---|
706 | * Now set the screen resolution and get the surface pointer
|
---|
707 | * @todo BPP is not supported!
|
---|
708 | */
|
---|
709 | mScreen = SDL_SetVideoMode(newWidth, newHeight, 0, sdlFlags);
|
---|
710 | #ifdef VBOX_SECURELABEL
|
---|
711 | /*
|
---|
712 | * For non fixed SDL resolution, the above call tried to add the label height
|
---|
713 | * to the guest height. If it worked, we have an offset. If it didn't the below
|
---|
714 | * code will try again with the original guest resolution.
|
---|
715 | */
|
---|
716 | if (mFixedSDLWidth == ~(uint32_t)0)
|
---|
717 | {
|
---|
718 | /* if it didn't work, then we have to go for the original resolution and paint over the guest */
|
---|
719 | if (!mScreen)
|
---|
720 | {
|
---|
721 | mScreen = SDL_SetVideoMode(newWidth, newHeight - mLabelHeight, 0, sdlFlags);
|
---|
722 | }
|
---|
723 | else
|
---|
724 | {
|
---|
725 | /* we now have some extra space */
|
---|
726 | mTopOffset = mLabelHeight;
|
---|
727 | }
|
---|
728 | }
|
---|
729 | else
|
---|
730 | {
|
---|
731 | /* in case the guest resolution is small enough, we do have a top offset */
|
---|
732 | if (mFixedSDLHeight - mGuestYRes >= mLabelHeight)
|
---|
733 | mTopOffset = mLabelHeight;
|
---|
734 |
|
---|
735 | /* we also might have to center the guest picture */
|
---|
736 | if (mFixedSDLWidth > mGuestXRes)
|
---|
737 | mCenterXOffset = (mFixedSDLWidth - mGuestXRes) / 2;
|
---|
738 | if (mFixedSDLHeight > mGuestYRes + mLabelHeight)
|
---|
739 | mCenterYOffset = (mFixedSDLHeight - (mGuestYRes + mLabelHeight)) / 2;
|
---|
740 | }
|
---|
741 | #endif
|
---|
742 | AssertMsg(mScreen, ("Error: SDL_SetVideoMode failed!\n"));
|
---|
743 | if (mScreen)
|
---|
744 | {
|
---|
745 | #ifdef VBOX_WIN32_UI
|
---|
746 | /* inform the UI code */
|
---|
747 | resizeUI(mScreen->w, mScreen->h);
|
---|
748 | #endif
|
---|
749 | if (mfShowSDLConfig)
|
---|
750 | RTPrintf("Resized to %dx%d, screen surface type: %s\n", mScreen->w, mScreen->h,
|
---|
751 | ((mScreen->flags & SDL_HWSURFACE) == 0) ? "software" : "hardware");
|
---|
752 | }
|
---|
753 | repaint();
|
---|
754 | }
|
---|
755 |
|
---|
756 | /**
|
---|
757 | * Update specified framebuffer area. The coordinates can either be
|
---|
758 | * relative to the guest framebuffer or relative to the screen.
|
---|
759 | *
|
---|
760 | * @remarks Must be called from the SDL thread on Linux!
|
---|
761 | * @param x left column
|
---|
762 | * @param y top row
|
---|
763 | * @param w width in pixels
|
---|
764 | * @param h height in pixels
|
---|
765 | * @param fGuestRelative flag whether the above values are guest relative or screen relative;
|
---|
766 | */
|
---|
767 | void VBoxSDLFB::update(int x, int y, int w, int h, bool fGuestRelative)
|
---|
768 | {
|
---|
769 | #ifdef __LINUX__
|
---|
770 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
771 | #endif
|
---|
772 | Assert(mScreen);
|
---|
773 | Assert(mSurfVRAM);
|
---|
774 | if (!mScreen || !mSurfVRAM)
|
---|
775 | return;
|
---|
776 |
|
---|
777 | /* the source and destination rectangles */
|
---|
778 | SDL_Rect srcRect;
|
---|
779 | SDL_Rect dstRect;
|
---|
780 |
|
---|
781 | /* this is how many pixels we have to cut off from the height for this specific blit */
|
---|
782 | int yCutoffGuest = 0;
|
---|
783 |
|
---|
784 | #ifdef VBOX_SECURELABEL
|
---|
785 | bool fPaintLabel = false;
|
---|
786 | /* if we have a label and no space for it, we have to cut off a bit */
|
---|
787 | if (mLabelHeight && !mTopOffset)
|
---|
788 | {
|
---|
789 | if (y < (int)mLabelHeight)
|
---|
790 | yCutoffGuest = mLabelHeight - y;
|
---|
791 | }
|
---|
792 | #endif
|
---|
793 |
|
---|
794 | /**
|
---|
795 | * If we get a SDL window relative update, we
|
---|
796 | * just perform a full screen update to keep things simple.
|
---|
797 | *
|
---|
798 | * @todo improve
|
---|
799 | */
|
---|
800 | if (!fGuestRelative)
|
---|
801 | {
|
---|
802 | #ifdef VBOX_SECURELABEL
|
---|
803 | /* repaint the label if necessary */
|
---|
804 | if (y < (int)mLabelHeight)
|
---|
805 | fPaintLabel = true;
|
---|
806 | #endif
|
---|
807 | x = 0;
|
---|
808 | w = mGuestXRes;
|
---|
809 | y = 0;
|
---|
810 | h = mGuestYRes;
|
---|
811 | }
|
---|
812 |
|
---|
813 | srcRect.x = x;
|
---|
814 | srcRect.y = y + yCutoffGuest;
|
---|
815 | srcRect.w = w;
|
---|
816 | srcRect.h = RT_MAX(0, h - yCutoffGuest);
|
---|
817 |
|
---|
818 | /*
|
---|
819 | * Destination rectangle is just offset by the label height.
|
---|
820 | * There are two cases though: label height is added to the
|
---|
821 | * guest resolution (mTopOffset == mLabelHeight; yCutoffGuest == 0)
|
---|
822 | * or the label cuts off a portion of the guest screen (mTopOffset == 0;
|
---|
823 | * yCutoffGuest >= 0)
|
---|
824 | */
|
---|
825 | dstRect.x = x + mCenterXOffset;
|
---|
826 | #ifdef VBOX_SECURELABEL
|
---|
827 | dstRect.y = RT_MAX(mLabelHeight, y + yCutoffGuest + mTopOffset) + mCenterYOffset;
|
---|
828 | #else
|
---|
829 | dstRect.y = y + yCutoffGuest + mTopOffset + mCenterYOffset;
|
---|
830 | #endif
|
---|
831 | dstRect.w = w;
|
---|
832 | dstRect.h = RT_MAX(0, h - yCutoffGuest);
|
---|
833 |
|
---|
834 | //RTPrintf("y = %d h = %d mapped to srcY %d srcH %d mapped to dstY = %d dstH %d (guestrel: %d, mLabelHeight: %d, mTopOffset: %d)\n",
|
---|
835 | // y, h, srcRect.y, srcRect.h, dstRect.y, dstRect.h, fGuestRelative, mLabelHeight, mTopOffset);
|
---|
836 |
|
---|
837 | /*
|
---|
838 | * Now we just blit
|
---|
839 | */
|
---|
840 | SDL_BlitSurface(mSurfVRAM, &srcRect, mScreen, &dstRect);
|
---|
841 | /* hardware surfaces don't need update notifications */
|
---|
842 | if ((mScreen->flags & SDL_HWSURFACE) == 0)
|
---|
843 | SDL_UpdateRect(mScreen, dstRect.x, dstRect.y, dstRect.w, dstRect.h);
|
---|
844 |
|
---|
845 | #ifdef VBOX_SECURELABEL
|
---|
846 | if (fPaintLabel)
|
---|
847 | paintSecureLabel(0, 0, 0, 0, false);
|
---|
848 | #endif
|
---|
849 | }
|
---|
850 |
|
---|
851 | /**
|
---|
852 | * Repaint the whole framebuffer
|
---|
853 | *
|
---|
854 | * @remarks Must be called from the SDL thread!
|
---|
855 | */
|
---|
856 | void VBoxSDLFB::repaint()
|
---|
857 | {
|
---|
858 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
859 | LogFlow(("VBoxSDLFB::repaint\n"));
|
---|
860 | update(0, 0, mScreen->w, mScreen->h, false /* fGuestRelative */);
|
---|
861 | }
|
---|
862 |
|
---|
863 | bool VBoxSDLFB::getFullscreen()
|
---|
864 | {
|
---|
865 | LogFlow(("VBoxSDLFB::getFullscreen\n"));
|
---|
866 | return mfFullscreen;
|
---|
867 | }
|
---|
868 |
|
---|
869 | /**
|
---|
870 | * Toggle fullscreen mode
|
---|
871 | *
|
---|
872 | * @remarks Must be called from the SDL thread!
|
---|
873 | */
|
---|
874 | void VBoxSDLFB::setFullscreen(bool fFullscreen)
|
---|
875 | {
|
---|
876 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
877 | LogFlow(("VBoxSDLFB::SetFullscreen: fullscreen: %d\n", fFullscreen));
|
---|
878 | mfFullscreen = fFullscreen;
|
---|
879 | /* only change the SDL resolution, do not touch the guest framebuffer */
|
---|
880 | resizeSDL();
|
---|
881 | }
|
---|
882 |
|
---|
883 |
|
---|
884 | /**
|
---|
885 | * Returns the current x offset of the start of the guest screen
|
---|
886 | *
|
---|
887 | * @returns current x offset in pixels
|
---|
888 | */
|
---|
889 | int VBoxSDLFB::getXOffset()
|
---|
890 | {
|
---|
891 | /* there can only be an offset for centering */
|
---|
892 | return mCenterXOffset;
|
---|
893 | }
|
---|
894 |
|
---|
895 | /**
|
---|
896 | * Returns the current y offset of the start of the guest screen
|
---|
897 | *
|
---|
898 | * @returns current y offset in pixels
|
---|
899 | */
|
---|
900 | int VBoxSDLFB::getYOffset()
|
---|
901 | {
|
---|
902 | /* we might have a top offset and a center offset */
|
---|
903 | return mTopOffset + mCenterYOffset;
|
---|
904 | }
|
---|
905 |
|
---|
906 | #ifdef VBOX_SECURELABEL
|
---|
907 | /**
|
---|
908 | * Setup the secure labeling parameters
|
---|
909 | *
|
---|
910 | * @returns VBox status code
|
---|
911 | * @param height height of the secure label area in pixels
|
---|
912 | * @param font file path fo the TrueType font file
|
---|
913 | * @param pointsize font size in points
|
---|
914 | */
|
---|
915 | int VBoxSDLFB::initSecureLabel(uint32_t height, char *font, uint32_t pointsize)
|
---|
916 | {
|
---|
917 | LogFlow(("VBoxSDLFB:initSecureLabel: new offset: %d pixels, new font: %s, new pointsize: %d\n",
|
---|
918 | height, font, pointsize));
|
---|
919 | mLabelHeight = height;
|
---|
920 | Assert(font);
|
---|
921 | pTTF_Init();
|
---|
922 | mLabelFont = pTTF_OpenFont(font, pointsize);
|
---|
923 | if (!mLabelFont)
|
---|
924 | {
|
---|
925 | AssertMsgFailed(("Failed to open TTF font file %s\n", font));
|
---|
926 | return VERR_OPEN_FAILED;
|
---|
927 | }
|
---|
928 | mSecureLabelColorFG = 0x0000FF00;
|
---|
929 | mSecureLabelColorBG = 0x00FFFF00;
|
---|
930 | repaint();
|
---|
931 | return VINF_SUCCESS;
|
---|
932 | }
|
---|
933 |
|
---|
934 | /**
|
---|
935 | * Set the secure label text and repaint the label
|
---|
936 | *
|
---|
937 | * @param text UTF-8 string of new label
|
---|
938 | * @remarks must be called from the SDL thread!
|
---|
939 | */
|
---|
940 | void VBoxSDLFB::setSecureLabelText(const char *text)
|
---|
941 | {
|
---|
942 | mSecureLabelText = text;
|
---|
943 | paintSecureLabel(0, 0, 0, 0, true);
|
---|
944 | }
|
---|
945 |
|
---|
946 | /**
|
---|
947 | * Sets the secure label background color.
|
---|
948 | *
|
---|
949 | * @param colorFG encoded RGB value for text
|
---|
950 | * @param colorBG encored RGB value for background
|
---|
951 | * @remarks must be called from the SDL thread!
|
---|
952 | */
|
---|
953 | void VBoxSDLFB::setSecureLabelColor(uint32_t colorFG, uint32_t colorBG)
|
---|
954 | {
|
---|
955 | mSecureLabelColorFG = colorFG;
|
---|
956 | mSecureLabelColorBG = colorBG;
|
---|
957 | paintSecureLabel(0, 0, 0, 0, true);
|
---|
958 | }
|
---|
959 |
|
---|
960 | /**
|
---|
961 | * Paint the secure label if required
|
---|
962 | *
|
---|
963 | * @param fForce Force the repaint
|
---|
964 | * @remarks must be called from the SDL thread!
|
---|
965 | */
|
---|
966 | void VBoxSDLFB::paintSecureLabel(int x, int y, int w, int h, bool fForce)
|
---|
967 | {
|
---|
968 | #ifdef __LINUX__
|
---|
969 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
970 | #endif
|
---|
971 | /* only when the function is present */
|
---|
972 | if (!pTTF_RenderUTF8_Solid)
|
---|
973 | return;
|
---|
974 | /* check if we can skip the paint */
|
---|
975 | if (!fForce && ((uint32_t)y > mLabelHeight))
|
---|
976 | {
|
---|
977 | return;
|
---|
978 | }
|
---|
979 | /* first fill the background */
|
---|
980 | SDL_Rect rect = {0, 0, (Uint16)mScreen->w, (Uint16)mLabelHeight};
|
---|
981 | SDL_FillRect(mScreen, &rect, SDL_MapRGB(mScreen->format,
|
---|
982 | (mSecureLabelColorBG & 0x00FF0000) >> 16, /* red */
|
---|
983 | (mSecureLabelColorBG & 0x0000FF00) >> 8, /* green */
|
---|
984 | mSecureLabelColorBG & 0x000000FF)); /* blue */
|
---|
985 |
|
---|
986 | /* now the text */
|
---|
987 | if (mLabelFont != NULL && mSecureLabelText)
|
---|
988 | {
|
---|
989 | SDL_Color clrFg = {(mSecureLabelColorFG & 0x00FF0000) >> 16,
|
---|
990 | (mSecureLabelColorFG & 0x0000FF00) >> 8,
|
---|
991 | mSecureLabelColorFG & 0x000000FF, 0};
|
---|
992 | SDL_Surface *sText = pTTF_RenderUTF8_Solid(mLabelFont, mSecureLabelText.raw(), clrFg);
|
---|
993 | rect.x = 10;
|
---|
994 | SDL_BlitSurface(sText, NULL, mScreen, &rect);
|
---|
995 | SDL_FreeSurface(sText);
|
---|
996 | }
|
---|
997 | /* make sure to update the screen */
|
---|
998 | SDL_UpdateRect(mScreen, 0, 0, mScreen->w, mLabelHeight);
|
---|
999 | }
|
---|
1000 | #endif /* VBOX_SECURELABEL */
|
---|
1001 |
|
---|
1002 | /**
|
---|
1003 | * Terminate SDL
|
---|
1004 | *
|
---|
1005 | * @remarks must be called from the SDL thread!
|
---|
1006 | */
|
---|
1007 | void VBoxSDLFB::uninit()
|
---|
1008 | {
|
---|
1009 | AssertMsg(mSdlNativeThread == RTThreadNativeSelf(), ("Wrong thread! SDL is not threadsafe!\n"));
|
---|
1010 | if (mSurfVRAM)
|
---|
1011 | {
|
---|
1012 | SDL_FreeSurface(mSurfVRAM);
|
---|
1013 | mSurfVRAM = NULL;
|
---|
1014 | }
|
---|
1015 | SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
---|
1016 | #ifdef VBOX_SECURELABEL
|
---|
1017 | if (mLabelFont)
|
---|
1018 | pTTF_CloseFont(mLabelFont);
|
---|
1019 | if (pTTF_Quit)
|
---|
1020 | pTTF_Quit();
|
---|
1021 | #endif
|
---|
1022 | mScreen = NULL;
|
---|
1023 | if (mWMIcon)
|
---|
1024 | {
|
---|
1025 | SDL_FreeSurface(mWMIcon);
|
---|
1026 | mWMIcon = NULL;
|
---|
1027 | }
|
---|
1028 | }
|
---|
1029 |
|
---|
1030 | // IFramebufferOverlay
|
---|
1031 | ///////////////////////////////////////////////////////////////////////////////////
|
---|
1032 |
|
---|
1033 | /**
|
---|
1034 | * Constructor for the VBoxSDLFBOverlay class (IFramebufferOverlay implementation)
|
---|
1035 | *
|
---|
1036 | * @param x Initial X offset for the overlay
|
---|
1037 | * @param y Initial Y offset for the overlay
|
---|
1038 | * @param width Initial width for the overlay
|
---|
1039 | * @param height Initial height for the overlay
|
---|
1040 | * @param visible Whether the overlay is initially visible
|
---|
1041 | * @param alpha Initial alpha channel value for the overlay
|
---|
1042 | */
|
---|
1043 | VBoxSDLFBOverlay::VBoxSDLFBOverlay(ULONG x, ULONG y, ULONG width, ULONG height,
|
---|
1044 | BOOL visible, VBoxSDLFB *aParent) :
|
---|
1045 | mOverlayX(x), mOverlayY(y), mOverlayWidth(width),
|
---|
1046 | mOverlayHeight(height), mOverlayVisible(visible),
|
---|
1047 | mParent(aParent)
|
---|
1048 | {}
|
---|
1049 |
|
---|
1050 | /**
|
---|
1051 | * Destructor for the VBoxSDLFBOverlay class.
|
---|
1052 | */
|
---|
1053 | VBoxSDLFBOverlay::~VBoxSDLFBOverlay()
|
---|
1054 | {
|
---|
1055 | SDL_FreeSurface(mBlendedBits);
|
---|
1056 | SDL_FreeSurface(mOverlayBits);
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | /**
|
---|
1060 | * Perform any initialisation of the overlay that can potentially fail
|
---|
1061 | *
|
---|
1062 | * @returns S_OK on success or the reason for the failure
|
---|
1063 | */
|
---|
1064 | HRESULT VBoxSDLFBOverlay::init()
|
---|
1065 | {
|
---|
1066 | mBlendedBits = SDL_CreateRGBSurface(SDL_ANYFORMAT, mOverlayWidth, mOverlayHeight, 32,
|
---|
1067 | 0x00ff0000, 0x0000ff00, 0x000000ff, 0);
|
---|
1068 | AssertMsgReturn(mBlendedBits != NULL, ("Failed to create an SDL surface\n"),
|
---|
1069 | E_OUTOFMEMORY);
|
---|
1070 | mOverlayBits = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, mOverlayWidth,
|
---|
1071 | mOverlayHeight, 32, 0x00ff0000, 0x0000ff00,
|
---|
1072 | 0x000000ff, 0xff000000);
|
---|
1073 | AssertMsgReturn(mOverlayBits != NULL, ("Failed to create an SDL surface\n"),
|
---|
1074 | E_OUTOFMEMORY);
|
---|
1075 | return S_OK;
|
---|
1076 | }
|
---|
1077 |
|
---|
1078 | /**
|
---|
1079 | * Returns the current overlay X offset in pixels.
|
---|
1080 | *
|
---|
1081 | * @returns COM status code
|
---|
1082 | * @param x Address of result buffer.
|
---|
1083 | */
|
---|
1084 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(X)(ULONG *x)
|
---|
1085 | {
|
---|
1086 | LogFlow(("VBoxSDLFBOverlay::GetX\n"));
|
---|
1087 | if (!x)
|
---|
1088 | return E_INVALIDARG;
|
---|
1089 | *x = mOverlayX;
|
---|
1090 | return S_OK;
|
---|
1091 | }
|
---|
1092 |
|
---|
1093 | /**
|
---|
1094 | * Returns the current overlay height in pixels.
|
---|
1095 | *
|
---|
1096 | * @returns COM status code
|
---|
1097 | * @param height Address of result buffer.
|
---|
1098 | */
|
---|
1099 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Y)(ULONG *y)
|
---|
1100 | {
|
---|
1101 | LogFlow(("VBoxSDLFBOverlay::GetY\n"));
|
---|
1102 | if (!y)
|
---|
1103 | return E_INVALIDARG;
|
---|
1104 | *y = mOverlayY;
|
---|
1105 | return S_OK;
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 | /**
|
---|
1109 | * Returns the current overlay width in pixels. In fact, this returns the line size.
|
---|
1110 | *
|
---|
1111 | * @returns COM status code
|
---|
1112 | * @param width Address of result buffer.
|
---|
1113 | */
|
---|
1114 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Width)(ULONG *width)
|
---|
1115 | {
|
---|
1116 | LogFlow(("VBoxSDLFBOverlay::GetWidth\n"));
|
---|
1117 | if (!width)
|
---|
1118 | return E_INVALIDARG;
|
---|
1119 | *width = mOverlayBits->pitch;
|
---|
1120 | return S_OK;
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 | /**
|
---|
1124 | * Returns the current overlay line size in pixels.
|
---|
1125 | *
|
---|
1126 | * @returns COM status code
|
---|
1127 | * @param lineSize Address of result buffer.
|
---|
1128 | */
|
---|
1129 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(LineSize)(ULONG *lineSize)
|
---|
1130 | {
|
---|
1131 | LogFlow(("VBoxSDLFBOverlay::GetLineSize\n"));
|
---|
1132 | if (!lineSize)
|
---|
1133 | return E_INVALIDARG;
|
---|
1134 | *lineSize = mOverlayBits->pitch;
|
---|
1135 | return S_OK;
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | /**
|
---|
1139 | * Returns the current overlay height in pixels.
|
---|
1140 | *
|
---|
1141 | * @returns COM status code
|
---|
1142 | * @param height Address of result buffer.
|
---|
1143 | */
|
---|
1144 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Height)(ULONG *height)
|
---|
1145 | {
|
---|
1146 | LogFlow(("VBoxSDLFBOverlay::GetHeight\n"));
|
---|
1147 | if (!height)
|
---|
1148 | return E_INVALIDARG;
|
---|
1149 | *height = mOverlayHeight;
|
---|
1150 | return S_OK;
|
---|
1151 | }
|
---|
1152 |
|
---|
1153 | /**
|
---|
1154 | * Returns whether the overlay is currently visible.
|
---|
1155 | *
|
---|
1156 | * @returns COM status code
|
---|
1157 | * @param visible Address of result buffer.
|
---|
1158 | */
|
---|
1159 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Visible)(BOOL *visible)
|
---|
1160 | {
|
---|
1161 | LogFlow(("VBoxSDLFBOverlay::GetVisible\n"));
|
---|
1162 | if (!visible)
|
---|
1163 | return E_INVALIDARG;
|
---|
1164 | *visible = mOverlayVisible;
|
---|
1165 | return S_OK;
|
---|
1166 | }
|
---|
1167 |
|
---|
1168 | /**
|
---|
1169 | * Sets whether the overlay is currently visible.
|
---|
1170 | *
|
---|
1171 | * @returns COM status code
|
---|
1172 | * @param visible New value.
|
---|
1173 | */
|
---|
1174 | STDMETHODIMP VBoxSDLFBOverlay::COMSETTER(Visible)(BOOL visible)
|
---|
1175 | {
|
---|
1176 | LogFlow(("VBoxSDLFBOverlay::SetVisible\n"));
|
---|
1177 | mOverlayVisible = visible;
|
---|
1178 | return S_OK;
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | /**
|
---|
1182 | * Returns the value of the global alpha channel.
|
---|
1183 | *
|
---|
1184 | * @returns COM status code
|
---|
1185 | * @param alpha Address of result buffer.
|
---|
1186 | */
|
---|
1187 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Alpha)(ULONG *alpha)
|
---|
1188 | {
|
---|
1189 | LogFlow(("VBoxSDLFBOverlay::GetAlpha\n"));
|
---|
1190 | return E_NOTIMPL;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | /**
|
---|
1194 | * Sets whether the overlay is currently visible.
|
---|
1195 | *
|
---|
1196 | * @returns COM status code
|
---|
1197 | * @param alpha new value.
|
---|
1198 | */
|
---|
1199 | STDMETHODIMP VBoxSDLFBOverlay::COMSETTER(Alpha)(ULONG alpha)
|
---|
1200 | {
|
---|
1201 | LogFlow(("VBoxSDLFBOverlay::SetAlpha\n"));
|
---|
1202 | return E_NOTIMPL;
|
---|
1203 | }
|
---|
1204 |
|
---|
1205 | /**
|
---|
1206 | * Returns the address of the framebuffer bits for writing to.
|
---|
1207 | *
|
---|
1208 | * @returns COM status code
|
---|
1209 | * @param alpha Address of result buffer.
|
---|
1210 | */
|
---|
1211 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Address)(ULONG *address)
|
---|
1212 | {
|
---|
1213 | LogFlow(("VBoxSDLFBOverlay::GetAddress\n"));
|
---|
1214 | if (!address)
|
---|
1215 | return E_INVALIDARG;
|
---|
1216 | *address = (uintptr_t) mOverlayBits->pixels;
|
---|
1217 | return S_OK;
|
---|
1218 | }
|
---|
1219 |
|
---|
1220 | /**
|
---|
1221 | * Returns the current colour depth. In fact, this is always 32bpp.
|
---|
1222 | *
|
---|
1223 | * @returns COM status code
|
---|
1224 | * @param colorDepth Address of result buffer.
|
---|
1225 | */
|
---|
1226 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(ColorDepth)(ULONG *colorDepth)
|
---|
1227 | {
|
---|
1228 | LogFlow(("VBoxSDLFBOverlay::GetColorDepth\n"));
|
---|
1229 | if (!colorDepth)
|
---|
1230 | return E_INVALIDARG;
|
---|
1231 | *colorDepth = 32;
|
---|
1232 | return S_OK;
|
---|
1233 | }
|
---|
1234 |
|
---|
1235 | /**
|
---|
1236 | * Returns the current pixel format. In fact, this is always RGB32.
|
---|
1237 | *
|
---|
1238 | * @returns COM status code
|
---|
1239 | * @param pixelFormat Address of result buffer.
|
---|
1240 | */
|
---|
1241 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(PixelFormat)(FramebufferPixelFormat_T *pixelFormat)
|
---|
1242 | {
|
---|
1243 | LogFlow(("VBoxSDLFBOverlay::GetPixelFormat\n"));
|
---|
1244 | if (!pixelFormat)
|
---|
1245 | return E_INVALIDARG;
|
---|
1246 | *pixelFormat = FramebufferPixelFormat_PixelFormatRGB32;
|
---|
1247 | return S_OK;
|
---|
1248 | }
|
---|
1249 |
|
---|
1250 | /**
|
---|
1251 | * Returns the height reduction. In fact, this is always 0.
|
---|
1252 | *
|
---|
1253 | * @returns COM status code
|
---|
1254 | * @param heightReduction Address of result buffer.
|
---|
1255 | */
|
---|
1256 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(HeightReduction)(ULONG *heightReduction)
|
---|
1257 | {
|
---|
1258 | LogFlow(("VBoxSDLFBOverlay::GetHeightReduction\n"));
|
---|
1259 | if (!heightReduction)
|
---|
1260 | return E_INVALIDARG;
|
---|
1261 | *heightReduction = 0;
|
---|
1262 | return S_OK;
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | /**
|
---|
1266 | * Returns the overlay for this framebuffer. Obviously, we return NULL here.
|
---|
1267 | *
|
---|
1268 | * @returns COM status code
|
---|
1269 | * @param overlay Address of result buffer.
|
---|
1270 | */
|
---|
1271 | STDMETHODIMP VBoxSDLFBOverlay::COMGETTER(Overlay)(IFramebufferOverlay **aOverlay)
|
---|
1272 | {
|
---|
1273 | LogFlow(("VBoxSDLFBOverlay::GetOverlay\n"));
|
---|
1274 | if (!aOverlay)
|
---|
1275 | return E_INVALIDARG;
|
---|
1276 | *aOverlay = 0;
|
---|
1277 | return S_OK;
|
---|
1278 | }
|
---|
1279 |
|
---|
1280 | /**
|
---|
1281 | * Lock the overlay. This should not be used - lock the parent IFramebuffer instead.
|
---|
1282 | *
|
---|
1283 | * @returns COM status code
|
---|
1284 | */
|
---|
1285 | STDMETHODIMP VBoxSDLFBOverlay::Lock()
|
---|
1286 | {
|
---|
1287 | LogFlow(("VBoxSDLFBOverlay::Lock\n"));
|
---|
1288 | AssertMsgFailed(("You should not attempt to lock an IFramebufferOverlay object -\n"
|
---|
1289 | "lock the parent IFramebuffer object instead.\n"));
|
---|
1290 | return E_NOTIMPL;
|
---|
1291 | }
|
---|
1292 |
|
---|
1293 | /**
|
---|
1294 | * Unlock the overlay.
|
---|
1295 | *
|
---|
1296 | * @returns COM status code
|
---|
1297 | */
|
---|
1298 | STDMETHODIMP VBoxSDLFBOverlay::Unlock()
|
---|
1299 | {
|
---|
1300 | LogFlow(("VBoxSDLFBOverlay::Unlock\n"));
|
---|
1301 | AssertMsgFailed(("You should not attempt to lock an IFramebufferOverlay object -\n"
|
---|
1302 | "lock the parent IFramebuffer object instead.\n"));
|
---|
1303 | return E_NOTIMPL;
|
---|
1304 | }
|
---|
1305 |
|
---|
1306 | /**
|
---|
1307 | * Change the X and Y co-ordinates of the overlay area.
|
---|
1308 | *
|
---|
1309 | * @returns COM status code
|
---|
1310 | * @param x New X co-ordinate.
|
---|
1311 | * @param y New Y co-ordinate.
|
---|
1312 | */
|
---|
1313 | STDMETHODIMP VBoxSDLFBOverlay::Move(ULONG x, ULONG y)
|
---|
1314 | {
|
---|
1315 | mOverlayX = x;
|
---|
1316 | mOverlayY = y;
|
---|
1317 | return S_OK;
|
---|
1318 | }
|
---|
1319 |
|
---|
1320 | /**
|
---|
1321 | * Notify the overlay that a section of the framebuffer has been redrawn.
|
---|
1322 | *
|
---|
1323 | * @returns COM status code
|
---|
1324 | * @param x X co-ordinate of upper left corner of modified area.
|
---|
1325 | * @param y Y co-ordinate of upper left corner of modified area.
|
---|
1326 | * @param w Width of modified area.
|
---|
1327 | * @param h Height of modified area.
|
---|
1328 | * @retval finished Set if the operation has completed.
|
---|
1329 | *
|
---|
1330 | * All we do here is to send a request to the parent to update the affected area,
|
---|
1331 | * translating between our co-ordinate system and the parent's. It would be have
|
---|
1332 | * been better to call the parent directly, but such is life. We leave bounds
|
---|
1333 | * checking to the parent.
|
---|
1334 | */
|
---|
1335 | STDMETHODIMP VBoxSDLFBOverlay::NotifyUpdate(ULONG x, ULONG y,
|
---|
1336 | ULONG w, ULONG h, BOOL *finished)
|
---|
1337 | {
|
---|
1338 | return mParent->NotifyUpdate(x + mOverlayX, y + mOverlayY, w, h, finished);
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 | /**
|
---|
1342 | * Change the dimensions of the overlay.
|
---|
1343 | *
|
---|
1344 | * @returns COM status code
|
---|
1345 | * @param pixelFormat Must be FramebufferPixelFormat_PixelFormatRGB32.
|
---|
1346 | * @param vram Must be NULL.
|
---|
1347 | * @param lineSize Ignored.
|
---|
1348 | * @param w New overlay width.
|
---|
1349 | * @param h New overlay height.
|
---|
1350 | * @retval finished Set if the operation has completed.
|
---|
1351 | */
|
---|
1352 | STDMETHODIMP VBoxSDLFBOverlay::RequestResize(ULONG aScreenId, FramebufferPixelFormat_T pixelFormat,
|
---|
1353 | ULONG vram, ULONG lineSize, ULONG w,
|
---|
1354 | ULONG h, BOOL *finished)
|
---|
1355 | {
|
---|
1356 | AssertReturn(pixelFormat == FramebufferPixelFormat_PixelFormatRGB32, E_INVALIDARG);
|
---|
1357 | AssertReturn(vram == 0, E_INVALIDARG);
|
---|
1358 | mOverlayWidth = w;
|
---|
1359 | mOverlayHeight = h;
|
---|
1360 | SDL_FreeSurface(mOverlayBits);
|
---|
1361 | mBlendedBits = SDL_CreateRGBSurface(SDL_ANYFORMAT, mOverlayWidth, mOverlayHeight, 32,
|
---|
1362 | 0x00ff0000, 0x0000ff00, 0x000000ff, 0);
|
---|
1363 | AssertMsgReturn(mBlendedBits != NULL, ("Failed to create an SDL surface\n"),
|
---|
1364 | E_OUTOFMEMORY);
|
---|
1365 | mOverlayBits = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, mOverlayWidth,
|
---|
1366 | mOverlayHeight, 32, 0x00ff0000, 0x0000ff00,
|
---|
1367 | 0x000000ff, 0xff000000);
|
---|
1368 | AssertMsgReturn(mOverlayBits != NULL, ("Failed to create an SDL surface\n"),
|
---|
1369 | E_OUTOFMEMORY);
|
---|
1370 | return S_OK;
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 | /**
|
---|
1374 | * Queries whether we support a given accelerated opperation. Since we do not currently
|
---|
1375 | * support any accelerated operations, we always return false in supported.
|
---|
1376 | *
|
---|
1377 | * @returns COM status code
|
---|
1378 | * @param operation The operation being queried
|
---|
1379 | * @retval supported Whether or not we support that operation
|
---|
1380 | */
|
---|
1381 | STDMETHODIMP VBoxSDLFBOverlay::OperationSupported(FramebufferAccelerationOperation_T
|
---|
1382 | operation, BOOL *supported)
|
---|
1383 | {
|
---|
1384 | if (!supported)
|
---|
1385 | return E_POINTER;
|
---|
1386 | /* We currently do not support any acceleration here, and will probably not in
|
---|
1387 | the forseeable future. */
|
---|
1388 | *supported = false;
|
---|
1389 | return S_OK;
|
---|
1390 | }
|
---|
1391 |
|
---|
1392 | /**
|
---|
1393 | * Returns whether we like the given video mode.
|
---|
1394 | *
|
---|
1395 | * @returns COM status code
|
---|
1396 | * @param width video mode width in pixels
|
---|
1397 | * @param height video mode height in pixels
|
---|
1398 | * @param bpp video mode bit depth in bits per pixel
|
---|
1399 | * @retval supported pointer to result variable
|
---|
1400 | *
|
---|
1401 | * Basically, we support anything with 32bpp.
|
---|
1402 | */
|
---|
1403 | STDMETHODIMP VBoxSDLFBOverlay::VideoModeSupported(ULONG width, ULONG height, ULONG bpp,
|
---|
1404 | BOOL *supported)
|
---|
1405 | {
|
---|
1406 | if (!supported)
|
---|
1407 | return E_POINTER;
|
---|
1408 | if (bpp == 32)
|
---|
1409 | *supported = true;
|
---|
1410 | else
|
---|
1411 | *supported = false;
|
---|
1412 | return S_OK;
|
---|
1413 | }
|
---|
1414 |
|
---|
1415 | /**
|
---|
1416 | * Fill an area of the framebuffer with solid colour
|
---|
1417 | *
|
---|
1418 | * @returns COM status code
|
---|
1419 | * @param x X co-ordinate of the area to fill, top-left corner
|
---|
1420 | * @param y Y co-ordinate of the area to fill, top-left corner
|
---|
1421 | * @param width width of the area to fill
|
---|
1422 | * @param height height of the area to fill
|
---|
1423 | * @param color colour with which to fill the area
|
---|
1424 | * @retval handled whether we support this operation or not
|
---|
1425 | *
|
---|
1426 | * Since we currently do not have any way of doing this faster than
|
---|
1427 | * the VGA device, we simply false in handled.
|
---|
1428 | */
|
---|
1429 | STDMETHODIMP VBoxSDLFBOverlay::SolidFill(ULONG x, ULONG y, ULONG width,
|
---|
1430 | ULONG height, ULONG color, BOOL *handled)
|
---|
1431 | {
|
---|
1432 | LogFlow(("VBoxSDLFBOverlay::SolidFill called\n"));
|
---|
1433 | if (!handled)
|
---|
1434 | return E_POINTER;
|
---|
1435 | *handled = false;
|
---|
1436 | return S_OK;
|
---|
1437 | }
|
---|
1438 |
|
---|
1439 | /**
|
---|
1440 | * Since we currently do not have any way of doing this faster than
|
---|
1441 | * the VGA device, we simply false in handled.
|
---|
1442 | */
|
---|
1443 | STDMETHODIMP VBoxSDLFBOverlay::CopyScreenBits(ULONG xDst, ULONG yDst, ULONG xSrc,
|
---|
1444 | ULONG ySrc, ULONG width,
|
---|
1445 | ULONG height, BOOL *handled)
|
---|
1446 | {
|
---|
1447 | LogFlow(("VBoxSDLFBOverlay::CopyScreenBits called.\n"));
|
---|
1448 | if (!handled)
|
---|
1449 | return E_POINTER;
|
---|
1450 | *handled = false;
|
---|
1451 | return S_OK;
|
---|
1452 | }
|
---|