1 | /* $Id: DisplayImpl.cpp 67914 2017-07-11 20:46:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #define LOG_GROUP LOG_GROUP_MAIN_DISPLAY
|
---|
19 | #include "LoggingNew.h"
|
---|
20 |
|
---|
21 | #include "DisplayImpl.h"
|
---|
22 | #include "DisplayUtils.h"
|
---|
23 | #include "ConsoleImpl.h"
|
---|
24 | #include "ConsoleVRDPServer.h"
|
---|
25 | #include "GuestImpl.h"
|
---|
26 | #include "VMMDev.h"
|
---|
27 |
|
---|
28 | #include "AutoCaller.h"
|
---|
29 |
|
---|
30 | /* generated header */
|
---|
31 | #include "VBoxEvents.h"
|
---|
32 |
|
---|
33 | #include <iprt/semaphore.h>
|
---|
34 | #include <iprt/thread.h>
|
---|
35 | #include <iprt/asm.h>
|
---|
36 | #include <iprt/time.h>
|
---|
37 | #include <iprt/cpp/utils.h>
|
---|
38 | #include <iprt/alloca.h>
|
---|
39 |
|
---|
40 | #include <VBox/vmm/pdmdrv.h>
|
---|
41 | #if defined(DEBUG) || defined(VBOX_STRICT) /* for VM_ASSERT_EMT(). */
|
---|
42 | # include <VBox/vmm/vm.h>
|
---|
43 | #endif
|
---|
44 |
|
---|
45 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
46 | # include <VBoxVideo.h>
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | #if defined(VBOX_WITH_CROGL) || defined(VBOX_WITH_CRHGSMI)
|
---|
50 | # include <VBox/HostServices/VBoxCrOpenGLSvc.h>
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #include <VBox/com/array.h>
|
---|
54 |
|
---|
55 | #ifdef VBOX_WITH_VIDEOREC
|
---|
56 | # include <iprt/path.h>
|
---|
57 | # include "VideoRec.h"
|
---|
58 | #endif
|
---|
59 |
|
---|
60 | #ifdef VBOX_WITH_CROGL
|
---|
61 | typedef enum
|
---|
62 | {
|
---|
63 | CRVREC_STATE_IDLE,
|
---|
64 | CRVREC_STATE_SUBMITTED
|
---|
65 | } CRVREC_STATE;
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Display driver instance data.
|
---|
70 | *
|
---|
71 | * @implements PDMIDISPLAYCONNECTOR
|
---|
72 | */
|
---|
73 | typedef struct DRVMAINDISPLAY
|
---|
74 | {
|
---|
75 | /** Pointer to the display object. */
|
---|
76 | Display *pDisplay;
|
---|
77 | /** Pointer to the driver instance structure. */
|
---|
78 | PPDMDRVINS pDrvIns;
|
---|
79 | /** Pointer to the keyboard port interface of the driver/device above us. */
|
---|
80 | PPDMIDISPLAYPORT pUpPort;
|
---|
81 | /** Our display connector interface. */
|
---|
82 | PDMIDISPLAYCONNECTOR IConnector;
|
---|
83 | #if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_CRHGSMI)
|
---|
84 | /** VBVA callbacks */
|
---|
85 | PPDMIDISPLAYVBVACALLBACKS pVBVACallbacks;
|
---|
86 | #endif
|
---|
87 | } DRVMAINDISPLAY, *PDRVMAINDISPLAY;
|
---|
88 |
|
---|
89 | /** Converts PDMIDISPLAYCONNECTOR pointer to a DRVMAINDISPLAY pointer. */
|
---|
90 | #define PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface) RT_FROM_MEMBER(pInterface, DRVMAINDISPLAY, IConnector)
|
---|
91 |
|
---|
92 | // constructor / destructor
|
---|
93 | /////////////////////////////////////////////////////////////////////////////
|
---|
94 |
|
---|
95 | Display::Display()
|
---|
96 | : mParent(NULL), mfIsCr3DEnabled(false)
|
---|
97 | {
|
---|
98 | }
|
---|
99 |
|
---|
100 | Display::~Display()
|
---|
101 | {
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | HRESULT Display::FinalConstruct()
|
---|
106 | {
|
---|
107 | int rc = videoAccelConstruct(&mVideoAccelLegacy);
|
---|
108 | AssertRC(rc);
|
---|
109 |
|
---|
110 | mfVideoAccelVRDP = false;
|
---|
111 | mfu32SupportedOrders = 0;
|
---|
112 | mcVideoAccelVRDPRefs = 0;
|
---|
113 |
|
---|
114 | mfSeamlessEnabled = false;
|
---|
115 | mpRectVisibleRegion = NULL;
|
---|
116 | mcRectVisibleRegion = 0;
|
---|
117 |
|
---|
118 | #ifdef VBOX_WITH_CROGL
|
---|
119 | mfCrOglDataHidden = false;
|
---|
120 | #endif
|
---|
121 |
|
---|
122 | mpDrv = NULL;
|
---|
123 | mpVMMDev = NULL;
|
---|
124 | mfVMMDevInited = false;
|
---|
125 |
|
---|
126 | rc = RTCritSectInit(&mVideoAccelLock);
|
---|
127 | AssertRC(rc);
|
---|
128 |
|
---|
129 | #ifdef VBOX_WITH_HGSMI
|
---|
130 | mu32UpdateVBVAFlags = 0;
|
---|
131 | mfVMMDevSupportsGraphics = false;
|
---|
132 | mfGuestVBVACapabilities = 0;
|
---|
133 | mfHostCursorCapabilities = 0;
|
---|
134 | #endif
|
---|
135 |
|
---|
136 | #ifdef VBOX_WITH_VIDEOREC
|
---|
137 | rc = RTCritSectInit(&mVideoCaptureLock);
|
---|
138 | AssertRC(rc);
|
---|
139 |
|
---|
140 | mpVideoRecCtx = NULL;
|
---|
141 | for (unsigned i = 0; i < RT_ELEMENTS(maVideoRecEnabled); i++)
|
---|
142 | maVideoRecEnabled[i] = true;
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | #ifdef VBOX_WITH_CRHGSMI
|
---|
146 | mhCrOglSvc = NULL;
|
---|
147 | rc = RTCritSectRwInit(&mCrOglLock);
|
---|
148 | AssertRC(rc);
|
---|
149 | #endif
|
---|
150 |
|
---|
151 | #ifdef VBOX_WITH_CROGL
|
---|
152 | RT_ZERO(mCrOglCallbacks);
|
---|
153 | RT_ZERO(mCrOglScreenshotData);
|
---|
154 | mfCrOglVideoRecState = CRVREC_STATE_IDLE;
|
---|
155 | mCrOglScreenshotData.u32Screen = CRSCREEN_ALL;
|
---|
156 | mCrOglScreenshotData.pvContext = this;
|
---|
157 | mCrOglScreenshotData.pfnScreenshotBegin = i_displayCrVRecScreenshotBegin;
|
---|
158 | mCrOglScreenshotData.pfnScreenshotPerform = i_displayCrVRecScreenshotPerform;
|
---|
159 | mCrOglScreenshotData.pfnScreenshotEnd = i_displayCrVRecScreenshotEnd;
|
---|
160 | #endif
|
---|
161 |
|
---|
162 | return BaseFinalConstruct();
|
---|
163 | }
|
---|
164 |
|
---|
165 | void Display::FinalRelease()
|
---|
166 | {
|
---|
167 | uninit();
|
---|
168 |
|
---|
169 | #ifdef VBOX_WITH_VIDEOREC
|
---|
170 | if (RTCritSectIsInitialized(&mVideoCaptureLock))
|
---|
171 | {
|
---|
172 | RTCritSectDelete(&mVideoCaptureLock);
|
---|
173 | RT_ZERO(mVideoCaptureLock);
|
---|
174 | }
|
---|
175 | #endif
|
---|
176 |
|
---|
177 | videoAccelDestroy(&mVideoAccelLegacy);
|
---|
178 | i_saveVisibleRegion(0, NULL);
|
---|
179 |
|
---|
180 | if (RTCritSectIsInitialized(&mVideoAccelLock))
|
---|
181 | {
|
---|
182 | RTCritSectDelete(&mVideoAccelLock);
|
---|
183 | RT_ZERO(mVideoAccelLock);
|
---|
184 | }
|
---|
185 |
|
---|
186 | #ifdef VBOX_WITH_CRHGSMI
|
---|
187 | if (RTCritSectRwIsInitialized(&mCrOglLock))
|
---|
188 | {
|
---|
189 | RTCritSectRwDelete(&mCrOglLock);
|
---|
190 | RT_ZERO(mCrOglLock);
|
---|
191 | }
|
---|
192 | #endif
|
---|
193 | BaseFinalRelease();
|
---|
194 | }
|
---|
195 |
|
---|
196 | // public initializer/uninitializer for internal purposes only
|
---|
197 | /////////////////////////////////////////////////////////////////////////////
|
---|
198 |
|
---|
199 | #define kMaxSizeThumbnail 64
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Save thumbnail and screenshot of the guest screen.
|
---|
203 | */
|
---|
204 | static int displayMakeThumbnail(uint8_t *pbData, uint32_t cx, uint32_t cy,
|
---|
205 | uint8_t **ppu8Thumbnail, uint32_t *pcbThumbnail, uint32_t *pcxThumbnail, uint32_t *pcyThumbnail)
|
---|
206 | {
|
---|
207 | int rc = VINF_SUCCESS;
|
---|
208 |
|
---|
209 | uint8_t *pu8Thumbnail = NULL;
|
---|
210 | uint32_t cbThumbnail = 0;
|
---|
211 | uint32_t cxThumbnail = 0;
|
---|
212 | uint32_t cyThumbnail = 0;
|
---|
213 |
|
---|
214 | if (cx > cy)
|
---|
215 | {
|
---|
216 | cxThumbnail = kMaxSizeThumbnail;
|
---|
217 | cyThumbnail = (kMaxSizeThumbnail * cy) / cx;
|
---|
218 | }
|
---|
219 | else
|
---|
220 | {
|
---|
221 | cyThumbnail = kMaxSizeThumbnail;
|
---|
222 | cxThumbnail = (kMaxSizeThumbnail * cx) / cy;
|
---|
223 | }
|
---|
224 |
|
---|
225 | LogRelFlowFunc(("%dx%d -> %dx%d\n", cx, cy, cxThumbnail, cyThumbnail));
|
---|
226 |
|
---|
227 | cbThumbnail = cxThumbnail * 4 * cyThumbnail;
|
---|
228 | pu8Thumbnail = (uint8_t *)RTMemAlloc(cbThumbnail);
|
---|
229 |
|
---|
230 | if (pu8Thumbnail)
|
---|
231 | {
|
---|
232 | uint8_t *dst = pu8Thumbnail;
|
---|
233 | uint8_t *src = pbData;
|
---|
234 | int dstW = cxThumbnail;
|
---|
235 | int dstH = cyThumbnail;
|
---|
236 | int srcW = cx;
|
---|
237 | int srcH = cy;
|
---|
238 | int iDeltaLine = cx * 4;
|
---|
239 |
|
---|
240 | BitmapScale32(dst,
|
---|
241 | dstW, dstH,
|
---|
242 | src,
|
---|
243 | iDeltaLine,
|
---|
244 | srcW, srcH);
|
---|
245 |
|
---|
246 | *ppu8Thumbnail = pu8Thumbnail;
|
---|
247 | *pcbThumbnail = cbThumbnail;
|
---|
248 | *pcxThumbnail = cxThumbnail;
|
---|
249 | *pcyThumbnail = cyThumbnail;
|
---|
250 | }
|
---|
251 | else
|
---|
252 | {
|
---|
253 | rc = VERR_NO_MEMORY;
|
---|
254 | }
|
---|
255 |
|
---|
256 | return rc;
|
---|
257 | }
|
---|
258 |
|
---|
259 | #ifdef VBOX_WITH_CROGL
|
---|
260 | typedef struct
|
---|
261 | {
|
---|
262 | CRVBOXHGCMTAKESCREENSHOT Base;
|
---|
263 |
|
---|
264 | /* 32bpp small RGB image. */
|
---|
265 | uint8_t *pu8Thumbnail;
|
---|
266 | uint32_t cbThumbnail;
|
---|
267 | uint32_t cxThumbnail;
|
---|
268 | uint32_t cyThumbnail;
|
---|
269 |
|
---|
270 | /* PNG screenshot. */
|
---|
271 | uint8_t *pu8PNG;
|
---|
272 | uint32_t cbPNG;
|
---|
273 | uint32_t cxPNG;
|
---|
274 | uint32_t cyPNG;
|
---|
275 | } VBOX_DISPLAY_SAVESCREENSHOT_DATA;
|
---|
276 |
|
---|
277 | static DECLCALLBACK(void) displaySaveScreenshotReport(void *pvCtx, uint32_t uScreen,
|
---|
278 | uint32_t x, uint32_t y, uint32_t uBitsPerPixel,
|
---|
279 | uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
|
---|
280 | uint8_t *pu8BufferAddress, uint64_t u64Timestamp)
|
---|
281 | {
|
---|
282 | RT_NOREF(uScreen, x, y, uBitsPerPixel,uBytesPerLine, u64Timestamp);
|
---|
283 | VBOX_DISPLAY_SAVESCREENSHOT_DATA *pData = (VBOX_DISPLAY_SAVESCREENSHOT_DATA*)pvCtx;
|
---|
284 | displayMakeThumbnail(pu8BufferAddress, uGuestWidth, uGuestHeight, &pData->pu8Thumbnail,
|
---|
285 | &pData->cbThumbnail, &pData->cxThumbnail, &pData->cyThumbnail);
|
---|
286 | int rc = DisplayMakePNG(pu8BufferAddress, uGuestWidth, uGuestHeight, &pData->pu8PNG,
|
---|
287 | &pData->cbPNG, &pData->cxPNG, &pData->cyPNG, 1);
|
---|
288 | if (RT_FAILURE(rc))
|
---|
289 | {
|
---|
290 | AssertMsgFailed(("DisplayMakePNG failed (rc=%Rrc)\n", rc));
|
---|
291 | if (pData->pu8PNG)
|
---|
292 | {
|
---|
293 | RTMemFree(pData->pu8PNG);
|
---|
294 | pData->pu8PNG = NULL;
|
---|
295 | }
|
---|
296 | pData->cbPNG = 0;
|
---|
297 | pData->cxPNG = 0;
|
---|
298 | pData->cyPNG = 0;
|
---|
299 | }
|
---|
300 | }
|
---|
301 | #endif
|
---|
302 |
|
---|
303 | DECLCALLBACK(void) Display::i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser)
|
---|
304 | {
|
---|
305 | Display *that = static_cast<Display*>(pvUser);
|
---|
306 |
|
---|
307 | /* 32bpp small RGB image. */
|
---|
308 | uint8_t *pu8Thumbnail = NULL;
|
---|
309 | uint32_t cbThumbnail = 0;
|
---|
310 | uint32_t cxThumbnail = 0;
|
---|
311 | uint32_t cyThumbnail = 0;
|
---|
312 |
|
---|
313 | /* PNG screenshot. */
|
---|
314 | uint8_t *pu8PNG = NULL;
|
---|
315 | uint32_t cbPNG = 0;
|
---|
316 | uint32_t cxPNG = 0;
|
---|
317 | uint32_t cyPNG = 0;
|
---|
318 |
|
---|
319 | Console::SafeVMPtr ptrVM(that->mParent);
|
---|
320 | if (ptrVM.isOk())
|
---|
321 | {
|
---|
322 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
323 | BOOL f3DSnapshot = FALSE;
|
---|
324 | if ( that->mfIsCr3DEnabled
|
---|
325 | && that->mCrOglCallbacks.pfnHasData
|
---|
326 | && that->mCrOglCallbacks.pfnHasData())
|
---|
327 | {
|
---|
328 | VMMDev *pVMMDev = that->mParent->i_getVMMDev();
|
---|
329 | if (pVMMDev)
|
---|
330 | {
|
---|
331 | VBOX_DISPLAY_SAVESCREENSHOT_DATA *pScreenshot;
|
---|
332 | pScreenshot = (VBOX_DISPLAY_SAVESCREENSHOT_DATA*)RTMemAllocZ(sizeof(*pScreenshot));
|
---|
333 | if (pScreenshot)
|
---|
334 | {
|
---|
335 | /* screen id or CRSCREEN_ALL to specify all enabled */
|
---|
336 | pScreenshot->Base.u32Screen = 0;
|
---|
337 | pScreenshot->Base.u32Width = 0;
|
---|
338 | pScreenshot->Base.u32Height = 0;
|
---|
339 | pScreenshot->Base.u32Pitch = 0;
|
---|
340 | pScreenshot->Base.pvBuffer = NULL;
|
---|
341 | pScreenshot->Base.pvContext = pScreenshot;
|
---|
342 | pScreenshot->Base.pfnScreenshotBegin = NULL;
|
---|
343 | pScreenshot->Base.pfnScreenshotPerform = displaySaveScreenshotReport;
|
---|
344 | pScreenshot->Base.pfnScreenshotEnd = NULL;
|
---|
345 |
|
---|
346 | VBOXCRCMDCTL_HGCM data;
|
---|
347 | data.Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
348 | data.Hdr.u32Function = SHCRGL_HOST_FN_TAKE_SCREENSHOT;
|
---|
349 |
|
---|
350 | data.aParms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
351 | data.aParms[0].u.pointer.addr = &pScreenshot->Base;
|
---|
352 | data.aParms[0].u.pointer.size = sizeof(pScreenshot->Base);
|
---|
353 |
|
---|
354 | int rc = that->i_crCtlSubmitSync(&data.Hdr, sizeof(data));
|
---|
355 | if (RT_SUCCESS(rc))
|
---|
356 | {
|
---|
357 | if (pScreenshot->pu8PNG)
|
---|
358 | {
|
---|
359 | pu8Thumbnail = pScreenshot->pu8Thumbnail;
|
---|
360 | cbThumbnail = pScreenshot->cbThumbnail;
|
---|
361 | cxThumbnail = pScreenshot->cxThumbnail;
|
---|
362 | cyThumbnail = pScreenshot->cyThumbnail;
|
---|
363 |
|
---|
364 | /* PNG screenshot. */
|
---|
365 | pu8PNG = pScreenshot->pu8PNG;
|
---|
366 | cbPNG = pScreenshot->cbPNG;
|
---|
367 | cxPNG = pScreenshot->cxPNG;
|
---|
368 | cyPNG = pScreenshot->cyPNG;
|
---|
369 | f3DSnapshot = TRUE;
|
---|
370 | }
|
---|
371 | else
|
---|
372 | AssertMsgFailed(("no png\n"));
|
---|
373 | }
|
---|
374 | else
|
---|
375 | AssertMsgFailed(("SHCRGL_HOST_FN_TAKE_SCREENSHOT failed (rc=%Rrc)\n", rc));
|
---|
376 |
|
---|
377 |
|
---|
378 | RTMemFree(pScreenshot);
|
---|
379 | }
|
---|
380 | }
|
---|
381 | }
|
---|
382 |
|
---|
383 | if (!f3DSnapshot)
|
---|
384 | #endif
|
---|
385 | {
|
---|
386 | /* Query RGB bitmap. */
|
---|
387 | /* SSM code is executed on EMT(0), therefore no need to use VMR3ReqCallWait. */
|
---|
388 | uint8_t *pbData = NULL;
|
---|
389 | size_t cbData = 0;
|
---|
390 | uint32_t cx = 0;
|
---|
391 | uint32_t cy = 0;
|
---|
392 | bool fFreeMem = false;
|
---|
393 | int rc = Display::i_displayTakeScreenshotEMT(that, VBOX_VIDEO_PRIMARY_SCREEN, &pbData, &cbData, &cx, &cy, &fFreeMem);
|
---|
394 |
|
---|
395 | /*
|
---|
396 | * It is possible that success is returned but everything is 0 or NULL.
|
---|
397 | * (no display attached if a VM is running with VBoxHeadless on OSE for example)
|
---|
398 | */
|
---|
399 | if (RT_SUCCESS(rc) && pbData)
|
---|
400 | {
|
---|
401 | Assert(cx && cy);
|
---|
402 |
|
---|
403 | /* Prepare a small thumbnail and a PNG screenshot. */
|
---|
404 | displayMakeThumbnail(pbData, cx, cy, &pu8Thumbnail, &cbThumbnail, &cxThumbnail, &cyThumbnail);
|
---|
405 | rc = DisplayMakePNG(pbData, cx, cy, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 1);
|
---|
406 | if (RT_FAILURE(rc))
|
---|
407 | {
|
---|
408 | if (pu8PNG)
|
---|
409 | {
|
---|
410 | RTMemFree(pu8PNG);
|
---|
411 | pu8PNG = NULL;
|
---|
412 | }
|
---|
413 | cbPNG = 0;
|
---|
414 | cxPNG = 0;
|
---|
415 | cyPNG = 0;
|
---|
416 | }
|
---|
417 |
|
---|
418 | if (fFreeMem)
|
---|
419 | RTMemFree(pbData);
|
---|
420 | else
|
---|
421 | that->mpDrv->pUpPort->pfnFreeScreenshot(that->mpDrv->pUpPort, pbData);
|
---|
422 | }
|
---|
423 | }
|
---|
424 | }
|
---|
425 | else
|
---|
426 | {
|
---|
427 | LogFunc(("Failed to get VM pointer 0x%x\n", ptrVM.rc()));
|
---|
428 | }
|
---|
429 |
|
---|
430 | /* Regardless of rc, save what is available:
|
---|
431 | * Data format:
|
---|
432 | * uint32_t cBlocks;
|
---|
433 | * [blocks]
|
---|
434 | *
|
---|
435 | * Each block is:
|
---|
436 | * uint32_t cbBlock; if 0 - no 'block data'.
|
---|
437 | * uint32_t typeOfBlock; 0 - 32bpp RGB bitmap, 1 - PNG, ignored if 'cbBlock' is 0.
|
---|
438 | * [block data]
|
---|
439 | *
|
---|
440 | * Block data for bitmap and PNG:
|
---|
441 | * uint32_t cx;
|
---|
442 | * uint32_t cy;
|
---|
443 | * [image data]
|
---|
444 | */
|
---|
445 | SSMR3PutU32(pSSM, 2); /* Write thumbnail and PNG screenshot. */
|
---|
446 |
|
---|
447 | /* First block. */
|
---|
448 | SSMR3PutU32(pSSM, (uint32_t)(cbThumbnail + 2 * sizeof(uint32_t)));
|
---|
449 | SSMR3PutU32(pSSM, 0); /* Block type: thumbnail. */
|
---|
450 |
|
---|
451 | if (cbThumbnail)
|
---|
452 | {
|
---|
453 | SSMR3PutU32(pSSM, cxThumbnail);
|
---|
454 | SSMR3PutU32(pSSM, cyThumbnail);
|
---|
455 | SSMR3PutMem(pSSM, pu8Thumbnail, cbThumbnail);
|
---|
456 | }
|
---|
457 |
|
---|
458 | /* Second block. */
|
---|
459 | SSMR3PutU32(pSSM, (uint32_t)(cbPNG + 2 * sizeof(uint32_t)));
|
---|
460 | SSMR3PutU32(pSSM, 1); /* Block type: png. */
|
---|
461 |
|
---|
462 | if (cbPNG)
|
---|
463 | {
|
---|
464 | SSMR3PutU32(pSSM, cxPNG);
|
---|
465 | SSMR3PutU32(pSSM, cyPNG);
|
---|
466 | SSMR3PutMem(pSSM, pu8PNG, cbPNG);
|
---|
467 | }
|
---|
468 |
|
---|
469 | RTMemFree(pu8PNG);
|
---|
470 | RTMemFree(pu8Thumbnail);
|
---|
471 | }
|
---|
472 |
|
---|
473 | DECLCALLBACK(int)
|
---|
474 | Display::i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
|
---|
475 | {
|
---|
476 | RT_NOREF(pvUser);
|
---|
477 | if (uVersion != sSSMDisplayScreenshotVer)
|
---|
478 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
479 | Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
480 |
|
---|
481 | /* Skip data. */
|
---|
482 | uint32_t cBlocks;
|
---|
483 | int rc = SSMR3GetU32(pSSM, &cBlocks);
|
---|
484 | AssertRCReturn(rc, rc);
|
---|
485 |
|
---|
486 | for (uint32_t i = 0; i < cBlocks; i++)
|
---|
487 | {
|
---|
488 | uint32_t cbBlock;
|
---|
489 | rc = SSMR3GetU32(pSSM, &cbBlock);
|
---|
490 | AssertRCBreak(rc);
|
---|
491 |
|
---|
492 | uint32_t typeOfBlock;
|
---|
493 | rc = SSMR3GetU32(pSSM, &typeOfBlock);
|
---|
494 | AssertRCBreak(rc);
|
---|
495 |
|
---|
496 | LogRelFlowFunc(("[%d] type %d, size %d bytes\n", i, typeOfBlock, cbBlock));
|
---|
497 |
|
---|
498 | /* Note: displaySSMSaveScreenshot writes size of a block = 8 and
|
---|
499 | * do not write any data if the image size was 0.
|
---|
500 | * @todo Fix and increase saved state version.
|
---|
501 | */
|
---|
502 | if (cbBlock > 2 * sizeof(uint32_t))
|
---|
503 | {
|
---|
504 | rc = SSMR3Skip(pSSM, cbBlock);
|
---|
505 | AssertRCBreak(rc);
|
---|
506 | }
|
---|
507 | }
|
---|
508 |
|
---|
509 | return rc;
|
---|
510 | }
|
---|
511 |
|
---|
512 | /**
|
---|
513 | * Save/Load some important guest state
|
---|
514 | */
|
---|
515 | DECLCALLBACK(void)
|
---|
516 | Display::i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser)
|
---|
517 | {
|
---|
518 | Display *that = static_cast<Display*>(pvUser);
|
---|
519 |
|
---|
520 | SSMR3PutU32(pSSM, that->mcMonitors);
|
---|
521 | for (unsigned i = 0; i < that->mcMonitors; i++)
|
---|
522 | {
|
---|
523 | SSMR3PutU32(pSSM, that->maFramebuffers[i].u32Offset);
|
---|
524 | SSMR3PutU32(pSSM, that->maFramebuffers[i].u32MaxFramebufferSize);
|
---|
525 | SSMR3PutU32(pSSM, that->maFramebuffers[i].u32InformationSize);
|
---|
526 | SSMR3PutU32(pSSM, that->maFramebuffers[i].w);
|
---|
527 | SSMR3PutU32(pSSM, that->maFramebuffers[i].h);
|
---|
528 | SSMR3PutS32(pSSM, that->maFramebuffers[i].xOrigin);
|
---|
529 | SSMR3PutS32(pSSM, that->maFramebuffers[i].yOrigin);
|
---|
530 | SSMR3PutU32(pSSM, that->maFramebuffers[i].flags);
|
---|
531 | }
|
---|
532 | SSMR3PutS32(pSSM, that->xInputMappingOrigin);
|
---|
533 | SSMR3PutS32(pSSM, that->yInputMappingOrigin);
|
---|
534 | SSMR3PutU32(pSSM, that->cxInputMapping);
|
---|
535 | SSMR3PutU32(pSSM, that->cyInputMapping);
|
---|
536 | SSMR3PutU32(pSSM, that->mfGuestVBVACapabilities);
|
---|
537 | SSMR3PutU32(pSSM, that->mfHostCursorCapabilities);
|
---|
538 | }
|
---|
539 |
|
---|
540 | DECLCALLBACK(int)
|
---|
541 | Display::i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
|
---|
542 | {
|
---|
543 | Display *that = static_cast<Display*>(pvUser);
|
---|
544 |
|
---|
545 | if ( uVersion != sSSMDisplayVer
|
---|
546 | && uVersion != sSSMDisplayVer2
|
---|
547 | && uVersion != sSSMDisplayVer3
|
---|
548 | && uVersion != sSSMDisplayVer4
|
---|
549 | && uVersion != sSSMDisplayVer5)
|
---|
550 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
551 | Assert(uPass == SSM_PASS_FINAL); NOREF(uPass);
|
---|
552 |
|
---|
553 | uint32_t cMonitors;
|
---|
554 | int rc = SSMR3GetU32(pSSM, &cMonitors);
|
---|
555 | AssertRCReturn(rc, rc);
|
---|
556 | if (cMonitors != that->mcMonitors)
|
---|
557 | return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Number of monitors changed (%d->%d)!"), cMonitors, that->mcMonitors);
|
---|
558 |
|
---|
559 | for (uint32_t i = 0; i < cMonitors; i++)
|
---|
560 | {
|
---|
561 | SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32Offset);
|
---|
562 | SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32MaxFramebufferSize);
|
---|
563 | SSMR3GetU32(pSSM, &that->maFramebuffers[i].u32InformationSize);
|
---|
564 | if ( uVersion == sSSMDisplayVer2
|
---|
565 | || uVersion == sSSMDisplayVer3
|
---|
566 | || uVersion == sSSMDisplayVer4
|
---|
567 | || uVersion == sSSMDisplayVer5)
|
---|
568 | {
|
---|
569 | uint32_t w;
|
---|
570 | uint32_t h;
|
---|
571 | SSMR3GetU32(pSSM, &w);
|
---|
572 | SSMR3GetU32(pSSM, &h);
|
---|
573 | that->maFramebuffers[i].w = w;
|
---|
574 | that->maFramebuffers[i].h = h;
|
---|
575 | }
|
---|
576 | if ( uVersion == sSSMDisplayVer3
|
---|
577 | || uVersion == sSSMDisplayVer4
|
---|
578 | || uVersion == sSSMDisplayVer5)
|
---|
579 | {
|
---|
580 | int32_t xOrigin;
|
---|
581 | int32_t yOrigin;
|
---|
582 | uint32_t flags;
|
---|
583 | SSMR3GetS32(pSSM, &xOrigin);
|
---|
584 | SSMR3GetS32(pSSM, &yOrigin);
|
---|
585 | SSMR3GetU32(pSSM, &flags);
|
---|
586 | that->maFramebuffers[i].xOrigin = xOrigin;
|
---|
587 | that->maFramebuffers[i].yOrigin = yOrigin;
|
---|
588 | that->maFramebuffers[i].flags = (uint16_t)flags;
|
---|
589 | that->maFramebuffers[i].fDisabled = (that->maFramebuffers[i].flags & VBVA_SCREEN_F_DISABLED) != 0;
|
---|
590 | }
|
---|
591 | }
|
---|
592 | if ( uVersion == sSSMDisplayVer4
|
---|
593 | || uVersion == sSSMDisplayVer5)
|
---|
594 | {
|
---|
595 | SSMR3GetS32(pSSM, &that->xInputMappingOrigin);
|
---|
596 | SSMR3GetS32(pSSM, &that->yInputMappingOrigin);
|
---|
597 | SSMR3GetU32(pSSM, &that->cxInputMapping);
|
---|
598 | SSMR3GetU32(pSSM, &that->cyInputMapping);
|
---|
599 | }
|
---|
600 | if (uVersion == sSSMDisplayVer5)
|
---|
601 | {
|
---|
602 | SSMR3GetU32(pSSM, &that->mfGuestVBVACapabilities);
|
---|
603 | SSMR3GetU32(pSSM, &that->mfHostCursorCapabilities);
|
---|
604 | }
|
---|
605 |
|
---|
606 | return VINF_SUCCESS;
|
---|
607 | }
|
---|
608 |
|
---|
609 | /**
|
---|
610 | * Initializes the display object.
|
---|
611 | *
|
---|
612 | * @returns COM result indicator
|
---|
613 | * @param aParent handle of our parent object
|
---|
614 | */
|
---|
615 | HRESULT Display::init(Console *aParent)
|
---|
616 | {
|
---|
617 | ComAssertRet(aParent, E_INVALIDARG);
|
---|
618 | /* Enclose the state transition NotReady->InInit->Ready */
|
---|
619 | AutoInitSpan autoInitSpan(this);
|
---|
620 | AssertReturn(autoInitSpan.isOk(), E_FAIL);
|
---|
621 |
|
---|
622 | unconst(mParent) = aParent;
|
---|
623 |
|
---|
624 | mfSourceBitmapEnabled = true;
|
---|
625 | fVGAResizing = false;
|
---|
626 |
|
---|
627 | ULONG ul;
|
---|
628 | mParent->i_machine()->COMGETTER(MonitorCount)(&ul);
|
---|
629 | mcMonitors = ul;
|
---|
630 | xInputMappingOrigin = 0;
|
---|
631 | yInputMappingOrigin = 0;
|
---|
632 | cxInputMapping = 0;
|
---|
633 | cyInputMapping = 0;
|
---|
634 |
|
---|
635 | for (ul = 0; ul < mcMonitors; ul++)
|
---|
636 | {
|
---|
637 | maFramebuffers[ul].u32Offset = 0;
|
---|
638 | maFramebuffers[ul].u32MaxFramebufferSize = 0;
|
---|
639 | maFramebuffers[ul].u32InformationSize = 0;
|
---|
640 |
|
---|
641 | maFramebuffers[ul].pFramebuffer = NULL;
|
---|
642 | /* All secondary monitors are disabled at startup. */
|
---|
643 | maFramebuffers[ul].fDisabled = ul > 0;
|
---|
644 |
|
---|
645 | maFramebuffers[ul].u32Caps = 0;
|
---|
646 |
|
---|
647 | maFramebuffers[ul].updateImage.pu8Address = NULL;
|
---|
648 | maFramebuffers[ul].updateImage.cbLine = 0;
|
---|
649 |
|
---|
650 | maFramebuffers[ul].xOrigin = 0;
|
---|
651 | maFramebuffers[ul].yOrigin = 0;
|
---|
652 |
|
---|
653 | maFramebuffers[ul].w = 0;
|
---|
654 | maFramebuffers[ul].h = 0;
|
---|
655 |
|
---|
656 | maFramebuffers[ul].flags = maFramebuffers[ul].fDisabled? VBVA_SCREEN_F_DISABLED: 0;
|
---|
657 |
|
---|
658 | maFramebuffers[ul].u16BitsPerPixel = 0;
|
---|
659 | maFramebuffers[ul].pu8FramebufferVRAM = NULL;
|
---|
660 | maFramebuffers[ul].u32LineSize = 0;
|
---|
661 |
|
---|
662 | maFramebuffers[ul].pHostEvents = NULL;
|
---|
663 |
|
---|
664 | maFramebuffers[ul].fDefaultFormat = false;
|
---|
665 |
|
---|
666 | #ifdef VBOX_WITH_HGSMI
|
---|
667 | maFramebuffers[ul].fVBVAEnabled = false;
|
---|
668 | maFramebuffers[ul].fVBVAForceResize = false;
|
---|
669 | maFramebuffers[ul].fRenderThreadMode = false;
|
---|
670 | maFramebuffers[ul].pVBVAHostFlags = NULL;
|
---|
671 | #endif /* VBOX_WITH_HGSMI */
|
---|
672 | #ifdef VBOX_WITH_CROGL
|
---|
673 | RT_ZERO(maFramebuffers[ul].pendingViewportInfo);
|
---|
674 | #endif
|
---|
675 | }
|
---|
676 |
|
---|
677 | {
|
---|
678 | // register listener for state change events
|
---|
679 | ComPtr<IEventSource> es;
|
---|
680 | mParent->COMGETTER(EventSource)(es.asOutParam());
|
---|
681 | com::SafeArray<VBoxEventType_T> eventTypes;
|
---|
682 | eventTypes.push_back(VBoxEventType_OnStateChanged);
|
---|
683 | es->RegisterListener(this, ComSafeArrayAsInParam(eventTypes), true);
|
---|
684 | }
|
---|
685 |
|
---|
686 | /* Cache the 3D settings. */
|
---|
687 | BOOL fIs3DEnabled = FALSE;
|
---|
688 | mParent->i_machine()->COMGETTER(Accelerate3DEnabled)(&fIs3DEnabled);
|
---|
689 | GraphicsControllerType_T enmGpuType = (GraphicsControllerType_T)GraphicsControllerType_VBoxVGA;
|
---|
690 | mParent->i_machine()->COMGETTER(GraphicsControllerType)(&enmGpuType);
|
---|
691 | mfIsCr3DEnabled = fIs3DEnabled && enmGpuType == GraphicsControllerType_VBoxVGA;
|
---|
692 |
|
---|
693 | /* Confirm a successful initialization */
|
---|
694 | autoInitSpan.setSucceeded();
|
---|
695 |
|
---|
696 | return S_OK;
|
---|
697 | }
|
---|
698 |
|
---|
699 | /**
|
---|
700 | * Uninitializes the instance and sets the ready flag to FALSE.
|
---|
701 | * Called either from FinalRelease() or by the parent when it gets destroyed.
|
---|
702 | */
|
---|
703 | void Display::uninit()
|
---|
704 | {
|
---|
705 | LogRelFlowFunc(("this=%p\n", this));
|
---|
706 |
|
---|
707 | /* Enclose the state transition Ready->InUninit->NotReady */
|
---|
708 | AutoUninitSpan autoUninitSpan(this);
|
---|
709 | if (autoUninitSpan.uninitDone())
|
---|
710 | return;
|
---|
711 |
|
---|
712 | unsigned uScreenId;
|
---|
713 | for (uScreenId = 0; uScreenId < mcMonitors; uScreenId++)
|
---|
714 | {
|
---|
715 | maFramebuffers[uScreenId].pSourceBitmap.setNull();
|
---|
716 | maFramebuffers[uScreenId].updateImage.pSourceBitmap.setNull();
|
---|
717 | maFramebuffers[uScreenId].updateImage.pu8Address = NULL;
|
---|
718 | maFramebuffers[uScreenId].updateImage.cbLine = 0;
|
---|
719 | maFramebuffers[uScreenId].pFramebuffer.setNull();
|
---|
720 | #ifdef VBOX_WITH_VIDEOREC
|
---|
721 | maFramebuffers[uScreenId].videoCapture.pSourceBitmap.setNull();
|
---|
722 | #endif
|
---|
723 | }
|
---|
724 |
|
---|
725 | if (mParent)
|
---|
726 | {
|
---|
727 | ComPtr<IEventSource> es;
|
---|
728 | mParent->COMGETTER(EventSource)(es.asOutParam());
|
---|
729 | es->UnregisterListener(this);
|
---|
730 | }
|
---|
731 |
|
---|
732 | unconst(mParent) = NULL;
|
---|
733 |
|
---|
734 | if (mpDrv)
|
---|
735 | mpDrv->pDisplay = NULL;
|
---|
736 |
|
---|
737 | mpDrv = NULL;
|
---|
738 | mpVMMDev = NULL;
|
---|
739 | mfVMMDevInited = true;
|
---|
740 | }
|
---|
741 |
|
---|
742 | /**
|
---|
743 | * Register the SSM methods. Called by the power up thread to be able to
|
---|
744 | * pass pVM
|
---|
745 | */
|
---|
746 | int Display::i_registerSSM(PUVM pUVM)
|
---|
747 | {
|
---|
748 | /* Version 2 adds width and height of the framebuffer; version 3 adds
|
---|
749 | * the framebuffer offset in the virtual desktop and the framebuffer flags;
|
---|
750 | * version 4 adds guest to host input event mapping and version 5 adds
|
---|
751 | * guest VBVA and host cursor capabilities.
|
---|
752 | */
|
---|
753 | int rc = SSMR3RegisterExternal(pUVM, "DisplayData", 0, sSSMDisplayVer5,
|
---|
754 | mcMonitors * sizeof(uint32_t) * 8 + sizeof(uint32_t),
|
---|
755 | NULL, NULL, NULL,
|
---|
756 | NULL, i_displaySSMSave, NULL,
|
---|
757 | NULL, i_displaySSMLoad, NULL, this);
|
---|
758 | AssertRCReturn(rc, rc);
|
---|
759 |
|
---|
760 | /*
|
---|
761 | * Register loaders for old saved states where iInstance was
|
---|
762 | * 3 * sizeof(uint32_t *) due to a code mistake.
|
---|
763 | */
|
---|
764 | rc = SSMR3RegisterExternal(pUVM, "DisplayData", 12 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
|
---|
765 | NULL, NULL, NULL,
|
---|
766 | NULL, NULL, NULL,
|
---|
767 | NULL, i_displaySSMLoad, NULL, this);
|
---|
768 | AssertRCReturn(rc, rc);
|
---|
769 |
|
---|
770 | rc = SSMR3RegisterExternal(pUVM, "DisplayData", 24 /*uInstance*/, sSSMDisplayVer, 0 /*cbGuess*/,
|
---|
771 | NULL, NULL, NULL,
|
---|
772 | NULL, NULL, NULL,
|
---|
773 | NULL, i_displaySSMLoad, NULL, this);
|
---|
774 | AssertRCReturn(rc, rc);
|
---|
775 |
|
---|
776 | /* uInstance is an arbitrary value greater than 1024. Such a value will ensure a quick seek in saved state file. */
|
---|
777 | rc = SSMR3RegisterExternal(pUVM, "DisplayScreenshot", 1100 /*uInstance*/, sSSMDisplayScreenshotVer, 0 /*cbGuess*/,
|
---|
778 | NULL, NULL, NULL,
|
---|
779 | NULL, i_displaySSMSaveScreenshot, NULL,
|
---|
780 | NULL, i_displaySSMLoadScreenshot, NULL, this);
|
---|
781 |
|
---|
782 | AssertRCReturn(rc, rc);
|
---|
783 |
|
---|
784 | return VINF_SUCCESS;
|
---|
785 | }
|
---|
786 |
|
---|
787 | DECLCALLBACK(void) Display::i_displayCrCmdFree(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion)
|
---|
788 | {
|
---|
789 | RT_NOREF(pCmd, cbCmd, rc);
|
---|
790 | Assert(pvCompletion);
|
---|
791 | RTMemFree(pvCompletion);
|
---|
792 | }
|
---|
793 |
|
---|
794 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
795 | int Display::i_crOglWindowsShow(bool fShow)
|
---|
796 | {
|
---|
797 | if (!mfCrOglDataHidden == !!fShow)
|
---|
798 | return VINF_SUCCESS;
|
---|
799 |
|
---|
800 | if (!mhCrOglSvc)
|
---|
801 | {
|
---|
802 | /* No 3D or the VMSVGA3d kind. */
|
---|
803 | Assert(!mfIsCr3DEnabled);
|
---|
804 | return VERR_INVALID_STATE;
|
---|
805 | }
|
---|
806 |
|
---|
807 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
808 | if (!pVMMDev)
|
---|
809 | {
|
---|
810 | AssertMsgFailed(("no vmmdev\n"));
|
---|
811 | return VERR_INVALID_STATE;
|
---|
812 | }
|
---|
813 |
|
---|
814 | VBOXCRCMDCTL_HGCM *pData = (VBOXCRCMDCTL_HGCM*)RTMemAlloc(sizeof(VBOXCRCMDCTL_HGCM));
|
---|
815 | if (!pData)
|
---|
816 | {
|
---|
817 | AssertMsgFailed(("RTMemAlloc failed\n"));
|
---|
818 | return VERR_NO_MEMORY;
|
---|
819 | }
|
---|
820 |
|
---|
821 | pData->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
822 | pData->Hdr.u32Function = SHCRGL_HOST_FN_WINDOWS_SHOW;
|
---|
823 |
|
---|
824 | pData->aParms[0].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
825 | pData->aParms[0].u.uint32 = (uint32_t)fShow;
|
---|
826 |
|
---|
827 | int rc = i_crCtlSubmit(&pData->Hdr, sizeof(*pData), i_displayCrCmdFree, pData);
|
---|
828 | if (RT_SUCCESS(rc))
|
---|
829 | mfCrOglDataHidden = !fShow;
|
---|
830 | else
|
---|
831 | {
|
---|
832 | AssertMsgFailed(("crCtlSubmit failed (rc=%Rrc)\n", rc));
|
---|
833 | RTMemFree(pData);
|
---|
834 | }
|
---|
835 |
|
---|
836 | return rc;
|
---|
837 | }
|
---|
838 | #endif
|
---|
839 |
|
---|
840 |
|
---|
841 | // public methods only for internal purposes
|
---|
842 | /////////////////////////////////////////////////////////////////////////////
|
---|
843 |
|
---|
844 | int Display::i_notifyCroglResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM)
|
---|
845 | {
|
---|
846 | RT_NOREF(pView);
|
---|
847 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
848 | if (maFramebuffers[pScreen->u32ViewIndex].fRenderThreadMode)
|
---|
849 | return VINF_SUCCESS; /* nop it */
|
---|
850 |
|
---|
851 | if (mfIsCr3DEnabled)
|
---|
852 | {
|
---|
853 | int rc = VERR_INVALID_STATE;
|
---|
854 | if (mhCrOglSvc)
|
---|
855 | {
|
---|
856 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
857 | if (pVMMDev)
|
---|
858 | {
|
---|
859 | VBOXCRCMDCTL_HGCM *pCtl;
|
---|
860 | pCtl = (VBOXCRCMDCTL_HGCM*)RTMemAlloc(sizeof(CRVBOXHGCMDEVRESIZE) + sizeof(VBOXCRCMDCTL_HGCM));
|
---|
861 | if (pCtl)
|
---|
862 | {
|
---|
863 | CRVBOXHGCMDEVRESIZE *pData = (CRVBOXHGCMDEVRESIZE*)(pCtl+1);
|
---|
864 | pData->Screen = *pScreen;
|
---|
865 | pData->pvVRAM = pvVRAM;
|
---|
866 |
|
---|
867 | pCtl->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
868 | pCtl->Hdr.u32Function = SHCRGL_HOST_FN_DEV_RESIZE;
|
---|
869 | pCtl->aParms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
870 | pCtl->aParms[0].u.pointer.addr = pData;
|
---|
871 | pCtl->aParms[0].u.pointer.size = sizeof(*pData);
|
---|
872 |
|
---|
873 | rc = i_crCtlSubmit(&pCtl->Hdr, sizeof(*pCtl), i_displayCrCmdFree, pCtl);
|
---|
874 | if (RT_FAILURE(rc))
|
---|
875 | {
|
---|
876 | AssertMsgFailed(("crCtlSubmit failed (rc=%Rrc)\n", rc));
|
---|
877 | RTMemFree(pCtl);
|
---|
878 | }
|
---|
879 | }
|
---|
880 | else
|
---|
881 | rc = VERR_NO_MEMORY;
|
---|
882 | }
|
---|
883 | }
|
---|
884 |
|
---|
885 | return rc;
|
---|
886 | }
|
---|
887 | #else /* !VBOX_WITH_HGCM || !VBOX_WITH_CROGL */
|
---|
888 | RT_NOREF(pScreen, pvVRAM);
|
---|
889 | #endif
|
---|
890 | return VINF_SUCCESS;
|
---|
891 | }
|
---|
892 |
|
---|
893 | /**
|
---|
894 | * Handles display resize event.
|
---|
895 | *
|
---|
896 | * @param uScreenId Screen ID
|
---|
897 | * @param bpp New bits per pixel.
|
---|
898 | * @param pvVRAM VRAM pointer.
|
---|
899 | * @param cbLine New bytes per line.
|
---|
900 | * @param w New display width.
|
---|
901 | * @param h New display height.
|
---|
902 | * @param flags Flags of the new video mode.
|
---|
903 | * @param xOrigin New display origin X.
|
---|
904 | * @param yOrigin New display origin Y.
|
---|
905 | * @param fVGAResize Whether the resize is originated from the VGA device (DevVGA).
|
---|
906 | */
|
---|
907 | int Display::i_handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM,
|
---|
908 | uint32_t cbLine, uint32_t w, uint32_t h, uint16_t flags,
|
---|
909 | int32_t xOrigin, int32_t yOrigin, bool fVGAResize)
|
---|
910 | {
|
---|
911 | LogRel(("Display::handleDisplayResize: uScreenId=%d pvVRAM=%p w=%d h=%d bpp=%d cbLine=0x%X flags=0x%X\n", uScreenId,
|
---|
912 | pvVRAM, w, h, bpp, cbLine, flags));
|
---|
913 |
|
---|
914 | /* Caller must not hold the object lock. */
|
---|
915 | AssertReturn(!isWriteLockOnCurrentThread(), VERR_INVALID_STATE);
|
---|
916 |
|
---|
917 | /* Note: the old code checked if the video mode was actially chnaged and
|
---|
918 | * did not invalidate the source bitmap if the mode did not change.
|
---|
919 | * The new code always invalidates the source bitmap, i.e. it will
|
---|
920 | * notify the frontend even if nothing actually changed.
|
---|
921 | *
|
---|
922 | * Implementing the filtering is possible but might lead to pfnSetRenderVRAM races
|
---|
923 | * between this method and QuerySourceBitmap. Such races can be avoided by implementing
|
---|
924 | * the @todo below.
|
---|
925 | */
|
---|
926 |
|
---|
927 | /* Make sure that the VGA device does not access the source bitmap. */
|
---|
928 | if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN && mpDrv)
|
---|
929 | {
|
---|
930 | /// @todo It is probably more convenient to implement
|
---|
931 | // mpDrv->pUpPort->pfnSetOutputBitmap(pvVRAM, cbScanline, cBits, cx, cy, bool fSet);
|
---|
932 | // and remove IConnector.pbData, cbScanline, cBits, cx, cy.
|
---|
933 | // fSet = false disables rendering and VGA can check
|
---|
934 | // if it is already rendering to a different bitmap, avoiding
|
---|
935 | // enable/disable rendering races.
|
---|
936 | mpDrv->pUpPort->pfnSetRenderVRAM(mpDrv->pUpPort, false);
|
---|
937 |
|
---|
938 | mpDrv->IConnector.pbData = NULL;
|
---|
939 | mpDrv->IConnector.cbScanline = 0;
|
---|
940 | mpDrv->IConnector.cBits = 32; /* DevVGA does not work with cBits == 0. */
|
---|
941 | mpDrv->IConnector.cx = 0;
|
---|
942 | mpDrv->IConnector.cy = 0;
|
---|
943 | }
|
---|
944 |
|
---|
945 | /* Update maFramebuffers[uScreenId] under lock. */
|
---|
946 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
947 |
|
---|
948 | if (uScreenId >= mcMonitors)
|
---|
949 | return VINF_SUCCESS;
|
---|
950 |
|
---|
951 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[uScreenId];
|
---|
952 |
|
---|
953 | /* Whether the monitor position has changed.
|
---|
954 | * A resize initiated by the VGA device does not change the monitor position.
|
---|
955 | */
|
---|
956 | const bool fNewOrigin = !fVGAResize
|
---|
957 | && ( pFBInfo->xOrigin != xOrigin
|
---|
958 | || pFBInfo->yOrigin != yOrigin);
|
---|
959 |
|
---|
960 | /* The event for disabled->enabled transition.
|
---|
961 | * VGA resizes also come when the guest uses VBVA mode. They do not affect pFBInfo->fDisabled.
|
---|
962 | * The primary screen is re-enabled when the guest leaves the VBVA mode in i_displayVBVADisable.
|
---|
963 | */
|
---|
964 | const bool fGuestMonitorChangedEvent = !fVGAResize
|
---|
965 | && (pFBInfo->fDisabled != RT_BOOL(flags & VBVA_SCREEN_F_DISABLED));
|
---|
966 |
|
---|
967 | /* Reset the update mode. */
|
---|
968 | pFBInfo->updateImage.pSourceBitmap.setNull();
|
---|
969 | pFBInfo->updateImage.pu8Address = NULL;
|
---|
970 | pFBInfo->updateImage.cbLine = 0;
|
---|
971 |
|
---|
972 | /* Release the current source bitmap. */
|
---|
973 | pFBInfo->pSourceBitmap.setNull();
|
---|
974 |
|
---|
975 | /* VGA blanking is signaled as w=0, h=0, bpp=0 and cbLine=0, and it's
|
---|
976 | * best to keep the old resolution, as otherwise the window size would
|
---|
977 | * change before the new resolution is known. */
|
---|
978 | const bool fVGABlank = fVGAResize && uScreenId == VBOX_VIDEO_PRIMARY_SCREEN
|
---|
979 | && w == 0 && h == 0 && bpp == 0 && cbLine == 0;
|
---|
980 | if (fVGABlank)
|
---|
981 | {
|
---|
982 | w = pFBInfo->w;
|
---|
983 | h = pFBInfo->h;
|
---|
984 | }
|
---|
985 |
|
---|
986 | /* Update the video mode information. */
|
---|
987 | pFBInfo->w = w;
|
---|
988 | pFBInfo->h = h;
|
---|
989 | pFBInfo->u16BitsPerPixel = (uint16_t)bpp;
|
---|
990 | pFBInfo->pu8FramebufferVRAM = (uint8_t *)pvVRAM;
|
---|
991 | pFBInfo->u32LineSize = cbLine;
|
---|
992 | if (!fVGAResize)
|
---|
993 | {
|
---|
994 | /* Fields which are not used in not VBVA modes and not affected by a VGA resize. */
|
---|
995 | pFBInfo->flags = flags;
|
---|
996 | pFBInfo->xOrigin = xOrigin;
|
---|
997 | pFBInfo->yOrigin = yOrigin;
|
---|
998 | pFBInfo->fDisabled = RT_BOOL(flags & VBVA_SCREEN_F_DISABLED);
|
---|
999 | pFBInfo->fVBVAForceResize = false;
|
---|
1000 | }
|
---|
1001 | else
|
---|
1002 | {
|
---|
1003 | pFBInfo->flags = 0;
|
---|
1004 | if (fVGABlank)
|
---|
1005 | pFBInfo->flags |= VBVA_SCREEN_F_BLANK;
|
---|
1006 | pFBInfo->fDisabled = false;
|
---|
1007 | }
|
---|
1008 |
|
---|
1009 | /* Prepare local vars for the notification code below. */
|
---|
1010 | ComPtr<IFramebuffer> pFramebuffer = pFBInfo->pFramebuffer;
|
---|
1011 | const bool fDisabled = pFBInfo->fDisabled;
|
---|
1012 |
|
---|
1013 | alock.release();
|
---|
1014 |
|
---|
1015 | if (!pFramebuffer.isNull())
|
---|
1016 | {
|
---|
1017 | HRESULT hr = pFramebuffer->NotifyChange(uScreenId, 0, 0, w, h); /** @todo origin */
|
---|
1018 | LogFunc(("NotifyChange hr %08X\n", hr));
|
---|
1019 | NOREF(hr);
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | if (fGuestMonitorChangedEvent)
|
---|
1023 | {
|
---|
1024 | if (fDisabled)
|
---|
1025 | fireGuestMonitorChangedEvent(mParent->i_getEventSource(),
|
---|
1026 | GuestMonitorChangedEventType_Disabled,
|
---|
1027 | uScreenId,
|
---|
1028 | 0, 0, 0, 0);
|
---|
1029 | else
|
---|
1030 | fireGuestMonitorChangedEvent(mParent->i_getEventSource(),
|
---|
1031 | GuestMonitorChangedEventType_Enabled,
|
---|
1032 | uScreenId,
|
---|
1033 | xOrigin, yOrigin, w, h);
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 | if (fNewOrigin)
|
---|
1037 | fireGuestMonitorChangedEvent(mParent->i_getEventSource(),
|
---|
1038 | GuestMonitorChangedEventType_NewOrigin,
|
---|
1039 | uScreenId,
|
---|
1040 | xOrigin, yOrigin, 0, 0);
|
---|
1041 |
|
---|
1042 | /* Inform the VRDP server about the change of display parameters. */
|
---|
1043 | LogRelFlowFunc(("Calling VRDP\n"));
|
---|
1044 | mParent->i_consoleVRDPServer()->SendResize();
|
---|
1045 |
|
---|
1046 | /* And re-send the seamless rectangles if necessary. */
|
---|
1047 | if (mfSeamlessEnabled)
|
---|
1048 | i_handleSetVisibleRegion(mcRectVisibleRegion, mpRectVisibleRegion);
|
---|
1049 |
|
---|
1050 | #ifdef VBOX_WITH_VIDEOREC
|
---|
1051 | videoCaptureScreenChanged(uScreenId);
|
---|
1052 | #endif
|
---|
1053 |
|
---|
1054 | LogRelFlowFunc(("[%d]: default format %d\n", uScreenId, pFBInfo->fDefaultFormat));
|
---|
1055 |
|
---|
1056 | return VINF_SUCCESS;
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | static void i_checkCoordBounds(int *px, int *py, int *pw, int *ph, int cx, int cy)
|
---|
1060 | {
|
---|
1061 | /* Correct negative x and y coordinates. */
|
---|
1062 | if (*px < 0)
|
---|
1063 | {
|
---|
1064 | *px += *pw; /* Compute xRight which is also the new width. */
|
---|
1065 |
|
---|
1066 | *pw = (*px < 0)? 0: *px;
|
---|
1067 |
|
---|
1068 | *px = 0;
|
---|
1069 | }
|
---|
1070 |
|
---|
1071 | if (*py < 0)
|
---|
1072 | {
|
---|
1073 | *py += *ph; /* Compute xBottom, which is also the new height. */
|
---|
1074 |
|
---|
1075 | *ph = (*py < 0)? 0: *py;
|
---|
1076 |
|
---|
1077 | *py = 0;
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | /* Also check if coords are greater than the display resolution. */
|
---|
1081 | if (*px + *pw > cx)
|
---|
1082 | {
|
---|
1083 | *pw = cx > *px? cx - *px: 0;
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 | if (*py + *ph > cy)
|
---|
1087 | {
|
---|
1088 | *ph = cy > *py? cy - *py: 0;
|
---|
1089 | }
|
---|
1090 | }
|
---|
1091 |
|
---|
1092 | void Display::i_handleDisplayUpdate(unsigned uScreenId, int x, int y, int w, int h)
|
---|
1093 | {
|
---|
1094 | /*
|
---|
1095 | * Always runs under either VBVA lock or, for HGSMI, DevVGA lock.
|
---|
1096 | * Safe to use VBVA vars and take the framebuffer lock.
|
---|
1097 | */
|
---|
1098 |
|
---|
1099 | #ifdef DEBUG_sunlover
|
---|
1100 | LogFlowFunc(("[%d] %d,%d %dx%d\n",
|
---|
1101 | uScreenId, x, y, w, h));
|
---|
1102 | #endif /* DEBUG_sunlover */
|
---|
1103 |
|
---|
1104 | /* No updates for a disabled guest screen. */
|
---|
1105 | if (maFramebuffers[uScreenId].fDisabled)
|
---|
1106 | return;
|
---|
1107 |
|
---|
1108 | /* No updates for a blank guest screen. */
|
---|
1109 | /** @note Disabled for now, as the GUI does not update the picture when we
|
---|
1110 | * first blank. */
|
---|
1111 | /* if (maFramebuffers[uScreenId].flags & VBVA_SCREEN_F_BLANK)
|
---|
1112 | return; */
|
---|
1113 |
|
---|
1114 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[uScreenId];
|
---|
1115 | AutoReadLock alockr(this COMMA_LOCKVAL_SRC_POS);
|
---|
1116 |
|
---|
1117 | ComPtr<IFramebuffer> pFramebuffer = pFBInfo->pFramebuffer;
|
---|
1118 | ComPtr<IDisplaySourceBitmap> pSourceBitmap = pFBInfo->updateImage.pSourceBitmap;
|
---|
1119 |
|
---|
1120 | alockr.release();
|
---|
1121 |
|
---|
1122 | if (RT_LIKELY(!pFramebuffer.isNull()))
|
---|
1123 | {
|
---|
1124 | if (RT_LIKELY(!RT_BOOL(pFBInfo->u32Caps & FramebufferCapabilities_UpdateImage)))
|
---|
1125 | {
|
---|
1126 | i_checkCoordBounds(&x, &y, &w, &h, pFBInfo->w, pFBInfo->h);
|
---|
1127 |
|
---|
1128 | if (w != 0 && h != 0)
|
---|
1129 | {
|
---|
1130 | pFramebuffer->NotifyUpdate(x, y, w, h);
|
---|
1131 | }
|
---|
1132 | }
|
---|
1133 | else
|
---|
1134 | {
|
---|
1135 | if (RT_LIKELY(!pSourceBitmap.isNull()))
|
---|
1136 | { /* likely */ }
|
---|
1137 | else
|
---|
1138 | {
|
---|
1139 | /* Create a source bitmap if UpdateImage mode is used. */
|
---|
1140 | HRESULT hr = QuerySourceBitmap(uScreenId, pSourceBitmap.asOutParam());
|
---|
1141 | if (SUCCEEDED(hr))
|
---|
1142 | {
|
---|
1143 | BYTE *pAddress = NULL;
|
---|
1144 | ULONG ulWidth = 0;
|
---|
1145 | ULONG ulHeight = 0;
|
---|
1146 | ULONG ulBitsPerPixel = 0;
|
---|
1147 | ULONG ulBytesPerLine = 0;
|
---|
1148 | BitmapFormat_T bitmapFormat = BitmapFormat_Opaque;
|
---|
1149 |
|
---|
1150 | hr = pSourceBitmap->QueryBitmapInfo(&pAddress,
|
---|
1151 | &ulWidth,
|
---|
1152 | &ulHeight,
|
---|
1153 | &ulBitsPerPixel,
|
---|
1154 | &ulBytesPerLine,
|
---|
1155 | &bitmapFormat);
|
---|
1156 | if (SUCCEEDED(hr))
|
---|
1157 | {
|
---|
1158 | AutoWriteLock alockw(this COMMA_LOCKVAL_SRC_POS);
|
---|
1159 |
|
---|
1160 | if (pFBInfo->updateImage.pSourceBitmap.isNull())
|
---|
1161 | {
|
---|
1162 | pFBInfo->updateImage.pSourceBitmap = pSourceBitmap;
|
---|
1163 | pFBInfo->updateImage.pu8Address = pAddress;
|
---|
1164 | pFBInfo->updateImage.cbLine = ulBytesPerLine;
|
---|
1165 | }
|
---|
1166 |
|
---|
1167 | pSourceBitmap = pFBInfo->updateImage.pSourceBitmap;
|
---|
1168 |
|
---|
1169 | alockw.release();
|
---|
1170 | }
|
---|
1171 | }
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | if (RT_LIKELY(!pSourceBitmap.isNull()))
|
---|
1175 | {
|
---|
1176 | BYTE *pbAddress = NULL;
|
---|
1177 | ULONG ulWidth = 0;
|
---|
1178 | ULONG ulHeight = 0;
|
---|
1179 | ULONG ulBitsPerPixel = 0;
|
---|
1180 | ULONG ulBytesPerLine = 0;
|
---|
1181 | BitmapFormat_T bitmapFormat = BitmapFormat_Opaque;
|
---|
1182 |
|
---|
1183 | HRESULT hr = pSourceBitmap->QueryBitmapInfo(&pbAddress,
|
---|
1184 | &ulWidth,
|
---|
1185 | &ulHeight,
|
---|
1186 | &ulBitsPerPixel,
|
---|
1187 | &ulBytesPerLine,
|
---|
1188 | &bitmapFormat);
|
---|
1189 | if (SUCCEEDED(hr))
|
---|
1190 | {
|
---|
1191 | /* Make sure that the requested update is within the source bitmap dimensions. */
|
---|
1192 | i_checkCoordBounds(&x, &y, &w, &h, ulWidth, ulHeight);
|
---|
1193 |
|
---|
1194 | if (w != 0 && h != 0)
|
---|
1195 | {
|
---|
1196 | const size_t cbData = w * h * 4;
|
---|
1197 | com::SafeArray<BYTE> image(cbData);
|
---|
1198 |
|
---|
1199 | uint8_t *pu8Dst = image.raw();
|
---|
1200 | const uint8_t *pu8Src = pbAddress + ulBytesPerLine * y + x * 4;
|
---|
1201 |
|
---|
1202 | int i;
|
---|
1203 | for (i = y; i < y + h; ++i)
|
---|
1204 | {
|
---|
1205 | memcpy(pu8Dst, pu8Src, w * 4);
|
---|
1206 | pu8Dst += w * 4;
|
---|
1207 | pu8Src += ulBytesPerLine;
|
---|
1208 | }
|
---|
1209 |
|
---|
1210 | pFramebuffer->NotifyUpdateImage(x, y, w, h, ComSafeArrayAsInParam(image));
|
---|
1211 | }
|
---|
1212 | }
|
---|
1213 | }
|
---|
1214 | }
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | #ifndef VBOX_WITH_HGSMI
|
---|
1218 | if (!mVideoAccelLegacy.fVideoAccelEnabled)
|
---|
1219 | {
|
---|
1220 | #else
|
---|
1221 | if (!mVideoAccelLegacy.fVideoAccelEnabled && !maFramebuffers[uScreenId].fVBVAEnabled)
|
---|
1222 | {
|
---|
1223 | #endif /* VBOX_WITH_HGSMI */
|
---|
1224 | /* When VBVA is enabled, the VRDP server is informed
|
---|
1225 | * either in VideoAccelFlush or displayVBVAUpdateProcess.
|
---|
1226 | * Inform the server here only if VBVA is disabled.
|
---|
1227 | */
|
---|
1228 | mParent->i_consoleVRDPServer()->SendUpdateBitmap(uScreenId, x, y, w, h);
|
---|
1229 | }
|
---|
1230 | }
|
---|
1231 |
|
---|
1232 | void Display::i_updateGuestGraphicsFacility(void)
|
---|
1233 | {
|
---|
1234 | Guest* pGuest = mParent->i_getGuest();
|
---|
1235 | AssertPtrReturnVoid(pGuest);
|
---|
1236 | /* The following is from GuestImpl.cpp. */
|
---|
1237 | /** @todo A nit: The timestamp is wrong on saved state restore. Would be better
|
---|
1238 | * to move the graphics and seamless capability -> facility translation to
|
---|
1239 | * VMMDev so this could be saved. */
|
---|
1240 | RTTIMESPEC TimeSpecTS;
|
---|
1241 | RTTimeNow(&TimeSpecTS);
|
---|
1242 |
|
---|
1243 | if ( mfVMMDevSupportsGraphics
|
---|
1244 | || (mfGuestVBVACapabilities & VBVACAPS_VIDEO_MODE_HINTS) != 0)
|
---|
1245 | pGuest->i_setAdditionsStatus(VBoxGuestFacilityType_Graphics,
|
---|
1246 | VBoxGuestFacilityStatus_Active,
|
---|
1247 | 0 /*fFlags*/, &TimeSpecTS);
|
---|
1248 | else
|
---|
1249 | pGuest->i_setAdditionsStatus(VBoxGuestFacilityType_Graphics,
|
---|
1250 | VBoxGuestFacilityStatus_Inactive,
|
---|
1251 | 0 /*fFlags*/, &TimeSpecTS);
|
---|
1252 | }
|
---|
1253 |
|
---|
1254 | void Display::i_handleUpdateVMMDevSupportsGraphics(bool fSupportsGraphics)
|
---|
1255 | {
|
---|
1256 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1257 | if (mfVMMDevSupportsGraphics == fSupportsGraphics)
|
---|
1258 | return;
|
---|
1259 | mfVMMDevSupportsGraphics = fSupportsGraphics;
|
---|
1260 | i_updateGuestGraphicsFacility();
|
---|
1261 | /* The VMMDev interface notifies the console. */
|
---|
1262 | }
|
---|
1263 |
|
---|
1264 | void Display::i_handleUpdateGuestVBVACapabilities(uint32_t fNewCapabilities)
|
---|
1265 | {
|
---|
1266 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1267 | bool fNotify = (fNewCapabilities & VBVACAPS_VIDEO_MODE_HINTS) != (mfGuestVBVACapabilities & VBVACAPS_VIDEO_MODE_HINTS);
|
---|
1268 |
|
---|
1269 | mfGuestVBVACapabilities = fNewCapabilities;
|
---|
1270 | if (!fNotify)
|
---|
1271 | return;
|
---|
1272 | i_updateGuestGraphicsFacility();
|
---|
1273 | /* Tell the console about it */
|
---|
1274 | mParent->i_onAdditionsStateChange();
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 | void Display::i_handleUpdateVBVAInputMapping(int32_t xOrigin, int32_t yOrigin, uint32_t cx, uint32_t cy)
|
---|
1278 | {
|
---|
1279 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1280 |
|
---|
1281 | xInputMappingOrigin = xOrigin;
|
---|
1282 | yInputMappingOrigin = yOrigin;
|
---|
1283 | cxInputMapping = cx;
|
---|
1284 | cyInputMapping = cy;
|
---|
1285 |
|
---|
1286 | /* Re-send the seamless rectangles if necessary. */
|
---|
1287 | if (mfSeamlessEnabled)
|
---|
1288 | i_handleSetVisibleRegion(mcRectVisibleRegion, mpRectVisibleRegion);
|
---|
1289 | }
|
---|
1290 |
|
---|
1291 | /**
|
---|
1292 | * Returns the upper left and lower right corners of the virtual framebuffer.
|
---|
1293 | * The lower right is "exclusive" (i.e. first pixel beyond the framebuffer),
|
---|
1294 | * and the origin is (0, 0), not (1, 1) like the GUI returns.
|
---|
1295 | */
|
---|
1296 | void Display::i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
|
---|
1297 | int32_t *px2, int32_t *py2)
|
---|
1298 | {
|
---|
1299 | int32_t x1 = 0, y1 = 0, x2 = 0, y2 = 0;
|
---|
1300 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1301 |
|
---|
1302 | AssertPtrReturnVoid(px1);
|
---|
1303 | AssertPtrReturnVoid(py1);
|
---|
1304 | AssertPtrReturnVoid(px2);
|
---|
1305 | AssertPtrReturnVoid(py2);
|
---|
1306 | LogRelFlowFunc(("\n"));
|
---|
1307 |
|
---|
1308 | if (!mpDrv)
|
---|
1309 | return;
|
---|
1310 | /* If VBVA is not in use then this flag will not be set and this
|
---|
1311 | * will still work as it should. */
|
---|
1312 | if (!maFramebuffers[0].fDisabled)
|
---|
1313 | {
|
---|
1314 | x1 = (int32_t)maFramebuffers[0].xOrigin;
|
---|
1315 | y1 = (int32_t)maFramebuffers[0].yOrigin;
|
---|
1316 | x2 = (int32_t)maFramebuffers[0].w + (int32_t)maFramebuffers[0].xOrigin;
|
---|
1317 | y2 = (int32_t)maFramebuffers[0].h + (int32_t)maFramebuffers[0].yOrigin;
|
---|
1318 | }
|
---|
1319 | if (cxInputMapping && cyInputMapping)
|
---|
1320 | {
|
---|
1321 | x1 = xInputMappingOrigin;
|
---|
1322 | y1 = yInputMappingOrigin;
|
---|
1323 | x2 = xInputMappingOrigin + cxInputMapping;
|
---|
1324 | y2 = yInputMappingOrigin + cyInputMapping;
|
---|
1325 | }
|
---|
1326 | else
|
---|
1327 | for (unsigned i = 1; i < mcMonitors; ++i)
|
---|
1328 | {
|
---|
1329 | if (!maFramebuffers[i].fDisabled)
|
---|
1330 | {
|
---|
1331 | x1 = RT_MIN(x1, maFramebuffers[i].xOrigin);
|
---|
1332 | y1 = RT_MIN(y1, maFramebuffers[i].yOrigin);
|
---|
1333 | x2 = RT_MAX(x2, maFramebuffers[i].xOrigin + (int32_t)maFramebuffers[i].w);
|
---|
1334 | y2 = RT_MAX(y2, maFramebuffers[i].yOrigin + (int32_t)maFramebuffers[i].h);
|
---|
1335 | }
|
---|
1336 | }
|
---|
1337 | *px1 = x1;
|
---|
1338 | *py1 = y1;
|
---|
1339 | *px2 = x2;
|
---|
1340 | *py2 = y2;
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 | HRESULT Display::i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved)
|
---|
1344 | {
|
---|
1345 | /* Do we need this to access mParent? I presume that the safe VM pointer
|
---|
1346 | * ensures that mpDrv will remain valid. */
|
---|
1347 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1348 | uint32_t fHostCursorCapabilities = (mfHostCursorCapabilities | fCapabilitiesAdded)
|
---|
1349 | & ~fCapabilitiesRemoved;
|
---|
1350 |
|
---|
1351 | Console::SafeVMPtr ptrVM(mParent);
|
---|
1352 | if (!ptrVM.isOk())
|
---|
1353 | return ptrVM.rc();
|
---|
1354 | if (mfHostCursorCapabilities == fHostCursorCapabilities)
|
---|
1355 | return S_OK;
|
---|
1356 | CHECK_CONSOLE_DRV(mpDrv);
|
---|
1357 | alock.release(); /* Release before calling up for lock order reasons. */
|
---|
1358 | mpDrv->pUpPort->pfnReportHostCursorCapabilities(mpDrv->pUpPort, fCapabilitiesAdded, fCapabilitiesRemoved);
|
---|
1359 | mfHostCursorCapabilities = fHostCursorCapabilities;
|
---|
1360 | return S_OK;
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 | HRESULT Display::i_reportHostCursorPosition(int32_t x, int32_t y)
|
---|
1364 | {
|
---|
1365 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1366 | uint32_t xAdj = (uint32_t)RT_MAX(x - xInputMappingOrigin, 0);
|
---|
1367 | uint32_t yAdj = (uint32_t)RT_MAX(y - yInputMappingOrigin, 0);
|
---|
1368 | xAdj = RT_MIN(xAdj, cxInputMapping);
|
---|
1369 | yAdj = RT_MIN(yAdj, cyInputMapping);
|
---|
1370 |
|
---|
1371 | Console::SafeVMPtr ptrVM(mParent);
|
---|
1372 | if (!ptrVM.isOk())
|
---|
1373 | return ptrVM.rc();
|
---|
1374 | CHECK_CONSOLE_DRV(mpDrv);
|
---|
1375 | alock.release(); /* Release before calling up for lock order reasons. */
|
---|
1376 | mpDrv->pUpPort->pfnReportHostCursorPosition(mpDrv->pUpPort, xAdj, yAdj);
|
---|
1377 | return S_OK;
|
---|
1378 | }
|
---|
1379 |
|
---|
1380 | static bool displayIntersectRect(RTRECT *prectResult,
|
---|
1381 | const RTRECT *prect1,
|
---|
1382 | const RTRECT *prect2)
|
---|
1383 | {
|
---|
1384 | /* Initialize result to an empty record. */
|
---|
1385 | memset(prectResult, 0, sizeof(RTRECT));
|
---|
1386 |
|
---|
1387 | int xLeftResult = RT_MAX(prect1->xLeft, prect2->xLeft);
|
---|
1388 | int xRightResult = RT_MIN(prect1->xRight, prect2->xRight);
|
---|
1389 |
|
---|
1390 | if (xLeftResult < xRightResult)
|
---|
1391 | {
|
---|
1392 | /* There is intersection by X. */
|
---|
1393 |
|
---|
1394 | int yTopResult = RT_MAX(prect1->yTop, prect2->yTop);
|
---|
1395 | int yBottomResult = RT_MIN(prect1->yBottom, prect2->yBottom);
|
---|
1396 |
|
---|
1397 | if (yTopResult < yBottomResult)
|
---|
1398 | {
|
---|
1399 | /* There is intersection by Y. */
|
---|
1400 |
|
---|
1401 | prectResult->xLeft = xLeftResult;
|
---|
1402 | prectResult->yTop = yTopResult;
|
---|
1403 | prectResult->xRight = xRightResult;
|
---|
1404 | prectResult->yBottom = yBottomResult;
|
---|
1405 |
|
---|
1406 | return true;
|
---|
1407 | }
|
---|
1408 | }
|
---|
1409 |
|
---|
1410 | return false;
|
---|
1411 | }
|
---|
1412 |
|
---|
1413 | int Display::i_saveVisibleRegion(uint32_t cRect, PRTRECT pRect)
|
---|
1414 | {
|
---|
1415 | RTRECT *pRectVisibleRegion = NULL;
|
---|
1416 |
|
---|
1417 | if (pRect == mpRectVisibleRegion)
|
---|
1418 | return VINF_SUCCESS;
|
---|
1419 | if (cRect != 0)
|
---|
1420 | {
|
---|
1421 | pRectVisibleRegion = (RTRECT *)RTMemAlloc(cRect * sizeof(RTRECT));
|
---|
1422 | if (!pRectVisibleRegion)
|
---|
1423 | {
|
---|
1424 | return VERR_NO_MEMORY;
|
---|
1425 | }
|
---|
1426 | memcpy(pRectVisibleRegion, pRect, cRect * sizeof(RTRECT));
|
---|
1427 | }
|
---|
1428 | if (mpRectVisibleRegion)
|
---|
1429 | RTMemFree(mpRectVisibleRegion);
|
---|
1430 | mcRectVisibleRegion = cRect;
|
---|
1431 | mpRectVisibleRegion = pRectVisibleRegion;
|
---|
1432 | return VINF_SUCCESS;
|
---|
1433 | }
|
---|
1434 |
|
---|
1435 | int Display::i_handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect)
|
---|
1436 | {
|
---|
1437 | RTRECT *pVisibleRegion = (RTRECT *)RTMemTmpAlloc( RT_MAX(cRect, 1)
|
---|
1438 | * sizeof(RTRECT));
|
---|
1439 | LogRel2(("%s: cRect=%u\n", __PRETTY_FUNCTION__, cRect));
|
---|
1440 | if (!pVisibleRegion)
|
---|
1441 | {
|
---|
1442 | return VERR_NO_TMP_MEMORY;
|
---|
1443 | }
|
---|
1444 | int rc = i_saveVisibleRegion(cRect, pRect);
|
---|
1445 | if (RT_FAILURE(rc))
|
---|
1446 | {
|
---|
1447 | RTMemTmpFree(pVisibleRegion);
|
---|
1448 | return rc;
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | unsigned uScreenId;
|
---|
1452 | for (uScreenId = 0; uScreenId < mcMonitors; uScreenId++)
|
---|
1453 | {
|
---|
1454 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[uScreenId];
|
---|
1455 |
|
---|
1456 | if ( !pFBInfo->pFramebuffer.isNull()
|
---|
1457 | && RT_BOOL(pFBInfo->u32Caps & FramebufferCapabilities_VisibleRegion))
|
---|
1458 | {
|
---|
1459 | /* Prepare a new array of rectangles which intersect with the framebuffer.
|
---|
1460 | */
|
---|
1461 | RTRECT rectFramebuffer;
|
---|
1462 | rectFramebuffer.xLeft = pFBInfo->xOrigin - xInputMappingOrigin;
|
---|
1463 | rectFramebuffer.yTop = pFBInfo->yOrigin - yInputMappingOrigin;
|
---|
1464 | rectFramebuffer.xRight = rectFramebuffer.xLeft + pFBInfo->w;
|
---|
1465 | rectFramebuffer.yBottom = rectFramebuffer.yTop + pFBInfo->h;
|
---|
1466 |
|
---|
1467 | uint32_t cRectVisibleRegion = 0;
|
---|
1468 |
|
---|
1469 | uint32_t i;
|
---|
1470 | for (i = 0; i < cRect; i++)
|
---|
1471 | {
|
---|
1472 | if (displayIntersectRect(&pVisibleRegion[cRectVisibleRegion], &pRect[i], &rectFramebuffer))
|
---|
1473 | {
|
---|
1474 | pVisibleRegion[cRectVisibleRegion].xLeft -= rectFramebuffer.xLeft;
|
---|
1475 | pVisibleRegion[cRectVisibleRegion].yTop -= rectFramebuffer.yTop;
|
---|
1476 | pVisibleRegion[cRectVisibleRegion].xRight -= rectFramebuffer.xLeft;
|
---|
1477 | pVisibleRegion[cRectVisibleRegion].yBottom -= rectFramebuffer.yTop;
|
---|
1478 |
|
---|
1479 | cRectVisibleRegion++;
|
---|
1480 | }
|
---|
1481 | }
|
---|
1482 | pFBInfo->pFramebuffer->SetVisibleRegion((BYTE *)pVisibleRegion, cRectVisibleRegion);
|
---|
1483 | }
|
---|
1484 | }
|
---|
1485 |
|
---|
1486 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
1487 | VMMDev *vmmDev = mParent->i_getVMMDev();
|
---|
1488 | if (mfIsCr3DEnabled && vmmDev)
|
---|
1489 | {
|
---|
1490 | if (mhCrOglSvc)
|
---|
1491 | {
|
---|
1492 | VBOXCRCMDCTL_HGCM *pCtl;
|
---|
1493 | pCtl = (VBOXCRCMDCTL_HGCM*)RTMemAlloc(RT_MAX(cRect, 1) * sizeof(RTRECT) + sizeof(VBOXCRCMDCTL_HGCM));
|
---|
1494 | if (pCtl)
|
---|
1495 | {
|
---|
1496 | RTRECT *pRectsCopy = (RTRECT*)(pCtl+1);
|
---|
1497 | memcpy(pRectsCopy, pRect, cRect * sizeof(RTRECT));
|
---|
1498 |
|
---|
1499 | pCtl->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
1500 | pCtl->Hdr.u32Function = SHCRGL_HOST_FN_SET_VISIBLE_REGION;
|
---|
1501 |
|
---|
1502 | pCtl->aParms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
1503 | pCtl->aParms[0].u.pointer.addr = pRectsCopy;
|
---|
1504 | pCtl->aParms[0].u.pointer.size = (uint32_t)(cRect * sizeof(RTRECT));
|
---|
1505 |
|
---|
1506 | rc = i_crCtlSubmit(&pCtl->Hdr, sizeof(*pCtl), i_displayCrCmdFree, pCtl);
|
---|
1507 | if (!RT_SUCCESS(rc))
|
---|
1508 | {
|
---|
1509 | AssertMsgFailed(("crCtlSubmit failed (rc=%Rrc)\n", rc));
|
---|
1510 | RTMemFree(pCtl);
|
---|
1511 | }
|
---|
1512 | }
|
---|
1513 | else
|
---|
1514 | AssertMsgFailed(("failed to allocate rects memory\n"));
|
---|
1515 | }
|
---|
1516 | else
|
---|
1517 | AssertMsgFailed(("mhCrOglSvc is NULL\n"));
|
---|
1518 | }
|
---|
1519 | #endif
|
---|
1520 |
|
---|
1521 | RTMemTmpFree(pVisibleRegion);
|
---|
1522 |
|
---|
1523 | return VINF_SUCCESS;
|
---|
1524 | }
|
---|
1525 |
|
---|
1526 | int Display::i_handleQueryVisibleRegion(uint32_t *pcRects, PRTRECT paRects)
|
---|
1527 | {
|
---|
1528 | /// @todo Currently not used by the guest and is not implemented in
|
---|
1529 | /// framebuffers. Remove?
|
---|
1530 | RT_NOREF(pcRects, paRects);
|
---|
1531 | return VERR_NOT_SUPPORTED;
|
---|
1532 | }
|
---|
1533 |
|
---|
1534 | #ifdef VBOX_WITH_HGSMI
|
---|
1535 | static void vbvaSetMemoryFlagsHGSMI(unsigned uScreenId,
|
---|
1536 | uint32_t fu32SupportedOrders,
|
---|
1537 | bool fVideoAccelVRDP,
|
---|
1538 | DISPLAYFBINFO *pFBInfo)
|
---|
1539 | {
|
---|
1540 | LogRelFlowFunc(("HGSMI[%d]: %p\n", uScreenId, pFBInfo->pVBVAHostFlags));
|
---|
1541 |
|
---|
1542 | if (pFBInfo->pVBVAHostFlags)
|
---|
1543 | {
|
---|
1544 | uint32_t fu32HostEvents = VBOX_VIDEO_INFO_HOST_EVENTS_F_VRDP_RESET;
|
---|
1545 |
|
---|
1546 | if (pFBInfo->fVBVAEnabled)
|
---|
1547 | {
|
---|
1548 | fu32HostEvents |= VBVA_F_MODE_ENABLED;
|
---|
1549 |
|
---|
1550 | if (fVideoAccelVRDP)
|
---|
1551 | {
|
---|
1552 | fu32HostEvents |= VBVA_F_MODE_VRDP;
|
---|
1553 | }
|
---|
1554 | }
|
---|
1555 |
|
---|
1556 | ASMAtomicWriteU32(&pFBInfo->pVBVAHostFlags->u32HostEvents, fu32HostEvents);
|
---|
1557 | ASMAtomicWriteU32(&pFBInfo->pVBVAHostFlags->u32SupportedOrders, fu32SupportedOrders);
|
---|
1558 |
|
---|
1559 | LogRelFlowFunc((" fu32HostEvents = 0x%08X, fu32SupportedOrders = 0x%08X\n", fu32HostEvents, fu32SupportedOrders));
|
---|
1560 | }
|
---|
1561 | }
|
---|
1562 |
|
---|
1563 | static void vbvaSetMemoryFlagsAllHGSMI(uint32_t fu32SupportedOrders,
|
---|
1564 | bool fVideoAccelVRDP,
|
---|
1565 | DISPLAYFBINFO *paFBInfos,
|
---|
1566 | unsigned cFBInfos)
|
---|
1567 | {
|
---|
1568 | unsigned uScreenId;
|
---|
1569 |
|
---|
1570 | for (uScreenId = 0; uScreenId < cFBInfos; uScreenId++)
|
---|
1571 | {
|
---|
1572 | vbvaSetMemoryFlagsHGSMI(uScreenId, fu32SupportedOrders, fVideoAccelVRDP, &paFBInfos[uScreenId]);
|
---|
1573 | }
|
---|
1574 | }
|
---|
1575 | #endif /* VBOX_WITH_HGSMI */
|
---|
1576 |
|
---|
1577 | int Display::VideoAccelEnableVMMDev(bool fEnable, VBVAMEMORY *pVbvaMemory)
|
---|
1578 | {
|
---|
1579 | LogFlowFunc(("%d %p\n", fEnable, pVbvaMemory));
|
---|
1580 | int rc = videoAccelEnterVMMDev(&mVideoAccelLegacy);
|
---|
1581 | if (RT_SUCCESS(rc))
|
---|
1582 | {
|
---|
1583 | rc = i_VideoAccelEnable(fEnable, pVbvaMemory, mpDrv->pUpPort);
|
---|
1584 | videoAccelLeaveVMMDev(&mVideoAccelLegacy);
|
---|
1585 | }
|
---|
1586 | LogFlowFunc(("leave %Rrc\n", rc));
|
---|
1587 | return rc;
|
---|
1588 | }
|
---|
1589 |
|
---|
1590 | int Display::VideoAccelEnableVGA(bool fEnable, VBVAMEMORY *pVbvaMemory)
|
---|
1591 | {
|
---|
1592 | LogFlowFunc(("%d %p\n", fEnable, pVbvaMemory));
|
---|
1593 | int rc = videoAccelEnterVGA(&mVideoAccelLegacy);
|
---|
1594 | if (RT_SUCCESS(rc))
|
---|
1595 | {
|
---|
1596 | rc = i_VideoAccelEnable(fEnable, pVbvaMemory, mpDrv->pUpPort);
|
---|
1597 | videoAccelLeaveVGA(&mVideoAccelLegacy);
|
---|
1598 | }
|
---|
1599 | LogFlowFunc(("leave %Rrc\n", rc));
|
---|
1600 | return rc;
|
---|
1601 | }
|
---|
1602 |
|
---|
1603 | void Display::VideoAccelFlushVMMDev(void)
|
---|
1604 | {
|
---|
1605 | LogFlowFunc(("enter\n"));
|
---|
1606 | int rc = videoAccelEnterVMMDev(&mVideoAccelLegacy);
|
---|
1607 | if (RT_SUCCESS(rc))
|
---|
1608 | {
|
---|
1609 | i_VideoAccelFlush(mpDrv->pUpPort);
|
---|
1610 | videoAccelLeaveVMMDev(&mVideoAccelLegacy);
|
---|
1611 | }
|
---|
1612 | LogFlowFunc(("leave\n"));
|
---|
1613 | }
|
---|
1614 |
|
---|
1615 | /* Called always by one VRDP server thread. Can be thread-unsafe.
|
---|
1616 | */
|
---|
1617 | void Display::i_VideoAccelVRDP(bool fEnable)
|
---|
1618 | {
|
---|
1619 | LogRelFlowFunc(("fEnable = %d\n", fEnable));
|
---|
1620 |
|
---|
1621 | VIDEOACCEL *pVideoAccel = &mVideoAccelLegacy;
|
---|
1622 |
|
---|
1623 | int c = fEnable?
|
---|
1624 | ASMAtomicIncS32(&mcVideoAccelVRDPRefs):
|
---|
1625 | ASMAtomicDecS32(&mcVideoAccelVRDPRefs);
|
---|
1626 |
|
---|
1627 | Assert (c >= 0);
|
---|
1628 |
|
---|
1629 | /* This can run concurrently with Display videoaccel state change. */
|
---|
1630 | RTCritSectEnter(&mVideoAccelLock);
|
---|
1631 |
|
---|
1632 | if (c == 0)
|
---|
1633 | {
|
---|
1634 | /* The last client has disconnected, and the accel can be
|
---|
1635 | * disabled.
|
---|
1636 | */
|
---|
1637 | Assert(fEnable == false);
|
---|
1638 |
|
---|
1639 | mfVideoAccelVRDP = false;
|
---|
1640 | mfu32SupportedOrders = 0;
|
---|
1641 |
|
---|
1642 | i_vbvaSetMemoryFlags(pVideoAccel->pVbvaMemory, pVideoAccel->fVideoAccelEnabled, mfVideoAccelVRDP, mfu32SupportedOrders,
|
---|
1643 | maFramebuffers, mcMonitors);
|
---|
1644 | #ifdef VBOX_WITH_HGSMI
|
---|
1645 | /* Here is VRDP-IN thread. Process the request in vbvaUpdateBegin under DevVGA lock on an EMT. */
|
---|
1646 | ASMAtomicIncU32(&mu32UpdateVBVAFlags);
|
---|
1647 | #endif /* VBOX_WITH_HGSMI */
|
---|
1648 |
|
---|
1649 | LogRel(("VBVA: VRDP acceleration has been disabled.\n"));
|
---|
1650 | }
|
---|
1651 | else if ( c == 1
|
---|
1652 | && !mfVideoAccelVRDP)
|
---|
1653 | {
|
---|
1654 | /* The first client has connected. Enable the accel.
|
---|
1655 | */
|
---|
1656 | Assert(fEnable == true);
|
---|
1657 |
|
---|
1658 | mfVideoAccelVRDP = true;
|
---|
1659 | /* Supporting all orders. */
|
---|
1660 | mfu32SupportedOrders = UINT32_MAX;
|
---|
1661 |
|
---|
1662 | i_vbvaSetMemoryFlags(pVideoAccel->pVbvaMemory, pVideoAccel->fVideoAccelEnabled, mfVideoAccelVRDP, mfu32SupportedOrders,
|
---|
1663 | maFramebuffers, mcMonitors);
|
---|
1664 | #ifdef VBOX_WITH_HGSMI
|
---|
1665 | /* Here is VRDP-IN thread. Process the request in vbvaUpdateBegin under DevVGA lock on an EMT. */
|
---|
1666 | ASMAtomicIncU32(&mu32UpdateVBVAFlags);
|
---|
1667 | #endif /* VBOX_WITH_HGSMI */
|
---|
1668 |
|
---|
1669 | LogRel(("VBVA: VRDP acceleration has been requested.\n"));
|
---|
1670 | }
|
---|
1671 | else
|
---|
1672 | {
|
---|
1673 | /* A client is connected or disconnected but there is no change in the
|
---|
1674 | * accel state. It remains enabled.
|
---|
1675 | */
|
---|
1676 | Assert(mfVideoAccelVRDP == true);
|
---|
1677 | }
|
---|
1678 |
|
---|
1679 | RTCritSectLeave(&mVideoAccelLock);
|
---|
1680 | }
|
---|
1681 |
|
---|
1682 | void Display::i_notifyPowerDown(void)
|
---|
1683 | {
|
---|
1684 | LogRelFlowFunc(("\n"));
|
---|
1685 |
|
---|
1686 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1687 |
|
---|
1688 | /* Source bitmaps are not available anymore. */
|
---|
1689 | mfSourceBitmapEnabled = false;
|
---|
1690 |
|
---|
1691 | alock.release();
|
---|
1692 |
|
---|
1693 | /* Resize all displays to tell framebuffers to forget current source bitmap. */
|
---|
1694 | unsigned uScreenId = mcMonitors;
|
---|
1695 | while (uScreenId > 0)
|
---|
1696 | {
|
---|
1697 | --uScreenId;
|
---|
1698 |
|
---|
1699 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[uScreenId];
|
---|
1700 | if (!pFBInfo->fDisabled)
|
---|
1701 | {
|
---|
1702 | i_handleDisplayResize(uScreenId, 32,
|
---|
1703 | pFBInfo->pu8FramebufferVRAM,
|
---|
1704 | pFBInfo->u32LineSize,
|
---|
1705 | pFBInfo->w,
|
---|
1706 | pFBInfo->h,
|
---|
1707 | pFBInfo->flags,
|
---|
1708 | pFBInfo->xOrigin,
|
---|
1709 | pFBInfo->yOrigin,
|
---|
1710 | false);
|
---|
1711 | }
|
---|
1712 | }
|
---|
1713 | }
|
---|
1714 |
|
---|
1715 | // Wrapped IDisplay methods
|
---|
1716 | /////////////////////////////////////////////////////////////////////////////
|
---|
1717 | HRESULT Display::getScreenResolution(ULONG aScreenId, ULONG *aWidth, ULONG *aHeight, ULONG *aBitsPerPixel,
|
---|
1718 | LONG *aXOrigin, LONG *aYOrigin, GuestMonitorStatus_T *aGuestMonitorStatus)
|
---|
1719 | {
|
---|
1720 | LogRelFlowFunc(("aScreenId=%RU32\n", aScreenId));
|
---|
1721 |
|
---|
1722 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1723 |
|
---|
1724 | if (aScreenId >= mcMonitors)
|
---|
1725 | return E_INVALIDARG;
|
---|
1726 |
|
---|
1727 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[aScreenId];
|
---|
1728 |
|
---|
1729 | GuestMonitorStatus_T guestMonitorStatus = GuestMonitorStatus_Enabled;
|
---|
1730 |
|
---|
1731 | if (pFBInfo->flags & VBVA_SCREEN_F_DISABLED)
|
---|
1732 | guestMonitorStatus = GuestMonitorStatus_Disabled;
|
---|
1733 | else if (pFBInfo->flags & (VBVA_SCREEN_F_BLANK | VBVA_SCREEN_F_BLANK2))
|
---|
1734 | guestMonitorStatus = GuestMonitorStatus_Blank;
|
---|
1735 |
|
---|
1736 | if (aWidth)
|
---|
1737 | *aWidth = pFBInfo->w;
|
---|
1738 | if (aHeight)
|
---|
1739 | *aHeight = pFBInfo->h;
|
---|
1740 | if (aBitsPerPixel)
|
---|
1741 | *aBitsPerPixel = pFBInfo->u16BitsPerPixel;
|
---|
1742 | if (aXOrigin)
|
---|
1743 | *aXOrigin = pFBInfo->xOrigin;
|
---|
1744 | if (aYOrigin)
|
---|
1745 | *aYOrigin = pFBInfo->yOrigin;
|
---|
1746 | if (aGuestMonitorStatus)
|
---|
1747 | *aGuestMonitorStatus = guestMonitorStatus;
|
---|
1748 |
|
---|
1749 | return S_OK;
|
---|
1750 | }
|
---|
1751 |
|
---|
1752 |
|
---|
1753 | HRESULT Display::attachFramebuffer(ULONG aScreenId, const ComPtr<IFramebuffer> &aFramebuffer, com::Guid &aId)
|
---|
1754 | {
|
---|
1755 | LogRelFlowFunc(("aScreenId = %d\n", aScreenId));
|
---|
1756 |
|
---|
1757 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1758 |
|
---|
1759 | if (aScreenId >= mcMonitors)
|
---|
1760 | return setError(E_INVALIDARG, tr("AttachFramebuffer: Invalid screen %d (total %d)"),
|
---|
1761 | aScreenId, mcMonitors);
|
---|
1762 |
|
---|
1763 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[aScreenId];
|
---|
1764 | if (!pFBInfo->pFramebuffer.isNull())
|
---|
1765 | return setError(E_FAIL, tr("AttachFramebuffer: Framebuffer already attached to %d"),
|
---|
1766 | aScreenId);
|
---|
1767 |
|
---|
1768 | pFBInfo->pFramebuffer = aFramebuffer;
|
---|
1769 | pFBInfo->framebufferId.create();
|
---|
1770 | aId = pFBInfo->framebufferId;
|
---|
1771 |
|
---|
1772 | SafeArray<FramebufferCapabilities_T> caps;
|
---|
1773 | pFBInfo->pFramebuffer->COMGETTER(Capabilities)(ComSafeArrayAsOutParam(caps));
|
---|
1774 | pFBInfo->u32Caps = 0;
|
---|
1775 | size_t i;
|
---|
1776 | for (i = 0; i < caps.size(); ++i)
|
---|
1777 | pFBInfo->u32Caps |= caps[i];
|
---|
1778 |
|
---|
1779 | alock.release();
|
---|
1780 |
|
---|
1781 | /* The driver might not have been constructed yet */
|
---|
1782 | if (mpDrv)
|
---|
1783 | {
|
---|
1784 | /* Inform the framebuffer about the actual screen size. */
|
---|
1785 | HRESULT hr = aFramebuffer->NotifyChange(aScreenId, 0, 0, pFBInfo->w, pFBInfo->h); /** @todo origin */
|
---|
1786 | LogFunc(("NotifyChange hr %08X\n", hr)); NOREF(hr);
|
---|
1787 |
|
---|
1788 | /* Re-send the seamless rectangles if necessary. */
|
---|
1789 | if (mfSeamlessEnabled)
|
---|
1790 | i_handleSetVisibleRegion(mcRectVisibleRegion, mpRectVisibleRegion);
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | Console::SafeVMPtrQuiet ptrVM(mParent);
|
---|
1794 | if (ptrVM.isOk())
|
---|
1795 | {
|
---|
1796 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
1797 | if (mfIsCr3DEnabled)
|
---|
1798 | {
|
---|
1799 | VBOXCRCMDCTL_HGCM data;
|
---|
1800 | RT_ZERO(data);
|
---|
1801 | data.Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
1802 | data.Hdr.u32Function = SHCRGL_HOST_FN_SCREEN_CHANGED;
|
---|
1803 |
|
---|
1804 | data.aParms[0].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
1805 | data.aParms[0].u.uint32 = aScreenId;
|
---|
1806 |
|
---|
1807 | int vrc = i_crCtlSubmitSync(&data.Hdr, sizeof(data));
|
---|
1808 | AssertRC(vrc);
|
---|
1809 | }
|
---|
1810 | #endif /* defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL) */
|
---|
1811 |
|
---|
1812 | VMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
|
---|
1813 | 3, this, aScreenId, false);
|
---|
1814 | }
|
---|
1815 |
|
---|
1816 | LogRelFlowFunc(("Attached to %d %RTuuid\n", aScreenId, aId.raw()));
|
---|
1817 | return S_OK;
|
---|
1818 | }
|
---|
1819 |
|
---|
1820 | HRESULT Display::detachFramebuffer(ULONG aScreenId, const com::Guid &aId)
|
---|
1821 | {
|
---|
1822 | LogRelFlowFunc(("aScreenId = %d %RTuuid\n", aScreenId, aId.raw()));
|
---|
1823 |
|
---|
1824 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1825 |
|
---|
1826 | if (aScreenId >= mcMonitors)
|
---|
1827 | return setError(E_INVALIDARG, tr("DetachFramebuffer: Invalid screen %d (total %d)"),
|
---|
1828 | aScreenId, mcMonitors);
|
---|
1829 |
|
---|
1830 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[aScreenId];
|
---|
1831 |
|
---|
1832 | if (pFBInfo->framebufferId != aId)
|
---|
1833 | {
|
---|
1834 | LogRelFlowFunc(("Invalid framebuffer aScreenId = %d, attached %p\n", aScreenId, pFBInfo->framebufferId.raw()));
|
---|
1835 | return setError(E_FAIL, tr("DetachFramebuffer: Invalid framebuffer object"));
|
---|
1836 | }
|
---|
1837 |
|
---|
1838 | pFBInfo->pFramebuffer.setNull();
|
---|
1839 | pFBInfo->framebufferId.clear();
|
---|
1840 |
|
---|
1841 | alock.release();
|
---|
1842 |
|
---|
1843 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
1844 | Console::SafeVMPtrQuiet ptrVM(mParent);
|
---|
1845 | if (ptrVM.isOk())
|
---|
1846 | {
|
---|
1847 | if (mfIsCr3DEnabled)
|
---|
1848 | {
|
---|
1849 | VBOXCRCMDCTL_HGCM data;
|
---|
1850 | RT_ZERO(data);
|
---|
1851 | data.Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
1852 | data.Hdr.u32Function = SHCRGL_HOST_FN_SCREEN_CHANGED;
|
---|
1853 |
|
---|
1854 | data.aParms[0].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
1855 | data.aParms[0].u.uint32 = aScreenId;
|
---|
1856 |
|
---|
1857 | int vrc = i_crCtlSubmitSync(&data.Hdr, sizeof(data));
|
---|
1858 | AssertRC(vrc);
|
---|
1859 | }
|
---|
1860 | }
|
---|
1861 | #endif /* defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL) */
|
---|
1862 |
|
---|
1863 | return S_OK;
|
---|
1864 | }
|
---|
1865 |
|
---|
1866 | HRESULT Display::queryFramebuffer(ULONG aScreenId, ComPtr<IFramebuffer> &aFramebuffer)
|
---|
1867 | {
|
---|
1868 | LogRelFlowFunc(("aScreenId = %d\n", aScreenId));
|
---|
1869 |
|
---|
1870 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1871 |
|
---|
1872 | if (aScreenId >= mcMonitors)
|
---|
1873 | return setError(E_INVALIDARG, tr("QueryFramebuffer: Invalid screen %d (total %d)"),
|
---|
1874 | aScreenId, mcMonitors);
|
---|
1875 |
|
---|
1876 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[aScreenId];
|
---|
1877 |
|
---|
1878 | pFBInfo->pFramebuffer.queryInterfaceTo(aFramebuffer.asOutParam());
|
---|
1879 |
|
---|
1880 | return S_OK;
|
---|
1881 | }
|
---|
1882 |
|
---|
1883 | HRESULT Display::setVideoModeHint(ULONG aDisplay, BOOL aEnabled,
|
---|
1884 | BOOL aChangeOrigin, LONG aOriginX, LONG aOriginY,
|
---|
1885 | ULONG aWidth, ULONG aHeight, ULONG aBitsPerPixel)
|
---|
1886 | {
|
---|
1887 | if (aWidth == 0 || aHeight == 0 || aBitsPerPixel == 0)
|
---|
1888 | {
|
---|
1889 | /* Some of parameters must not change. Query current mode. */
|
---|
1890 | ULONG ulWidth = 0;
|
---|
1891 | ULONG ulHeight = 0;
|
---|
1892 | ULONG ulBitsPerPixel = 0;
|
---|
1893 | HRESULT hr = getScreenResolution(aDisplay, &ulWidth, &ulHeight, &ulBitsPerPixel, NULL, NULL, NULL);
|
---|
1894 | if (FAILED(hr))
|
---|
1895 | return hr;
|
---|
1896 |
|
---|
1897 | /* Assign current values to not changing parameters. */
|
---|
1898 | if (aWidth == 0)
|
---|
1899 | aWidth = ulWidth;
|
---|
1900 | if (aHeight == 0)
|
---|
1901 | aHeight = ulHeight;
|
---|
1902 | if (aBitsPerPixel == 0)
|
---|
1903 | aBitsPerPixel = ulBitsPerPixel;
|
---|
1904 | }
|
---|
1905 |
|
---|
1906 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1907 |
|
---|
1908 | if (aDisplay >= mcMonitors)
|
---|
1909 | return E_INVALIDARG;
|
---|
1910 |
|
---|
1911 | CHECK_CONSOLE_DRV(mpDrv);
|
---|
1912 |
|
---|
1913 | /*
|
---|
1914 | * It is up to the guest to decide whether the hint is
|
---|
1915 | * valid. Therefore don't do any VRAM sanity checks here.
|
---|
1916 | */
|
---|
1917 |
|
---|
1918 | /* Have to release the lock because the pfnRequestDisplayChange
|
---|
1919 | * will call EMT. */
|
---|
1920 | alock.release();
|
---|
1921 |
|
---|
1922 | /* We always send the hint to the graphics card in case the guest enables
|
---|
1923 | * support later. For now we notify exactly when support is enabled. */
|
---|
1924 | mpDrv->pUpPort->pfnSendModeHint(mpDrv->pUpPort, aWidth, aHeight,
|
---|
1925 | aBitsPerPixel, aDisplay,
|
---|
1926 | aChangeOrigin ? aOriginX : ~0,
|
---|
1927 | aChangeOrigin ? aOriginY : ~0,
|
---|
1928 | RT_BOOL(aEnabled),
|
---|
1929 | mfGuestVBVACapabilities
|
---|
1930 | & VBVACAPS_VIDEO_MODE_HINTS);
|
---|
1931 | if ( mfGuestVBVACapabilities & VBVACAPS_VIDEO_MODE_HINTS
|
---|
1932 | && !(mfGuestVBVACapabilities & VBVACAPS_IRQ))
|
---|
1933 | {
|
---|
1934 | mParent->i_sendACPIMonitorHotPlugEvent();
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 | /* We currently never suppress the VMMDev hint if the guest has requested
|
---|
1938 | * it. Specifically the video graphics driver may not be responsible for
|
---|
1939 | * screen positioning in the guest virtual desktop, and the component
|
---|
1940 | * responsible may want to get the hint from VMMDev. */
|
---|
1941 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
1942 | if (pVMMDev)
|
---|
1943 | {
|
---|
1944 | PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort();
|
---|
1945 | if (pVMMDevPort)
|
---|
1946 | pVMMDevPort->pfnRequestDisplayChange(pVMMDevPort, aWidth, aHeight, aBitsPerPixel,
|
---|
1947 | aDisplay, aOriginX, aOriginY,
|
---|
1948 | RT_BOOL(aEnabled), RT_BOOL(aChangeOrigin));
|
---|
1949 | }
|
---|
1950 | return S_OK;
|
---|
1951 | }
|
---|
1952 |
|
---|
1953 | HRESULT Display::setSeamlessMode(BOOL enabled)
|
---|
1954 | {
|
---|
1955 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
1956 |
|
---|
1957 | /* Have to release the lock because the pfnRequestSeamlessChange will call EMT. */
|
---|
1958 | alock.release();
|
---|
1959 |
|
---|
1960 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
1961 | if (pVMMDev)
|
---|
1962 | {
|
---|
1963 | PPDMIVMMDEVPORT pVMMDevPort = pVMMDev->getVMMDevPort();
|
---|
1964 | if (pVMMDevPort)
|
---|
1965 | pVMMDevPort->pfnRequestSeamlessChange(pVMMDevPort, !!enabled);
|
---|
1966 | }
|
---|
1967 | mfSeamlessEnabled = RT_BOOL(enabled);
|
---|
1968 |
|
---|
1969 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
1970 | if (!enabled)
|
---|
1971 | {
|
---|
1972 | VMMDev *vmmDev = mParent->i_getVMMDev();
|
---|
1973 | if (mfIsCr3DEnabled && vmmDev)
|
---|
1974 | {
|
---|
1975 | VBOXCRCMDCTL_HGCM *pData = (VBOXCRCMDCTL_HGCM*)RTMemAlloc(sizeof(VBOXCRCMDCTL_HGCM));
|
---|
1976 | if (!pData)
|
---|
1977 | {
|
---|
1978 | AssertMsgFailed(("RTMemAlloc failed\n"));
|
---|
1979 | return VERR_NO_MEMORY;
|
---|
1980 | }
|
---|
1981 |
|
---|
1982 | pData->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
1983 | pData->Hdr.u32Function = SHCRGL_HOST_FN_SET_VISIBLE_REGION;
|
---|
1984 |
|
---|
1985 | pData->aParms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
1986 | pData->aParms[0].u.pointer.addr = NULL;
|
---|
1987 | pData->aParms[0].u.pointer.size = 0; /* <- means null rects, NULL pRects address and 0 rects means "disable" */
|
---|
1988 |
|
---|
1989 | int rc = i_crCtlSubmit(&pData->Hdr, sizeof(*pData), i_displayCrCmdFree, pData);
|
---|
1990 | if (!RT_SUCCESS(rc))
|
---|
1991 | {
|
---|
1992 | AssertMsgFailed(("crCtlSubmit failed (rc=%Rrc)\n", rc));
|
---|
1993 | RTMemFree(pData);
|
---|
1994 | }
|
---|
1995 | }
|
---|
1996 | }
|
---|
1997 | #endif
|
---|
1998 | return S_OK;
|
---|
1999 | }
|
---|
2000 |
|
---|
2001 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
2002 | BOOL Display::i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pbData,
|
---|
2003 | uint32_t u32Width, uint32_t u32Height)
|
---|
2004 | {
|
---|
2005 | if ( pDisplay->mfIsCr3DEnabled
|
---|
2006 | && pDisplay->mCrOglCallbacks.pfnHasData
|
---|
2007 | && pDisplay->mCrOglCallbacks.pfnHasData())
|
---|
2008 | {
|
---|
2009 | VMMDev *pVMMDev = pDisplay->mParent->i_getVMMDev();
|
---|
2010 | if (pVMMDev)
|
---|
2011 | {
|
---|
2012 | CRVBOXHGCMTAKESCREENSHOT *pScreenshot = (CRVBOXHGCMTAKESCREENSHOT *)RTMemAlloc(sizeof(*pScreenshot));
|
---|
2013 | if (pScreenshot)
|
---|
2014 | {
|
---|
2015 | /* screen id or CRSCREEN_ALL to specify all enabled */
|
---|
2016 | pScreenshot->u32Screen = aScreenId;
|
---|
2017 | pScreenshot->u32Width = u32Width;
|
---|
2018 | pScreenshot->u32Height = u32Height;
|
---|
2019 | pScreenshot->u32Pitch = u32Width * 4;
|
---|
2020 | pScreenshot->pvBuffer = pbData;
|
---|
2021 | pScreenshot->pvContext = NULL;
|
---|
2022 | pScreenshot->pfnScreenshotBegin = NULL;
|
---|
2023 | pScreenshot->pfnScreenshotPerform = NULL;
|
---|
2024 | pScreenshot->pfnScreenshotEnd = NULL;
|
---|
2025 |
|
---|
2026 | VBOXCRCMDCTL_HGCM data;
|
---|
2027 | data.Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
2028 | data.Hdr.u32Function = SHCRGL_HOST_FN_TAKE_SCREENSHOT;
|
---|
2029 |
|
---|
2030 | data.aParms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
2031 | data.aParms[0].u.pointer.addr = pScreenshot;
|
---|
2032 | data.aParms[0].u.pointer.size = sizeof(*pScreenshot);
|
---|
2033 |
|
---|
2034 | int rc = pDisplay->i_crCtlSubmitSync(&data.Hdr, sizeof(data));
|
---|
2035 |
|
---|
2036 | RTMemFree(pScreenshot);
|
---|
2037 |
|
---|
2038 | if (RT_SUCCESS(rc))
|
---|
2039 | return TRUE;
|
---|
2040 | AssertMsgFailed(("failed to get screenshot data from crOgl (rc=%Rrc)\n", rc));
|
---|
2041 | /* fall back to the non-3d mechanism */
|
---|
2042 | }
|
---|
2043 | }
|
---|
2044 | }
|
---|
2045 | return FALSE;
|
---|
2046 | }
|
---|
2047 | #endif
|
---|
2048 |
|
---|
2049 | /* static */
|
---|
2050 | int Display::i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
|
---|
2051 | uint32_t *pcx, uint32_t *pcy, bool *pfMemFree)
|
---|
2052 | {
|
---|
2053 | int rc;
|
---|
2054 | if ( aScreenId == VBOX_VIDEO_PRIMARY_SCREEN
|
---|
2055 | && pDisplay->maFramebuffers[aScreenId].fVBVAEnabled == false) /* A non-VBVA mode. */
|
---|
2056 | {
|
---|
2057 | if (pDisplay->mpDrv)
|
---|
2058 | {
|
---|
2059 | rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppbData, pcbData, pcx, pcy);
|
---|
2060 | *pfMemFree = false;
|
---|
2061 | }
|
---|
2062 | else
|
---|
2063 | {
|
---|
2064 | /* No image. */
|
---|
2065 | *ppbData = NULL;
|
---|
2066 | *pcbData = 0;
|
---|
2067 | *pcx = 0;
|
---|
2068 | *pcy = 0;
|
---|
2069 | *pfMemFree = true;
|
---|
2070 | rc = VINF_SUCCESS;
|
---|
2071 | }
|
---|
2072 | }
|
---|
2073 | else if (aScreenId < pDisplay->mcMonitors)
|
---|
2074 | {
|
---|
2075 | DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[aScreenId];
|
---|
2076 |
|
---|
2077 | uint32_t width = pFBInfo->w;
|
---|
2078 | uint32_t height = pFBInfo->h;
|
---|
2079 |
|
---|
2080 | /* Allocate 32 bit per pixel bitmap. */
|
---|
2081 | size_t cbRequired = width * 4 * height;
|
---|
2082 |
|
---|
2083 | if (cbRequired)
|
---|
2084 | {
|
---|
2085 | uint8_t *pbDst = (uint8_t *)RTMemAlloc(cbRequired);
|
---|
2086 | if (pbDst != NULL)
|
---|
2087 | {
|
---|
2088 | if (pFBInfo->flags & VBVA_SCREEN_F_ACTIVE)
|
---|
2089 | {
|
---|
2090 | /* Copy guest VRAM to the allocated 32bpp buffer. */
|
---|
2091 | const uint8_t *pu8Src = pFBInfo->pu8FramebufferVRAM;
|
---|
2092 | int32_t xSrc = 0;
|
---|
2093 | int32_t ySrc = 0;
|
---|
2094 | uint32_t u32SrcWidth = width;
|
---|
2095 | uint32_t u32SrcHeight = height;
|
---|
2096 | uint32_t u32SrcLineSize = pFBInfo->u32LineSize;
|
---|
2097 | uint32_t u32SrcBitsPerPixel = pFBInfo->u16BitsPerPixel;
|
---|
2098 |
|
---|
2099 | int32_t xDst = 0;
|
---|
2100 | int32_t yDst = 0;
|
---|
2101 | uint32_t u32DstWidth = u32SrcWidth;
|
---|
2102 | uint32_t u32DstHeight = u32SrcHeight;
|
---|
2103 | uint32_t u32DstLineSize = u32DstWidth * 4;
|
---|
2104 | uint32_t u32DstBitsPerPixel = 32;
|
---|
2105 |
|
---|
2106 | rc = pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
|
---|
2107 | width, height,
|
---|
2108 | pu8Src,
|
---|
2109 | xSrc, ySrc,
|
---|
2110 | u32SrcWidth, u32SrcHeight,
|
---|
2111 | u32SrcLineSize, u32SrcBitsPerPixel,
|
---|
2112 | pbDst,
|
---|
2113 | xDst, yDst,
|
---|
2114 | u32DstWidth, u32DstHeight,
|
---|
2115 | u32DstLineSize, u32DstBitsPerPixel);
|
---|
2116 | }
|
---|
2117 | else
|
---|
2118 | {
|
---|
2119 | memset(pbDst, 0, cbRequired);
|
---|
2120 | rc = VINF_SUCCESS;
|
---|
2121 | }
|
---|
2122 | if (RT_SUCCESS(rc))
|
---|
2123 | {
|
---|
2124 | *ppbData = pbDst;
|
---|
2125 | *pcbData = cbRequired;
|
---|
2126 | *pcx = width;
|
---|
2127 | *pcy = height;
|
---|
2128 | *pfMemFree = true;
|
---|
2129 | }
|
---|
2130 | else
|
---|
2131 | {
|
---|
2132 | RTMemFree(pbDst);
|
---|
2133 |
|
---|
2134 | /* CopyRect can fail if VBVA was paused in VGA device, retry using the generic method. */
|
---|
2135 | if ( rc == VERR_INVALID_STATE
|
---|
2136 | && aScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
|
---|
2137 | {
|
---|
2138 | rc = pDisplay->mpDrv->pUpPort->pfnTakeScreenshot(pDisplay->mpDrv->pUpPort, ppbData, pcbData, pcx, pcy);
|
---|
2139 | *pfMemFree = false;
|
---|
2140 | }
|
---|
2141 | }
|
---|
2142 | }
|
---|
2143 | else
|
---|
2144 | rc = VERR_NO_MEMORY;
|
---|
2145 | }
|
---|
2146 | else
|
---|
2147 | {
|
---|
2148 | /* No image. */
|
---|
2149 | *ppbData = NULL;
|
---|
2150 | *pcbData = 0;
|
---|
2151 | *pcx = 0;
|
---|
2152 | *pcy = 0;
|
---|
2153 | *pfMemFree = true;
|
---|
2154 | rc = VINF_SUCCESS;
|
---|
2155 | }
|
---|
2156 | }
|
---|
2157 | else
|
---|
2158 | rc = VERR_INVALID_PARAMETER;
|
---|
2159 | return rc;
|
---|
2160 | }
|
---|
2161 |
|
---|
2162 | static int i_displayTakeScreenshot(PUVM pUVM, Display *pDisplay, struct DRVMAINDISPLAY *pDrv, ULONG aScreenId,
|
---|
2163 | BYTE *address, ULONG width, ULONG height)
|
---|
2164 | {
|
---|
2165 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
2166 | /*
|
---|
2167 | * CrOgl screenshot hook/hack.
|
---|
2168 | */
|
---|
2169 | if (Display::i_displayCheckTakeScreenshotCrOgl(pDisplay, aScreenId, (uint8_t *)address, width, height))
|
---|
2170 | return VINF_SUCCESS;
|
---|
2171 | #endif
|
---|
2172 |
|
---|
2173 | uint8_t *pbData = NULL;
|
---|
2174 | size_t cbData = 0;
|
---|
2175 | uint32_t cx = 0;
|
---|
2176 | uint32_t cy = 0;
|
---|
2177 | bool fFreeMem = false;
|
---|
2178 | int vrc = VINF_SUCCESS;
|
---|
2179 |
|
---|
2180 | int cRetries = 5;
|
---|
2181 | while (cRetries-- > 0)
|
---|
2182 | {
|
---|
2183 | /* Note! Not sure if the priority call is such a good idea here, but
|
---|
2184 | it would be nice to have an accurate screenshot for the bug
|
---|
2185 | report if the VM deadlocks. */
|
---|
2186 | vrc = VMR3ReqPriorityCallWaitU(pUVM, VMCPUID_ANY, (PFNRT)Display::i_displayTakeScreenshotEMT, 7,
|
---|
2187 | pDisplay, aScreenId, &pbData, &cbData, &cx, &cy, &fFreeMem);
|
---|
2188 | if (vrc != VERR_TRY_AGAIN)
|
---|
2189 | {
|
---|
2190 | break;
|
---|
2191 | }
|
---|
2192 |
|
---|
2193 | RTThreadSleep(10);
|
---|
2194 | }
|
---|
2195 |
|
---|
2196 | if (RT_SUCCESS(vrc) && pbData)
|
---|
2197 | {
|
---|
2198 | if (cx == width && cy == height)
|
---|
2199 | {
|
---|
2200 | /* No scaling required. */
|
---|
2201 | memcpy(address, pbData, cbData);
|
---|
2202 | }
|
---|
2203 | else
|
---|
2204 | {
|
---|
2205 | /* Scale. */
|
---|
2206 | LogRelFlowFunc(("SCALE: %dx%d -> %dx%d\n", cx, cy, width, height));
|
---|
2207 |
|
---|
2208 | uint8_t *dst = address;
|
---|
2209 | uint8_t *src = pbData;
|
---|
2210 | int dstW = width;
|
---|
2211 | int dstH = height;
|
---|
2212 | int srcW = cx;
|
---|
2213 | int srcH = cy;
|
---|
2214 | int iDeltaLine = cx * 4;
|
---|
2215 |
|
---|
2216 | BitmapScale32(dst,
|
---|
2217 | dstW, dstH,
|
---|
2218 | src,
|
---|
2219 | iDeltaLine,
|
---|
2220 | srcW, srcH);
|
---|
2221 | }
|
---|
2222 |
|
---|
2223 | if (fFreeMem)
|
---|
2224 | RTMemFree(pbData);
|
---|
2225 | else
|
---|
2226 | {
|
---|
2227 | /* This can be called from any thread. */
|
---|
2228 | pDrv->pUpPort->pfnFreeScreenshot(pDrv->pUpPort, pbData);
|
---|
2229 | }
|
---|
2230 | }
|
---|
2231 |
|
---|
2232 | return vrc;
|
---|
2233 | }
|
---|
2234 |
|
---|
2235 | HRESULT Display::takeScreenShotWorker(ULONG aScreenId,
|
---|
2236 | BYTE *aAddress,
|
---|
2237 | ULONG aWidth,
|
---|
2238 | ULONG aHeight,
|
---|
2239 | BitmapFormat_T aBitmapFormat,
|
---|
2240 | ULONG *pcbOut)
|
---|
2241 | {
|
---|
2242 | HRESULT rc = S_OK;
|
---|
2243 |
|
---|
2244 | /* Do not allow too small and too large screenshots. This also filters out negative
|
---|
2245 | * values passed as either 'aWidth' or 'aHeight'.
|
---|
2246 | */
|
---|
2247 | CheckComArgExpr(aWidth, aWidth != 0 && aWidth <= 32767);
|
---|
2248 | CheckComArgExpr(aHeight, aHeight != 0 && aHeight <= 32767);
|
---|
2249 |
|
---|
2250 | if ( aBitmapFormat != BitmapFormat_BGR0
|
---|
2251 | && aBitmapFormat != BitmapFormat_BGRA
|
---|
2252 | && aBitmapFormat != BitmapFormat_RGBA
|
---|
2253 | && aBitmapFormat != BitmapFormat_PNG)
|
---|
2254 | {
|
---|
2255 | return setError(E_NOTIMPL,
|
---|
2256 | tr("Unsupported screenshot format 0x%08X"), aBitmapFormat);
|
---|
2257 | }
|
---|
2258 |
|
---|
2259 | Console::SafeVMPtr ptrVM(mParent);
|
---|
2260 | if (!ptrVM.isOk())
|
---|
2261 | return ptrVM.rc();
|
---|
2262 |
|
---|
2263 | int vrc = i_displayTakeScreenshot(ptrVM.rawUVM(), this, mpDrv, aScreenId, aAddress, aWidth, aHeight);
|
---|
2264 |
|
---|
2265 | if (RT_SUCCESS(vrc))
|
---|
2266 | {
|
---|
2267 | const size_t cbData = aWidth * 4 * aHeight;
|
---|
2268 |
|
---|
2269 | /* Most of uncompressed formats. */
|
---|
2270 | *pcbOut = (ULONG)cbData;
|
---|
2271 |
|
---|
2272 | if (aBitmapFormat == BitmapFormat_BGR0)
|
---|
2273 | {
|
---|
2274 | /* Do nothing. */
|
---|
2275 | }
|
---|
2276 | else if (aBitmapFormat == BitmapFormat_BGRA)
|
---|
2277 | {
|
---|
2278 | uint32_t *pu32 = (uint32_t *)aAddress;
|
---|
2279 | size_t cPixels = aWidth * aHeight;
|
---|
2280 | while (cPixels--)
|
---|
2281 | {
|
---|
2282 | *pu32++ |= UINT32_C(0xFF000000);
|
---|
2283 | }
|
---|
2284 | }
|
---|
2285 | else if (aBitmapFormat == BitmapFormat_RGBA)
|
---|
2286 | {
|
---|
2287 | uint8_t *pu8 = aAddress;
|
---|
2288 | size_t cPixels = aWidth * aHeight;
|
---|
2289 | while (cPixels--)
|
---|
2290 | {
|
---|
2291 | uint8_t u8 = pu8[0];
|
---|
2292 | pu8[0] = pu8[2];
|
---|
2293 | pu8[2] = u8;
|
---|
2294 | pu8[3] = 0xFF;
|
---|
2295 |
|
---|
2296 | pu8 += 4;
|
---|
2297 | }
|
---|
2298 | }
|
---|
2299 | else if (aBitmapFormat == BitmapFormat_PNG)
|
---|
2300 | {
|
---|
2301 | uint8_t *pu8PNG = NULL;
|
---|
2302 | uint32_t cbPNG = 0;
|
---|
2303 | uint32_t cxPNG = 0;
|
---|
2304 | uint32_t cyPNG = 0;
|
---|
2305 |
|
---|
2306 | vrc = DisplayMakePNG(aAddress, aWidth, aHeight, &pu8PNG, &cbPNG, &cxPNG, &cyPNG, 0);
|
---|
2307 | if (RT_SUCCESS(vrc))
|
---|
2308 | {
|
---|
2309 | if (cbPNG <= cbData)
|
---|
2310 | {
|
---|
2311 | memcpy(aAddress, pu8PNG, cbPNG);
|
---|
2312 | *pcbOut = cbPNG;
|
---|
2313 | }
|
---|
2314 | else
|
---|
2315 | {
|
---|
2316 | rc = setError(E_FAIL,
|
---|
2317 | tr("PNG is larger than 32bpp bitmap"));
|
---|
2318 | }
|
---|
2319 | }
|
---|
2320 | else
|
---|
2321 | {
|
---|
2322 | rc = setError(VBOX_E_IPRT_ERROR,
|
---|
2323 | tr("Could not convert screenshot to PNG (%Rrc)"), vrc);
|
---|
2324 | }
|
---|
2325 | RTMemFree(pu8PNG);
|
---|
2326 | }
|
---|
2327 | }
|
---|
2328 | else if (vrc == VERR_TRY_AGAIN)
|
---|
2329 | rc = setError(E_UNEXPECTED,
|
---|
2330 | tr("Screenshot is not available at this time"));
|
---|
2331 | else if (RT_FAILURE(vrc))
|
---|
2332 | rc = setError(VBOX_E_IPRT_ERROR,
|
---|
2333 | tr("Could not take a screenshot (%Rrc)"), vrc);
|
---|
2334 |
|
---|
2335 | return rc;
|
---|
2336 | }
|
---|
2337 |
|
---|
2338 | HRESULT Display::takeScreenShot(ULONG aScreenId,
|
---|
2339 | BYTE *aAddress,
|
---|
2340 | ULONG aWidth,
|
---|
2341 | ULONG aHeight,
|
---|
2342 | BitmapFormat_T aBitmapFormat)
|
---|
2343 | {
|
---|
2344 | HRESULT rc = S_OK;
|
---|
2345 |
|
---|
2346 | LogRelFlowFunc(("[%d] address=%p, width=%d, height=%d, format 0x%08X\n",
|
---|
2347 | aScreenId, aAddress, aWidth, aHeight, aBitmapFormat));
|
---|
2348 |
|
---|
2349 | ULONG cbOut = 0;
|
---|
2350 | rc = takeScreenShotWorker(aScreenId, aAddress, aWidth, aHeight, aBitmapFormat, &cbOut);
|
---|
2351 | NOREF(cbOut);
|
---|
2352 |
|
---|
2353 | LogRelFlowFunc(("%Rhrc\n", rc));
|
---|
2354 | return rc;
|
---|
2355 | }
|
---|
2356 |
|
---|
2357 | HRESULT Display::takeScreenShotToArray(ULONG aScreenId,
|
---|
2358 | ULONG aWidth,
|
---|
2359 | ULONG aHeight,
|
---|
2360 | BitmapFormat_T aBitmapFormat,
|
---|
2361 | std::vector<BYTE> &aScreenData)
|
---|
2362 | {
|
---|
2363 | HRESULT rc = S_OK;
|
---|
2364 |
|
---|
2365 | LogRelFlowFunc(("[%d] width=%d, height=%d, format 0x%08X\n",
|
---|
2366 | aScreenId, aWidth, aHeight, aBitmapFormat));
|
---|
2367 |
|
---|
2368 | /* Do not allow too small and too large screenshots. This also filters out negative
|
---|
2369 | * values passed as either 'aWidth' or 'aHeight'.
|
---|
2370 | */
|
---|
2371 | CheckComArgExpr(aWidth, aWidth != 0 && aWidth <= 32767);
|
---|
2372 | CheckComArgExpr(aHeight, aHeight != 0 && aHeight <= 32767);
|
---|
2373 |
|
---|
2374 | const size_t cbData = aWidth * 4 * aHeight;
|
---|
2375 | aScreenData.resize(cbData);
|
---|
2376 |
|
---|
2377 | ULONG cbOut = 0;
|
---|
2378 | rc = takeScreenShotWorker(aScreenId, &aScreenData.front(), aWidth, aHeight, aBitmapFormat, &cbOut);
|
---|
2379 | if (FAILED(rc))
|
---|
2380 | cbOut = 0;
|
---|
2381 |
|
---|
2382 | aScreenData.resize(cbOut);
|
---|
2383 |
|
---|
2384 | LogRelFlowFunc(("%Rhrc\n", rc));
|
---|
2385 | return rc;
|
---|
2386 | }
|
---|
2387 |
|
---|
2388 | int Display::i_videoCaptureEnableScreens(ComSafeArrayIn(BOOL, aScreens))
|
---|
2389 | {
|
---|
2390 | #ifdef VBOX_WITH_VIDEOREC
|
---|
2391 | com::SafeArray<BOOL> Screens(ComSafeArrayInArg(aScreens));
|
---|
2392 | for (unsigned i = 0; i < Screens.size(); i++)
|
---|
2393 | {
|
---|
2394 | bool fChanged = maVideoRecEnabled[i] != RT_BOOL(Screens[i]);
|
---|
2395 |
|
---|
2396 | maVideoRecEnabled[i] = RT_BOOL(Screens[i]);
|
---|
2397 |
|
---|
2398 | if (fChanged && i < mcMonitors)
|
---|
2399 | videoCaptureScreenChanged(i);
|
---|
2400 |
|
---|
2401 | }
|
---|
2402 | return VINF_SUCCESS;
|
---|
2403 | #else
|
---|
2404 | ComSafeArrayNoRef(aScreens);
|
---|
2405 | return VERR_NOT_SUPPORTED;
|
---|
2406 | #endif
|
---|
2407 | }
|
---|
2408 |
|
---|
2409 | /**
|
---|
2410 | * Sends belonging audio samples to the video capturing code.
|
---|
2411 | * Does nothing if capturing is disabled or if audio support for video capturing is disabled.
|
---|
2412 | *
|
---|
2413 | * @returns IPRT status code.
|
---|
2414 | * @param pvData Audio data.
|
---|
2415 | * @param cbData Size (in bytes) of audio data.
|
---|
2416 | * @param uTimestampMs Timestamp (in ms) of the audio data.
|
---|
2417 | */
|
---|
2418 | int Display::i_videoCaptureSendAudio(const void *pvData, size_t cbData, uint64_t uTimestampMs)
|
---|
2419 | {
|
---|
2420 | #ifdef VBOX_WITH_AUDIO_VIDEOREC
|
---|
2421 | if (!VideoRecIsEnabled(mpVideoRecCtx))
|
---|
2422 | return VINF_SUCCESS;
|
---|
2423 |
|
---|
2424 | return VideoRecSendAudioFrame(mpVideoRecCtx, pvData, cbData, uTimestampMs);
|
---|
2425 | #else
|
---|
2426 | RT_NOREF(pvData, cbData, uTimestampMs);
|
---|
2427 | return VERR_NOT_SUPPORTED;
|
---|
2428 | #endif
|
---|
2429 | }
|
---|
2430 |
|
---|
2431 | /**
|
---|
2432 | * Start video capturing. Does nothing if capturing is already active.
|
---|
2433 | *
|
---|
2434 | * @returns IPRT status code.
|
---|
2435 | */
|
---|
2436 | int Display::i_videoCaptureStart(void)
|
---|
2437 | {
|
---|
2438 | #ifdef VBOX_WITH_VIDEOREC
|
---|
2439 | if (VideoRecIsEnabled(mpVideoRecCtx))
|
---|
2440 | return VINF_SUCCESS;
|
---|
2441 |
|
---|
2442 | int rc = VideoRecContextCreate(mcMonitors, &mpVideoRecCtx);
|
---|
2443 | if (RT_FAILURE(rc))
|
---|
2444 | {
|
---|
2445 | LogFlow(("Failed to create video recording context (%Rrc)!\n", rc));
|
---|
2446 | return rc;
|
---|
2447 | }
|
---|
2448 | ComPtr<IMachine> pMachine = mParent->i_machine();
|
---|
2449 | com::SafeArray<BOOL> screens;
|
---|
2450 | HRESULT hrc = pMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(screens));
|
---|
2451 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2452 | for (unsigned i = 0; i < RT_ELEMENTS(maVideoRecEnabled); i++)
|
---|
2453 | maVideoRecEnabled[i] = i < screens.size() && screens[i];
|
---|
2454 | ULONG ulWidth;
|
---|
2455 | hrc = pMachine->COMGETTER(VideoCaptureWidth)(&ulWidth);
|
---|
2456 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2457 | ULONG ulHeight;
|
---|
2458 | hrc = pMachine->COMGETTER(VideoCaptureHeight)(&ulHeight);
|
---|
2459 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2460 | ULONG ulRate;
|
---|
2461 | hrc = pMachine->COMGETTER(VideoCaptureRate)(&ulRate);
|
---|
2462 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2463 | ULONG ulFPS;
|
---|
2464 | hrc = pMachine->COMGETTER(VideoCaptureFPS)(&ulFPS);
|
---|
2465 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2466 | BSTR strFile;
|
---|
2467 | hrc = pMachine->COMGETTER(VideoCaptureFile)(&strFile);
|
---|
2468 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2469 | ULONG ulMaxTime;
|
---|
2470 | hrc = pMachine->COMGETTER(VideoCaptureMaxTime)(&ulMaxTime);
|
---|
2471 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2472 | ULONG ulMaxSize;
|
---|
2473 | hrc = pMachine->COMGETTER(VideoCaptureMaxFileSize)(&ulMaxSize);
|
---|
2474 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2475 | BSTR strOptions;
|
---|
2476 | hrc = pMachine->COMGETTER(VideoCaptureOptions)(&strOptions);
|
---|
2477 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
2478 |
|
---|
2479 | RTTIMESPEC ts;
|
---|
2480 | RTTimeNow(&ts);
|
---|
2481 | RTTIME time;
|
---|
2482 | RTTimeExplode(&time, &ts);
|
---|
2483 | for (unsigned uScreen = 0; uScreen < mcMonitors; uScreen++)
|
---|
2484 | {
|
---|
2485 | char *pszAbsPath = RTPathAbsDup(com::Utf8Str(strFile).c_str());
|
---|
2486 | char *pszSuff = RTPathSuffix(pszAbsPath);
|
---|
2487 | if (pszSuff)
|
---|
2488 | pszSuff = RTStrDup(pszSuff);
|
---|
2489 | RTPathStripSuffix(pszAbsPath);
|
---|
2490 | if (!pszAbsPath)
|
---|
2491 | rc = VERR_INVALID_PARAMETER;
|
---|
2492 | if (!pszSuff)
|
---|
2493 | pszSuff = RTStrDup(".webm");
|
---|
2494 | char *pszName = NULL;
|
---|
2495 | if (RT_SUCCESS(rc))
|
---|
2496 | {
|
---|
2497 | if (mcMonitors > 1)
|
---|
2498 | rc = RTStrAPrintf(&pszName, "%s-%u%s", pszAbsPath, uScreen+1, pszSuff);
|
---|
2499 | else
|
---|
2500 | rc = RTStrAPrintf(&pszName, "%s%s", pszAbsPath, pszSuff);
|
---|
2501 | }
|
---|
2502 | if (RT_SUCCESS(rc))
|
---|
2503 | {
|
---|
2504 | rc = VideoRecStreamInit(mpVideoRecCtx, uScreen,
|
---|
2505 | pszName, ulWidth, ulHeight,
|
---|
2506 | ulRate, ulFPS, ulMaxTime,
|
---|
2507 | ulMaxSize, com::Utf8Str(strOptions).c_str());
|
---|
2508 | if (rc == VERR_ALREADY_EXISTS)
|
---|
2509 | {
|
---|
2510 | RTStrFree(pszName);
|
---|
2511 | pszName = NULL;
|
---|
2512 |
|
---|
2513 | if (mcMonitors > 1)
|
---|
2514 | rc = RTStrAPrintf(&pszName, "%s-%04d-%02u-%02uT%02u-%02u-%02u-%09uZ-%u%s",
|
---|
2515 | pszAbsPath, time.i32Year, time.u8Month, time.u8MonthDay,
|
---|
2516 | time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond,
|
---|
2517 | uScreen+1, pszSuff);
|
---|
2518 | else
|
---|
2519 | rc = RTStrAPrintf(&pszName, "%s-%04d-%02u-%02uT%02u-%02u-%02u-%09uZ%s",
|
---|
2520 | pszAbsPath, time.i32Year, time.u8Month, time.u8MonthDay,
|
---|
2521 | time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond,
|
---|
2522 | pszSuff);
|
---|
2523 | if (RT_SUCCESS(rc))
|
---|
2524 | rc = VideoRecStreamInit(mpVideoRecCtx, uScreen,
|
---|
2525 | pszName, ulWidth, ulHeight, ulRate,
|
---|
2526 | ulFPS, ulMaxTime,
|
---|
2527 | ulMaxSize, com::Utf8Str(strOptions).c_str());
|
---|
2528 | }
|
---|
2529 | }
|
---|
2530 |
|
---|
2531 | if (RT_SUCCESS(rc))
|
---|
2532 | {
|
---|
2533 | videoCaptureScreenChanged(uScreen);
|
---|
2534 | }
|
---|
2535 | else
|
---|
2536 | LogRel(("Display::VideoCaptureStart: Failed to initialize video recording context #%u, (%Rrc)\n", uScreen, rc));
|
---|
2537 |
|
---|
2538 | RTStrFree(pszName);
|
---|
2539 | RTStrFree(pszSuff);
|
---|
2540 | RTStrFree(pszAbsPath);
|
---|
2541 | }
|
---|
2542 | return rc;
|
---|
2543 | #else /* VBOX_WITH_VIDEOREC */
|
---|
2544 | return VERR_NOT_SUPPORTED;
|
---|
2545 | #endif
|
---|
2546 | }
|
---|
2547 |
|
---|
2548 | /**
|
---|
2549 | * Stop video capturing. Does nothing if video capturing is not active.
|
---|
2550 | */
|
---|
2551 | void Display::i_videoCaptureStop()
|
---|
2552 | {
|
---|
2553 | #ifdef VBOX_WITH_VIDEOREC
|
---|
2554 | if (!VideoRecIsEnabled(mpVideoRecCtx))
|
---|
2555 | return;
|
---|
2556 |
|
---|
2557 | VideoRecContextDestroy(mpVideoRecCtx);
|
---|
2558 | mpVideoRecCtx = NULL;
|
---|
2559 |
|
---|
2560 | unsigned uScreenId;
|
---|
2561 | for (uScreenId = 0; uScreenId < mcMonitors; ++uScreenId)
|
---|
2562 | videoCaptureScreenChanged(uScreenId);
|
---|
2563 | #endif
|
---|
2564 | }
|
---|
2565 |
|
---|
2566 | #ifdef VBOX_WITH_VIDEOREC
|
---|
2567 | void Display::videoCaptureScreenChanged(unsigned uScreenId)
|
---|
2568 | {
|
---|
2569 | if ( !VideoRecIsEnabled(mpVideoRecCtx)
|
---|
2570 | || !maVideoRecEnabled[uScreenId])
|
---|
2571 | {
|
---|
2572 | /* Skip recording this screen. */
|
---|
2573 | return;
|
---|
2574 | }
|
---|
2575 |
|
---|
2576 | /* Get a new source bitmap which will be used by video capture code. */
|
---|
2577 | ComPtr<IDisplaySourceBitmap> pSourceBitmap;
|
---|
2578 | QuerySourceBitmap(uScreenId, pSourceBitmap.asOutParam());
|
---|
2579 |
|
---|
2580 | int rc2 = RTCritSectEnter(&mVideoCaptureLock);
|
---|
2581 | if (RT_SUCCESS(rc2))
|
---|
2582 | {
|
---|
2583 | maFramebuffers[uScreenId].videoCapture.pSourceBitmap = pSourceBitmap;
|
---|
2584 |
|
---|
2585 | rc2 = RTCritSectLeave(&mVideoCaptureLock);
|
---|
2586 | AssertRC(rc2);
|
---|
2587 | }
|
---|
2588 | }
|
---|
2589 | #endif /* VBOX_WITH_VIDEOREC */
|
---|
2590 |
|
---|
2591 | int Display::i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address,
|
---|
2592 | ULONG x, ULONG y, ULONG width, ULONG height)
|
---|
2593 | {
|
---|
2594 | int rc = VINF_SUCCESS;
|
---|
2595 |
|
---|
2596 | DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[aScreenId];
|
---|
2597 |
|
---|
2598 | if (aScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
|
---|
2599 | {
|
---|
2600 | rc = pDisplay->mpDrv->pUpPort->pfnDisplayBlt(pDisplay->mpDrv->pUpPort, address, x, y, width, height);
|
---|
2601 | }
|
---|
2602 | else if (aScreenId < pDisplay->mcMonitors)
|
---|
2603 | {
|
---|
2604 | /* Copy the bitmap to the guest VRAM. */
|
---|
2605 | const uint8_t *pu8Src = address;
|
---|
2606 | int32_t xSrc = 0;
|
---|
2607 | int32_t ySrc = 0;
|
---|
2608 | uint32_t u32SrcWidth = width;
|
---|
2609 | uint32_t u32SrcHeight = height;
|
---|
2610 | uint32_t u32SrcLineSize = width * 4;
|
---|
2611 | uint32_t u32SrcBitsPerPixel = 32;
|
---|
2612 |
|
---|
2613 | uint8_t *pu8Dst = pFBInfo->pu8FramebufferVRAM;
|
---|
2614 | int32_t xDst = x;
|
---|
2615 | int32_t yDst = y;
|
---|
2616 | uint32_t u32DstWidth = pFBInfo->w;
|
---|
2617 | uint32_t u32DstHeight = pFBInfo->h;
|
---|
2618 | uint32_t u32DstLineSize = pFBInfo->u32LineSize;
|
---|
2619 | uint32_t u32DstBitsPerPixel = pFBInfo->u16BitsPerPixel;
|
---|
2620 |
|
---|
2621 | rc = pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
|
---|
2622 | width, height,
|
---|
2623 | pu8Src,
|
---|
2624 | xSrc, ySrc,
|
---|
2625 | u32SrcWidth, u32SrcHeight,
|
---|
2626 | u32SrcLineSize, u32SrcBitsPerPixel,
|
---|
2627 | pu8Dst,
|
---|
2628 | xDst, yDst,
|
---|
2629 | u32DstWidth, u32DstHeight,
|
---|
2630 | u32DstLineSize, u32DstBitsPerPixel);
|
---|
2631 | if (RT_SUCCESS(rc))
|
---|
2632 | {
|
---|
2633 | if (!pFBInfo->pSourceBitmap.isNull())
|
---|
2634 | {
|
---|
2635 | /* Update the changed screen area. When source bitmap uses VRAM directly, just notify
|
---|
2636 | * frontend to update. And for default format, render the guest VRAM to the source bitmap.
|
---|
2637 | */
|
---|
2638 | if ( pFBInfo->fDefaultFormat
|
---|
2639 | && !pFBInfo->fDisabled)
|
---|
2640 | {
|
---|
2641 | BYTE *pAddress = NULL;
|
---|
2642 | ULONG ulWidth = 0;
|
---|
2643 | ULONG ulHeight = 0;
|
---|
2644 | ULONG ulBitsPerPixel = 0;
|
---|
2645 | ULONG ulBytesPerLine = 0;
|
---|
2646 | BitmapFormat_T bitmapFormat = BitmapFormat_Opaque;
|
---|
2647 |
|
---|
2648 | HRESULT hrc = pFBInfo->pSourceBitmap->QueryBitmapInfo(&pAddress,
|
---|
2649 | &ulWidth,
|
---|
2650 | &ulHeight,
|
---|
2651 | &ulBitsPerPixel,
|
---|
2652 | &ulBytesPerLine,
|
---|
2653 | &bitmapFormat);
|
---|
2654 | if (SUCCEEDED(hrc))
|
---|
2655 | {
|
---|
2656 | pu8Src = pFBInfo->pu8FramebufferVRAM;
|
---|
2657 | xSrc = x;
|
---|
2658 | ySrc = y;
|
---|
2659 | u32SrcWidth = pFBInfo->w;
|
---|
2660 | u32SrcHeight = pFBInfo->h;
|
---|
2661 | u32SrcLineSize = pFBInfo->u32LineSize;
|
---|
2662 | u32SrcBitsPerPixel = pFBInfo->u16BitsPerPixel;
|
---|
2663 |
|
---|
2664 | /* Default format is 32 bpp. */
|
---|
2665 | pu8Dst = pAddress;
|
---|
2666 | xDst = xSrc;
|
---|
2667 | yDst = ySrc;
|
---|
2668 | u32DstWidth = u32SrcWidth;
|
---|
2669 | u32DstHeight = u32SrcHeight;
|
---|
2670 | u32DstLineSize = u32DstWidth * 4;
|
---|
2671 | u32DstBitsPerPixel = 32;
|
---|
2672 |
|
---|
2673 | pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
|
---|
2674 | width, height,
|
---|
2675 | pu8Src,
|
---|
2676 | xSrc, ySrc,
|
---|
2677 | u32SrcWidth, u32SrcHeight,
|
---|
2678 | u32SrcLineSize, u32SrcBitsPerPixel,
|
---|
2679 | pu8Dst,
|
---|
2680 | xDst, yDst,
|
---|
2681 | u32DstWidth, u32DstHeight,
|
---|
2682 | u32DstLineSize, u32DstBitsPerPixel);
|
---|
2683 | }
|
---|
2684 | }
|
---|
2685 | }
|
---|
2686 |
|
---|
2687 | pDisplay->i_handleDisplayUpdate(aScreenId, x, y, width, height);
|
---|
2688 | }
|
---|
2689 | }
|
---|
2690 | else
|
---|
2691 | {
|
---|
2692 | rc = VERR_INVALID_PARAMETER;
|
---|
2693 | }
|
---|
2694 |
|
---|
2695 | if (RT_SUCCESS(rc))
|
---|
2696 | pDisplay->mParent->i_consoleVRDPServer()->SendUpdateBitmap(aScreenId, x, y, width, height);
|
---|
2697 |
|
---|
2698 | return rc;
|
---|
2699 | }
|
---|
2700 |
|
---|
2701 | HRESULT Display::drawToScreen(ULONG aScreenId, BYTE *aAddress, ULONG aX, ULONG aY, ULONG aWidth, ULONG aHeight)
|
---|
2702 | {
|
---|
2703 | /// @todo (r=dmik) this function may take too long to complete if the VM
|
---|
2704 | // is doing something like saving state right now. Which, in case if it
|
---|
2705 | // is called on the GUI thread, will make it unresponsive. We should
|
---|
2706 | // check the machine state here (by enclosing the check and VMRequCall
|
---|
2707 | // within the Console lock to make it atomic).
|
---|
2708 |
|
---|
2709 | LogRelFlowFunc(("aAddress=%p, x=%d, y=%d, width=%d, height=%d\n",
|
---|
2710 | (void *)aAddress, aX, aY, aWidth, aHeight));
|
---|
2711 |
|
---|
2712 | CheckComArgExpr(aWidth, aWidth != 0);
|
---|
2713 | CheckComArgExpr(aHeight, aHeight != 0);
|
---|
2714 |
|
---|
2715 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
2716 |
|
---|
2717 | CHECK_CONSOLE_DRV(mpDrv);
|
---|
2718 |
|
---|
2719 | Console::SafeVMPtr ptrVM(mParent);
|
---|
2720 | if (!ptrVM.isOk())
|
---|
2721 | return ptrVM.rc();
|
---|
2722 |
|
---|
2723 | /* Release lock because the call scheduled on EMT may also try to take it. */
|
---|
2724 | alock.release();
|
---|
2725 |
|
---|
2726 | /*
|
---|
2727 | * Again we're lazy and make the graphics device do all the
|
---|
2728 | * dirty conversion work.
|
---|
2729 | */
|
---|
2730 | int rcVBox = VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_drawToScreenEMT, 7,
|
---|
2731 | this, aScreenId, aAddress, aX, aY, aWidth, aHeight);
|
---|
2732 |
|
---|
2733 | /*
|
---|
2734 | * If the function returns not supported, we'll have to do all the
|
---|
2735 | * work ourselves using the framebuffer.
|
---|
2736 | */
|
---|
2737 | HRESULT rc = S_OK;
|
---|
2738 | if (rcVBox == VERR_NOT_SUPPORTED || rcVBox == VERR_NOT_IMPLEMENTED)
|
---|
2739 | {
|
---|
2740 | /** @todo implement generic fallback for screen blitting. */
|
---|
2741 | rc = E_NOTIMPL;
|
---|
2742 | }
|
---|
2743 | else if (RT_FAILURE(rcVBox))
|
---|
2744 | rc = setError(VBOX_E_IPRT_ERROR,
|
---|
2745 | tr("Could not draw to the screen (%Rrc)"), rcVBox);
|
---|
2746 | /// @todo
|
---|
2747 | // else
|
---|
2748 | // {
|
---|
2749 | // /* All ok. Redraw the screen. */
|
---|
2750 | // handleDisplayUpdate(x, y, width, height);
|
---|
2751 | // }
|
---|
2752 |
|
---|
2753 | LogRelFlowFunc(("rc=%Rhrc\n", rc));
|
---|
2754 | return rc;
|
---|
2755 | }
|
---|
2756 |
|
---|
2757 | int Display::i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll)
|
---|
2758 | {
|
---|
2759 | LogRelFlowFunc(("uId=%d, fUpdateAll %d\n", uId, fUpdateAll));
|
---|
2760 |
|
---|
2761 | unsigned uScreenId;
|
---|
2762 | for (uScreenId = (fUpdateAll ? 0 : uId); uScreenId < pDisplay->mcMonitors; uScreenId++)
|
---|
2763 | {
|
---|
2764 | DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
|
---|
2765 |
|
---|
2766 | if ( !pFBInfo->fVBVAEnabled
|
---|
2767 | && uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
|
---|
2768 | {
|
---|
2769 | pDisplay->mpDrv->pUpPort->pfnUpdateDisplayAll(pDisplay->mpDrv->pUpPort, /* fFailOnResize = */ true);
|
---|
2770 | }
|
---|
2771 | else
|
---|
2772 | {
|
---|
2773 | if (!pFBInfo->fDisabled)
|
---|
2774 | {
|
---|
2775 | /* Render complete VRAM screen to the framebuffer.
|
---|
2776 | * When framebuffer uses VRAM directly, just notify it to update.
|
---|
2777 | */
|
---|
2778 | if (pFBInfo->fDefaultFormat && !pFBInfo->pSourceBitmap.isNull())
|
---|
2779 | {
|
---|
2780 | BYTE *pAddress = NULL;
|
---|
2781 | ULONG ulWidth = 0;
|
---|
2782 | ULONG ulHeight = 0;
|
---|
2783 | ULONG ulBitsPerPixel = 0;
|
---|
2784 | ULONG ulBytesPerLine = 0;
|
---|
2785 | BitmapFormat_T bitmapFormat = BitmapFormat_Opaque;
|
---|
2786 |
|
---|
2787 | HRESULT hrc = pFBInfo->pSourceBitmap->QueryBitmapInfo(&pAddress,
|
---|
2788 | &ulWidth,
|
---|
2789 | &ulHeight,
|
---|
2790 | &ulBitsPerPixel,
|
---|
2791 | &ulBytesPerLine,
|
---|
2792 | &bitmapFormat);
|
---|
2793 | if (SUCCEEDED(hrc))
|
---|
2794 | {
|
---|
2795 | uint32_t width = pFBInfo->w;
|
---|
2796 | uint32_t height = pFBInfo->h;
|
---|
2797 |
|
---|
2798 | const uint8_t *pu8Src = pFBInfo->pu8FramebufferVRAM;
|
---|
2799 | int32_t xSrc = 0;
|
---|
2800 | int32_t ySrc = 0;
|
---|
2801 | uint32_t u32SrcWidth = pFBInfo->w;
|
---|
2802 | uint32_t u32SrcHeight = pFBInfo->h;
|
---|
2803 | uint32_t u32SrcLineSize = pFBInfo->u32LineSize;
|
---|
2804 | uint32_t u32SrcBitsPerPixel = pFBInfo->u16BitsPerPixel;
|
---|
2805 |
|
---|
2806 | /* Default format is 32 bpp. */
|
---|
2807 | uint8_t *pu8Dst = pAddress;
|
---|
2808 | int32_t xDst = xSrc;
|
---|
2809 | int32_t yDst = ySrc;
|
---|
2810 | uint32_t u32DstWidth = u32SrcWidth;
|
---|
2811 | uint32_t u32DstHeight = u32SrcHeight;
|
---|
2812 | uint32_t u32DstLineSize = u32DstWidth * 4;
|
---|
2813 | uint32_t u32DstBitsPerPixel = 32;
|
---|
2814 |
|
---|
2815 | /* if uWidth != pFBInfo->w and uHeight != pFBInfo->h
|
---|
2816 | * implies resize of Framebuffer is in progress and
|
---|
2817 | * copyrect should not be called.
|
---|
2818 | */
|
---|
2819 | if (ulWidth == pFBInfo->w && ulHeight == pFBInfo->h)
|
---|
2820 | {
|
---|
2821 | pDisplay->mpDrv->pUpPort->pfnCopyRect(pDisplay->mpDrv->pUpPort,
|
---|
2822 | width, height,
|
---|
2823 | pu8Src,
|
---|
2824 | xSrc, ySrc,
|
---|
2825 | u32SrcWidth, u32SrcHeight,
|
---|
2826 | u32SrcLineSize, u32SrcBitsPerPixel,
|
---|
2827 | pu8Dst,
|
---|
2828 | xDst, yDst,
|
---|
2829 | u32DstWidth, u32DstHeight,
|
---|
2830 | u32DstLineSize, u32DstBitsPerPixel);
|
---|
2831 | }
|
---|
2832 | }
|
---|
2833 | }
|
---|
2834 |
|
---|
2835 | pDisplay->i_handleDisplayUpdate(uScreenId, 0, 0, pFBInfo->w, pFBInfo->h);
|
---|
2836 | }
|
---|
2837 | }
|
---|
2838 | if (!fUpdateAll)
|
---|
2839 | break;
|
---|
2840 | }
|
---|
2841 | LogRelFlowFunc(("done\n"));
|
---|
2842 | return VINF_SUCCESS;
|
---|
2843 | }
|
---|
2844 |
|
---|
2845 | /**
|
---|
2846 | * Does a full invalidation of the VM display and instructs the VM
|
---|
2847 | * to update it immediately.
|
---|
2848 | *
|
---|
2849 | * @returns COM status code
|
---|
2850 | */
|
---|
2851 |
|
---|
2852 | HRESULT Display::invalidateAndUpdate()
|
---|
2853 | {
|
---|
2854 | LogRelFlowFunc(("\n"));
|
---|
2855 |
|
---|
2856 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
2857 |
|
---|
2858 | CHECK_CONSOLE_DRV(mpDrv);
|
---|
2859 |
|
---|
2860 | Console::SafeVMPtr ptrVM(mParent);
|
---|
2861 | if (!ptrVM.isOk())
|
---|
2862 | return ptrVM.rc();
|
---|
2863 |
|
---|
2864 | HRESULT rc = S_OK;
|
---|
2865 |
|
---|
2866 | LogRelFlowFunc(("Sending DPYUPDATE request\n"));
|
---|
2867 |
|
---|
2868 | /* Have to release the lock when calling EMT. */
|
---|
2869 | alock.release();
|
---|
2870 |
|
---|
2871 | int rcVBox = VMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
|
---|
2872 | 3, this, 0, true);
|
---|
2873 | alock.acquire();
|
---|
2874 |
|
---|
2875 | if (RT_FAILURE(rcVBox))
|
---|
2876 | rc = setError(VBOX_E_IPRT_ERROR,
|
---|
2877 | tr("Could not invalidate and update the screen (%Rrc)"), rcVBox);
|
---|
2878 |
|
---|
2879 | LogRelFlowFunc(("rc=%Rhrc\n", rc));
|
---|
2880 | return rc;
|
---|
2881 | }
|
---|
2882 |
|
---|
2883 | HRESULT Display::invalidateAndUpdateScreen(ULONG aScreenId)
|
---|
2884 | {
|
---|
2885 | LogRelFlowFunc(("\n"));
|
---|
2886 |
|
---|
2887 | HRESULT rc = S_OK;
|
---|
2888 |
|
---|
2889 | Console::SafeVMPtr ptrVM(mParent);
|
---|
2890 | if (!ptrVM.isOk())
|
---|
2891 | return ptrVM.rc();
|
---|
2892 |
|
---|
2893 | int rcVBox = VMR3ReqCallNoWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
|
---|
2894 | 3, this, aScreenId, false);
|
---|
2895 | if (RT_FAILURE(rcVBox))
|
---|
2896 | rc = setError(VBOX_E_IPRT_ERROR,
|
---|
2897 | tr("Could not invalidate and update the screen %d (%Rrc)"), aScreenId, rcVBox);
|
---|
2898 |
|
---|
2899 | LogRelFlowFunc(("rc=%Rhrc\n", rc));
|
---|
2900 | return rc;
|
---|
2901 | }
|
---|
2902 |
|
---|
2903 | HRESULT Display::completeVHWACommand(BYTE *aCommand)
|
---|
2904 | {
|
---|
2905 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
2906 | mpDrv->pVBVACallbacks->pfnVHWACommandCompleteAsync(mpDrv->pVBVACallbacks, (PVBOXVHWACMD)aCommand);
|
---|
2907 | return S_OK;
|
---|
2908 | #else
|
---|
2909 | return E_NOTIMPL;
|
---|
2910 | #endif
|
---|
2911 | }
|
---|
2912 |
|
---|
2913 | HRESULT Display::viewportChanged(ULONG aScreenId, ULONG aX, ULONG aY, ULONG aWidth, ULONG aHeight)
|
---|
2914 | {
|
---|
2915 | AssertMsgReturn(aScreenId < mcMonitors, ("aScreendId=%d mcMonitors=%d\n", aScreenId, mcMonitors), E_INVALIDARG);
|
---|
2916 |
|
---|
2917 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
2918 | if (mfIsCr3DEnabled)
|
---|
2919 | {
|
---|
2920 | int rc = i_crViewportNotify(aScreenId, aX, aY, aWidth, aHeight);
|
---|
2921 | if (RT_FAILURE(rc))
|
---|
2922 | {
|
---|
2923 | DISPLAYFBINFO *pFb = &maFramebuffers[aScreenId];
|
---|
2924 | pFb->pendingViewportInfo.fPending = true;
|
---|
2925 | pFb->pendingViewportInfo.x = aX;
|
---|
2926 | pFb->pendingViewportInfo.y = aY;
|
---|
2927 | pFb->pendingViewportInfo.width = aWidth;
|
---|
2928 | pFb->pendingViewportInfo.height = aHeight;
|
---|
2929 | }
|
---|
2930 | }
|
---|
2931 | #endif /* VBOX_WITH_CROGL && VBOX_WITH_HGCM */
|
---|
2932 |
|
---|
2933 | /* The driver might not have been constructed yet */
|
---|
2934 | if (mpDrv && mpDrv->pUpPort->pfnSetViewport)
|
---|
2935 | mpDrv->pUpPort->pfnSetViewport(mpDrv->pUpPort, aScreenId, aX, aY, aWidth, aHeight);
|
---|
2936 |
|
---|
2937 | return S_OK;
|
---|
2938 | }
|
---|
2939 |
|
---|
2940 | HRESULT Display::querySourceBitmap(ULONG aScreenId,
|
---|
2941 | ComPtr<IDisplaySourceBitmap> &aDisplaySourceBitmap)
|
---|
2942 | {
|
---|
2943 | LogRelFlowFunc(("aScreenId = %d\n", aScreenId));
|
---|
2944 |
|
---|
2945 | Console::SafeVMPtr ptrVM(mParent);
|
---|
2946 | if (!ptrVM.isOk())
|
---|
2947 | return ptrVM.rc();
|
---|
2948 |
|
---|
2949 | bool fSetRenderVRAM = false;
|
---|
2950 | bool fInvalidate = false;
|
---|
2951 |
|
---|
2952 | AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
2953 |
|
---|
2954 | if (aScreenId >= mcMonitors)
|
---|
2955 | return setError(E_INVALIDARG, tr("QuerySourceBitmap: Invalid screen %d (total %d)"),
|
---|
2956 | aScreenId, mcMonitors);
|
---|
2957 |
|
---|
2958 | if (!mfSourceBitmapEnabled)
|
---|
2959 | {
|
---|
2960 | aDisplaySourceBitmap = NULL;
|
---|
2961 | return E_FAIL;
|
---|
2962 | }
|
---|
2963 |
|
---|
2964 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[aScreenId];
|
---|
2965 |
|
---|
2966 | /* No source bitmap for a blank guest screen. */
|
---|
2967 | if (pFBInfo->flags & VBVA_SCREEN_F_BLANK)
|
---|
2968 | {
|
---|
2969 | aDisplaySourceBitmap = NULL;
|
---|
2970 | return E_FAIL;
|
---|
2971 | }
|
---|
2972 |
|
---|
2973 | HRESULT hr = S_OK;
|
---|
2974 |
|
---|
2975 | if (pFBInfo->pSourceBitmap.isNull())
|
---|
2976 | {
|
---|
2977 | /* Create a new object. */
|
---|
2978 | ComObjPtr<DisplaySourceBitmap> obj;
|
---|
2979 | hr = obj.createObject();
|
---|
2980 | if (SUCCEEDED(hr))
|
---|
2981 | hr = obj->init(this, aScreenId, pFBInfo);
|
---|
2982 |
|
---|
2983 | if (SUCCEEDED(hr))
|
---|
2984 | {
|
---|
2985 | pFBInfo->pSourceBitmap = obj;
|
---|
2986 | pFBInfo->fDefaultFormat = !obj->i_usesVRAM();
|
---|
2987 |
|
---|
2988 | if (aScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
|
---|
2989 | {
|
---|
2990 | /* Start buffer updates. */
|
---|
2991 | BYTE *pAddress = NULL;
|
---|
2992 | ULONG ulWidth = 0;
|
---|
2993 | ULONG ulHeight = 0;
|
---|
2994 | ULONG ulBitsPerPixel = 0;
|
---|
2995 | ULONG ulBytesPerLine = 0;
|
---|
2996 | BitmapFormat_T bitmapFormat = BitmapFormat_Opaque;
|
---|
2997 |
|
---|
2998 | pFBInfo->pSourceBitmap->QueryBitmapInfo(&pAddress,
|
---|
2999 | &ulWidth,
|
---|
3000 | &ulHeight,
|
---|
3001 | &ulBitsPerPixel,
|
---|
3002 | &ulBytesPerLine,
|
---|
3003 | &bitmapFormat);
|
---|
3004 |
|
---|
3005 | mpDrv->IConnector.pbData = pAddress;
|
---|
3006 | mpDrv->IConnector.cbScanline = ulBytesPerLine;
|
---|
3007 | mpDrv->IConnector.cBits = ulBitsPerPixel;
|
---|
3008 | mpDrv->IConnector.cx = ulWidth;
|
---|
3009 | mpDrv->IConnector.cy = ulHeight;
|
---|
3010 |
|
---|
3011 | fSetRenderVRAM = pFBInfo->fDefaultFormat;
|
---|
3012 | }
|
---|
3013 |
|
---|
3014 | /* Make sure that the bitmap contains the latest image. */
|
---|
3015 | fInvalidate = pFBInfo->fDefaultFormat;
|
---|
3016 | }
|
---|
3017 | }
|
---|
3018 |
|
---|
3019 | if (SUCCEEDED(hr))
|
---|
3020 | {
|
---|
3021 | pFBInfo->pSourceBitmap.queryInterfaceTo(aDisplaySourceBitmap.asOutParam());
|
---|
3022 | }
|
---|
3023 |
|
---|
3024 | /* Leave the IDisplay lock because the VGA device must not be called under it. */
|
---|
3025 | alock.release();
|
---|
3026 |
|
---|
3027 | if (SUCCEEDED(hr))
|
---|
3028 | {
|
---|
3029 | if (fSetRenderVRAM)
|
---|
3030 | {
|
---|
3031 | mpDrv->pUpPort->pfnSetRenderVRAM(mpDrv->pUpPort, true);
|
---|
3032 | }
|
---|
3033 |
|
---|
3034 | if (fInvalidate)
|
---|
3035 | VMR3ReqCallWaitU(ptrVM.rawUVM(), VMCPUID_ANY, (PFNRT)Display::i_InvalidateAndUpdateEMT,
|
---|
3036 | 3, this, aScreenId, false);
|
---|
3037 | }
|
---|
3038 |
|
---|
3039 | LogRelFlowFunc(("%Rhrc\n", hr));
|
---|
3040 | return hr;
|
---|
3041 | }
|
---|
3042 |
|
---|
3043 | HRESULT Display::getGuestScreenLayout(std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenLayout)
|
---|
3044 | {
|
---|
3045 | NOREF(aGuestScreenLayout);
|
---|
3046 | return E_NOTIMPL;
|
---|
3047 | }
|
---|
3048 |
|
---|
3049 | HRESULT Display::setScreenLayout(ScreenLayoutMode_T aScreenLayoutMode,
|
---|
3050 | const std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenInfo)
|
---|
3051 | {
|
---|
3052 | NOREF(aScreenLayoutMode);
|
---|
3053 | NOREF(aGuestScreenInfo);
|
---|
3054 | return E_NOTIMPL;
|
---|
3055 | }
|
---|
3056 |
|
---|
3057 | // wrapped IEventListener method
|
---|
3058 | HRESULT Display::handleEvent(const ComPtr<IEvent> &aEvent)
|
---|
3059 | {
|
---|
3060 | VBoxEventType_T aType = VBoxEventType_Invalid;
|
---|
3061 |
|
---|
3062 | aEvent->COMGETTER(Type)(&aType);
|
---|
3063 | switch (aType)
|
---|
3064 | {
|
---|
3065 | case VBoxEventType_OnStateChanged:
|
---|
3066 | {
|
---|
3067 | ComPtr<IStateChangedEvent> scev = aEvent;
|
---|
3068 | Assert(scev);
|
---|
3069 | MachineState_T machineState;
|
---|
3070 | scev->COMGETTER(State)(&machineState);
|
---|
3071 | if ( machineState == MachineState_Running
|
---|
3072 | || machineState == MachineState_Teleporting
|
---|
3073 | || machineState == MachineState_LiveSnapshotting
|
---|
3074 | || machineState == MachineState_DeletingSnapshotOnline
|
---|
3075 | )
|
---|
3076 | {
|
---|
3077 | LogRelFlowFunc(("Machine is running.\n"));
|
---|
3078 |
|
---|
3079 | #ifdef VBOX_WITH_CROGL
|
---|
3080 | i_crOglWindowsShow(true);
|
---|
3081 | #endif
|
---|
3082 | }
|
---|
3083 | else
|
---|
3084 | {
|
---|
3085 | #ifdef VBOX_WITH_CROGL
|
---|
3086 | if (machineState == MachineState_Paused)
|
---|
3087 | i_crOglWindowsShow(false);
|
---|
3088 | #endif
|
---|
3089 | }
|
---|
3090 | break;
|
---|
3091 | }
|
---|
3092 | default:
|
---|
3093 | AssertFailed();
|
---|
3094 | }
|
---|
3095 |
|
---|
3096 | return S_OK;
|
---|
3097 | }
|
---|
3098 |
|
---|
3099 |
|
---|
3100 | // private methods
|
---|
3101 | /////////////////////////////////////////////////////////////////////////////
|
---|
3102 |
|
---|
3103 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
3104 | int Display::i_crViewportNotify(ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height)
|
---|
3105 | {
|
---|
3106 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
3107 | if (!pVMMDev)
|
---|
3108 | return VERR_INVALID_STATE;
|
---|
3109 |
|
---|
3110 | size_t cbData = RT_UOFFSETOF(VBOXCRCMDCTL_HGCM, aParms[5]);
|
---|
3111 | VBOXCRCMDCTL_HGCM *pData = (VBOXCRCMDCTL_HGCM *)alloca(cbData);
|
---|
3112 |
|
---|
3113 | pData->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
3114 | pData->Hdr.u32Function = SHCRGL_HOST_FN_VIEWPORT_CHANGED;
|
---|
3115 |
|
---|
3116 | pData->aParms[0].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
3117 | pData->aParms[0].u.uint32 = aScreenId;
|
---|
3118 |
|
---|
3119 | pData->aParms[1].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
3120 | pData->aParms[1].u.uint32 = x;
|
---|
3121 |
|
---|
3122 | pData->aParms[2].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
3123 | pData->aParms[2].u.uint32 = y;
|
---|
3124 |
|
---|
3125 | pData->aParms[3].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
3126 | pData->aParms[3].u.uint32 = width;
|
---|
3127 |
|
---|
3128 | pData->aParms[4].type = VBOX_HGCM_SVC_PARM_32BIT;
|
---|
3129 | pData->aParms[4].u.uint32 = height;
|
---|
3130 |
|
---|
3131 | return i_crCtlSubmitSyncIfHasDataForScreen(aScreenId, &pData->Hdr, (uint32_t)cbData);
|
---|
3132 | }
|
---|
3133 | #endif
|
---|
3134 |
|
---|
3135 | #ifdef VBOX_WITH_CRHGSMI
|
---|
3136 | void Display::i_setupCrHgsmiData(void)
|
---|
3137 | {
|
---|
3138 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
3139 | Assert(pVMMDev);
|
---|
3140 | int rc = RTCritSectRwEnterExcl(&mCrOglLock);
|
---|
3141 | AssertRC(rc);
|
---|
3142 |
|
---|
3143 | if (pVMMDev)
|
---|
3144 | rc = pVMMDev->hgcmHostSvcHandleCreate("VBoxSharedCrOpenGL", &mhCrOglSvc);
|
---|
3145 | else
|
---|
3146 | rc = VERR_GENERAL_FAILURE;
|
---|
3147 |
|
---|
3148 | if (RT_SUCCESS(rc))
|
---|
3149 | {
|
---|
3150 | Assert(mhCrOglSvc);
|
---|
3151 | /* setup command completion callback */
|
---|
3152 | VBOXVDMACMD_CHROMIUM_CTL_CRHGSMI_SETUP_MAINCB Completion;
|
---|
3153 | Completion.Hdr.enmType = VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_MAINCB;
|
---|
3154 | Completion.Hdr.cbCmd = sizeof(Completion);
|
---|
3155 | Completion.hCompletion = mpDrv->pVBVACallbacks;
|
---|
3156 | Completion.pfnCompletion = mpDrv->pVBVACallbacks->pfnCrHgsmiCommandCompleteAsync;
|
---|
3157 |
|
---|
3158 | VBOXHGCMSVCPARM parm;
|
---|
3159 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
3160 | parm.u.pointer.addr = &Completion;
|
---|
3161 | parm.u.pointer.size = 0;
|
---|
3162 |
|
---|
3163 | rc = pVMMDev->hgcmHostCall("VBoxSharedCrOpenGL", SHCRGL_HOST_FN_CRHGSMI_CTL, 1, &parm);
|
---|
3164 | if (RT_SUCCESS(rc))
|
---|
3165 | mCrOglCallbacks = Completion.MainInterface;
|
---|
3166 | else
|
---|
3167 | AssertMsgFailed(("VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP_COMPLETION failed (rc=%Rrc)\n", rc));
|
---|
3168 | }
|
---|
3169 |
|
---|
3170 | if (RT_FAILURE(rc))
|
---|
3171 | mhCrOglSvc = NULL;
|
---|
3172 |
|
---|
3173 | RTCritSectRwLeaveExcl(&mCrOglLock);
|
---|
3174 | }
|
---|
3175 |
|
---|
3176 | void Display::i_destructCrHgsmiData(void)
|
---|
3177 | {
|
---|
3178 | int rc = RTCritSectRwEnterExcl(&mCrOglLock);
|
---|
3179 | AssertRC(rc);
|
---|
3180 | mhCrOglSvc = NULL;
|
---|
3181 | RTCritSectRwLeaveExcl(&mCrOglLock);
|
---|
3182 | }
|
---|
3183 | #endif /* VBOX_WITH_CRHGSMI */
|
---|
3184 |
|
---|
3185 | /**
|
---|
3186 | * Handle display resize event issued by the VGA device for the primary screen.
|
---|
3187 | *
|
---|
3188 | * @see PDMIDISPLAYCONNECTOR::pfnResize
|
---|
3189 | */
|
---|
3190 | DECLCALLBACK(int) Display::i_displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
3191 | uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy)
|
---|
3192 | {
|
---|
3193 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3194 | Display *pThis = pDrv->pDisplay;
|
---|
3195 |
|
---|
3196 | LogRelFlowFunc(("bpp %d, pvVRAM %p, cbLine %d, cx %d, cy %d\n",
|
---|
3197 | bpp, pvVRAM, cbLine, cx, cy));
|
---|
3198 |
|
---|
3199 | bool f = ASMAtomicCmpXchgBool(&pThis->fVGAResizing, true, false);
|
---|
3200 | if (!f)
|
---|
3201 | {
|
---|
3202 | /* This is a result of recursive call when the source bitmap is being updated
|
---|
3203 | * during a VGA resize. Tell the VGA device to ignore the call.
|
---|
3204 | *
|
---|
3205 | * @todo It is a workaround, actually pfnUpdateDisplayAll must
|
---|
3206 | * fail on resize.
|
---|
3207 | */
|
---|
3208 | LogRel(("displayResizeCallback: already processing\n"));
|
---|
3209 | return VINF_VGA_RESIZE_IN_PROGRESS;
|
---|
3210 | }
|
---|
3211 |
|
---|
3212 | int rc = pThis->i_handleDisplayResize(VBOX_VIDEO_PRIMARY_SCREEN, bpp, pvVRAM, cbLine, cx, cy, 0, 0, 0, true);
|
---|
3213 |
|
---|
3214 | /* Restore the flag. */
|
---|
3215 | f = ASMAtomicCmpXchgBool(&pThis->fVGAResizing, false, true);
|
---|
3216 | AssertRelease(f);
|
---|
3217 |
|
---|
3218 | return rc;
|
---|
3219 | }
|
---|
3220 |
|
---|
3221 | /**
|
---|
3222 | * Handle display update.
|
---|
3223 | *
|
---|
3224 | * @see PDMIDISPLAYCONNECTOR::pfnUpdateRect
|
---|
3225 | */
|
---|
3226 | DECLCALLBACK(void) Display::i_displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
3227 | uint32_t x, uint32_t y, uint32_t cx, uint32_t cy)
|
---|
3228 | {
|
---|
3229 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3230 |
|
---|
3231 | #ifdef DEBUG_sunlover
|
---|
3232 | LogFlowFunc(("fVideoAccelEnabled = %d, %d,%d %dx%d\n",
|
---|
3233 | pDrv->pDisplay->mVideoAccelLegacy.fVideoAccelEnabled, x, y, cx, cy));
|
---|
3234 | #endif /* DEBUG_sunlover */
|
---|
3235 |
|
---|
3236 | /* This call does update regardless of VBVA status.
|
---|
3237 | * But in VBVA mode this is called only as result of
|
---|
3238 | * pfnUpdateDisplayAll in the VGA device.
|
---|
3239 | */
|
---|
3240 |
|
---|
3241 | pDrv->pDisplay->i_handleDisplayUpdate(VBOX_VIDEO_PRIMARY_SCREEN, x, y, cx, cy);
|
---|
3242 | }
|
---|
3243 |
|
---|
3244 | /**
|
---|
3245 | * Periodic display refresh callback.
|
---|
3246 | *
|
---|
3247 | * @see PDMIDISPLAYCONNECTOR::pfnRefresh
|
---|
3248 | * @thread EMT
|
---|
3249 | */
|
---|
3250 | /*static*/ DECLCALLBACK(void) Display::i_displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface)
|
---|
3251 | {
|
---|
3252 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3253 |
|
---|
3254 | #ifdef DEBUG_sunlover_2
|
---|
3255 | LogFlowFunc(("pDrv->pDisplay->mfVideoAccelEnabled = %d\n",
|
---|
3256 | pDrv->pDisplay->mfVideoAccelEnabled));
|
---|
3257 | #endif /* DEBUG_sunlover_2 */
|
---|
3258 |
|
---|
3259 | Display *pDisplay = pDrv->pDisplay;
|
---|
3260 | unsigned uScreenId;
|
---|
3261 |
|
---|
3262 | int rc = pDisplay->i_videoAccelRefreshProcess(pDrv->pUpPort);
|
---|
3263 | if (rc != VINF_TRY_AGAIN) /* Means 'do nothing' here. */
|
---|
3264 | {
|
---|
3265 | if (rc == VWRN_INVALID_STATE)
|
---|
3266 | {
|
---|
3267 | /* No VBVA do a display update. */
|
---|
3268 | pDrv->pUpPort->pfnUpdateDisplay(pDrv->pUpPort);
|
---|
3269 | }
|
---|
3270 |
|
---|
3271 | /* Inform the VRDP server that the current display update sequence is
|
---|
3272 | * completed. At this moment the framebuffer memory contains a definite
|
---|
3273 | * image, that is synchronized with the orders already sent to VRDP client.
|
---|
3274 | * The server can now process redraw requests from clients or initial
|
---|
3275 | * fullscreen updates for new clients.
|
---|
3276 | */
|
---|
3277 | for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
|
---|
3278 | {
|
---|
3279 | Assert(pDisplay->mParent && pDisplay->mParent->i_consoleVRDPServer());
|
---|
3280 | pDisplay->mParent->i_consoleVRDPServer()->SendUpdate(uScreenId, NULL, 0);
|
---|
3281 | }
|
---|
3282 | }
|
---|
3283 |
|
---|
3284 | #ifdef VBOX_WITH_VIDEOREC
|
---|
3285 | if (VideoRecIsEnabled(pDisplay->mpVideoRecCtx))
|
---|
3286 | {
|
---|
3287 | do {
|
---|
3288 | # if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
3289 | if (pDisplay->mfIsCr3DEnabled)
|
---|
3290 | {
|
---|
3291 | if (ASMAtomicCmpXchgU32(&pDisplay->mfCrOglVideoRecState, CRVREC_STATE_SUBMITTED, CRVREC_STATE_IDLE))
|
---|
3292 | {
|
---|
3293 | if ( pDisplay->mCrOglCallbacks.pfnHasData
|
---|
3294 | && pDisplay->mCrOglCallbacks.pfnHasData())
|
---|
3295 | {
|
---|
3296 | /* submit */
|
---|
3297 | VBOXCRCMDCTL_HGCM *pData = &pDisplay->mCrOglScreenshotCtl;
|
---|
3298 |
|
---|
3299 | pData->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
3300 | pData->Hdr.u32Function = SHCRGL_HOST_FN_TAKE_SCREENSHOT;
|
---|
3301 |
|
---|
3302 | pData->aParms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
3303 | pData->aParms[0].u.pointer.addr = &pDisplay->mCrOglScreenshotData;
|
---|
3304 | pData->aParms[0].u.pointer.size = sizeof(pDisplay->mCrOglScreenshotData);
|
---|
3305 | rc = pDisplay->i_crCtlSubmit(&pData->Hdr, sizeof(*pData), Display::i_displayVRecCompletion, pDisplay);
|
---|
3306 | if (RT_SUCCESS(rc))
|
---|
3307 | break;
|
---|
3308 | AssertMsgFailed(("crCtlSubmit failed (rc=%Rrc)\n", rc));
|
---|
3309 | }
|
---|
3310 |
|
---|
3311 | /* no 3D data available, or error has occured,
|
---|
3312 | * go the straight way */
|
---|
3313 | ASMAtomicWriteU32(&pDisplay->mfCrOglVideoRecState, CRVREC_STATE_IDLE);
|
---|
3314 | }
|
---|
3315 | else
|
---|
3316 | {
|
---|
3317 | /* record request is still in progress, don't do anything */
|
---|
3318 | break;
|
---|
3319 | }
|
---|
3320 | }
|
---|
3321 | # endif /* VBOX_WITH_HGCM && VBOX_WITH_CROGL */
|
---|
3322 |
|
---|
3323 | uint64_t u64Now = RTTimeProgramMilliTS();
|
---|
3324 | for (uScreenId = 0; uScreenId < pDisplay->mcMonitors; uScreenId++)
|
---|
3325 | {
|
---|
3326 | if (!pDisplay->maVideoRecEnabled[uScreenId])
|
---|
3327 | continue;
|
---|
3328 |
|
---|
3329 | if (VideoRecIsLimitReached(pDisplay->mpVideoRecCtx, uScreenId, u64Now))
|
---|
3330 | {
|
---|
3331 | pDisplay->i_videoCaptureStop();
|
---|
3332 | pDisplay->mParent->i_machine()->COMSETTER(VideoCaptureEnabled)(false);
|
---|
3333 | break;
|
---|
3334 | }
|
---|
3335 |
|
---|
3336 | DISPLAYFBINFO *pFBInfo = &pDisplay->maFramebuffers[uScreenId];
|
---|
3337 | if (!pFBInfo->fDisabled)
|
---|
3338 | {
|
---|
3339 | ComPtr<IDisplaySourceBitmap> pSourceBitmap;
|
---|
3340 | int rc2 = RTCritSectEnter(&pDisplay->mVideoCaptureLock);
|
---|
3341 | if (RT_SUCCESS(rc2))
|
---|
3342 | {
|
---|
3343 | pSourceBitmap = pFBInfo->videoCapture.pSourceBitmap;
|
---|
3344 | RTCritSectLeave(&pDisplay->mVideoCaptureLock);
|
---|
3345 | }
|
---|
3346 |
|
---|
3347 | if (!pSourceBitmap.isNull())
|
---|
3348 | {
|
---|
3349 | BYTE *pbAddress = NULL;
|
---|
3350 | ULONG ulWidth = 0;
|
---|
3351 | ULONG ulHeight = 0;
|
---|
3352 | ULONG ulBitsPerPixel = 0;
|
---|
3353 | ULONG ulBytesPerLine = 0;
|
---|
3354 | BitmapFormat_T bitmapFormat = BitmapFormat_Opaque;
|
---|
3355 | HRESULT hr = pSourceBitmap->QueryBitmapInfo(&pbAddress,
|
---|
3356 | &ulWidth,
|
---|
3357 | &ulHeight,
|
---|
3358 | &ulBitsPerPixel,
|
---|
3359 | &ulBytesPerLine,
|
---|
3360 | &bitmapFormat);
|
---|
3361 | if (SUCCEEDED(hr) && pbAddress)
|
---|
3362 | rc = VideoRecSendVideoFrame(pDisplay->mpVideoRecCtx, uScreenId, 0, 0,
|
---|
3363 | BitmapFormat_BGR,
|
---|
3364 | ulBitsPerPixel, ulBytesPerLine, ulWidth, ulHeight,
|
---|
3365 | pbAddress, u64Now);
|
---|
3366 | else
|
---|
3367 | rc = VERR_NOT_SUPPORTED;
|
---|
3368 |
|
---|
3369 | pSourceBitmap.setNull();
|
---|
3370 | }
|
---|
3371 | else
|
---|
3372 | rc = VERR_NOT_SUPPORTED;
|
---|
3373 |
|
---|
3374 | if (rc == VINF_TRY_AGAIN)
|
---|
3375 | break;
|
---|
3376 | }
|
---|
3377 | }
|
---|
3378 | } while (0);
|
---|
3379 | }
|
---|
3380 | #endif /* VBOX_WITH_VIDEOREC */
|
---|
3381 |
|
---|
3382 | #ifdef DEBUG_sunlover_2
|
---|
3383 | LogFlowFunc(("leave\n"));
|
---|
3384 | #endif /* DEBUG_sunlover_2 */
|
---|
3385 | }
|
---|
3386 |
|
---|
3387 | /**
|
---|
3388 | * Reset notification
|
---|
3389 | *
|
---|
3390 | * @see PDMIDISPLAYCONNECTOR::pfnReset
|
---|
3391 | */
|
---|
3392 | DECLCALLBACK(void) Display::i_displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface)
|
---|
3393 | {
|
---|
3394 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3395 |
|
---|
3396 | LogRelFlowFunc(("\n"));
|
---|
3397 |
|
---|
3398 | /* Disable VBVA mode. */
|
---|
3399 | pDrv->pDisplay->VideoAccelEnableVGA(false, NULL);
|
---|
3400 | }
|
---|
3401 |
|
---|
3402 | /**
|
---|
3403 | * LFBModeChange notification
|
---|
3404 | *
|
---|
3405 | * @see PDMIDISPLAYCONNECTOR::pfnLFBModeChange
|
---|
3406 | */
|
---|
3407 | DECLCALLBACK(void) Display::i_displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled)
|
---|
3408 | {
|
---|
3409 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3410 |
|
---|
3411 | LogRelFlowFunc(("fEnabled=%d\n", fEnabled));
|
---|
3412 |
|
---|
3413 | NOREF(fEnabled);
|
---|
3414 |
|
---|
3415 | /* Disable VBVA mode in any case. The guest driver reenables VBVA mode if necessary. */
|
---|
3416 | pDrv->pDisplay->VideoAccelEnableVGA(false, NULL);
|
---|
3417 | }
|
---|
3418 |
|
---|
3419 | /**
|
---|
3420 | * Adapter information change notification.
|
---|
3421 | *
|
---|
3422 | * @see PDMIDISPLAYCONNECTOR::pfnProcessAdapterData
|
---|
3423 | */
|
---|
3424 | DECLCALLBACK(void) Display::i_displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM,
|
---|
3425 | uint32_t u32VRAMSize)
|
---|
3426 | {
|
---|
3427 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3428 | pDrv->pDisplay->processAdapterData(pvVRAM, u32VRAMSize);
|
---|
3429 | }
|
---|
3430 |
|
---|
3431 | /**
|
---|
3432 | * Display information change notification.
|
---|
3433 | *
|
---|
3434 | * @see PDMIDISPLAYCONNECTOR::pfnProcessDisplayData
|
---|
3435 | */
|
---|
3436 | DECLCALLBACK(void) Display::i_displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
3437 | void *pvVRAM, unsigned uScreenId)
|
---|
3438 | {
|
---|
3439 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3440 | pDrv->pDisplay->processDisplayData(pvVRAM, uScreenId);
|
---|
3441 | }
|
---|
3442 |
|
---|
3443 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
3444 |
|
---|
3445 | #ifndef S_FALSE
|
---|
3446 | # define S_FALSE ((HRESULT)1L)
|
---|
3447 | #endif
|
---|
3448 |
|
---|
3449 | int Display::i_handleVHWACommandProcess(PVBOXVHWACMD pCommand)
|
---|
3450 | {
|
---|
3451 | unsigned id = (unsigned)pCommand->iDisplay;
|
---|
3452 | if (id >= mcMonitors)
|
---|
3453 | return VERR_INVALID_PARAMETER;
|
---|
3454 |
|
---|
3455 | ComPtr<IFramebuffer> pFramebuffer;
|
---|
3456 | AutoReadLock arlock(this COMMA_LOCKVAL_SRC_POS);
|
---|
3457 | pFramebuffer = maFramebuffers[id].pFramebuffer;
|
---|
3458 | bool fVHWASupported = RT_BOOL(maFramebuffers[id].u32Caps & FramebufferCapabilities_VHWA);
|
---|
3459 | arlock.release();
|
---|
3460 |
|
---|
3461 | if (pFramebuffer == NULL || !fVHWASupported)
|
---|
3462 | return VERR_NOT_IMPLEMENTED; /* Implementation is not available. */
|
---|
3463 |
|
---|
3464 | HRESULT hr = pFramebuffer->ProcessVHWACommand((BYTE*)pCommand);
|
---|
3465 | if (hr == S_FALSE)
|
---|
3466 | return VINF_SUCCESS;
|
---|
3467 | if (SUCCEEDED(hr))
|
---|
3468 | return VINF_CALLBACK_RETURN;
|
---|
3469 | if (hr == E_ACCESSDENIED)
|
---|
3470 | return VERR_INVALID_STATE; /* notify we can not handle request atm */
|
---|
3471 | if (hr == E_NOTIMPL)
|
---|
3472 | return VERR_NOT_IMPLEMENTED;
|
---|
3473 | return VERR_GENERAL_FAILURE;
|
---|
3474 | }
|
---|
3475 |
|
---|
3476 | DECLCALLBACK(int) Display::i_displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand)
|
---|
3477 | {
|
---|
3478 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3479 |
|
---|
3480 | return pDrv->pDisplay->i_handleVHWACommandProcess(pCommand);
|
---|
3481 | }
|
---|
3482 | #endif
|
---|
3483 |
|
---|
3484 | #ifdef VBOX_WITH_CRHGSMI
|
---|
3485 | void Display::i_handleCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam)
|
---|
3486 | {
|
---|
3487 | RT_NOREF(u32Function);
|
---|
3488 | mpDrv->pVBVACallbacks->pfnCrHgsmiCommandCompleteAsync(mpDrv->pVBVACallbacks,
|
---|
3489 | (PVBOXVDMACMD_CHROMIUM_CMD)pParam->u.pointer.addr, result);
|
---|
3490 | }
|
---|
3491 |
|
---|
3492 | void Display::i_handleCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam)
|
---|
3493 | {
|
---|
3494 | RT_NOREF(u32Function);
|
---|
3495 | PVBOXVDMACMD_CHROMIUM_CTL pCtl = (PVBOXVDMACMD_CHROMIUM_CTL)pParam->u.pointer.addr;
|
---|
3496 | mpDrv->pVBVACallbacks->pfnCrHgsmiControlCompleteAsync(mpDrv->pVBVACallbacks, pCtl, result);
|
---|
3497 | }
|
---|
3498 |
|
---|
3499 | void Display::i_handleCrHgsmiCommandProcess(PVBOXVDMACMD_CHROMIUM_CMD pCmd, uint32_t cbCmd)
|
---|
3500 | {
|
---|
3501 | int rc = VERR_NOT_SUPPORTED;
|
---|
3502 | VBOXHGCMSVCPARM parm;
|
---|
3503 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
3504 | parm.u.pointer.addr = pCmd;
|
---|
3505 | parm.u.pointer.size = cbCmd;
|
---|
3506 |
|
---|
3507 | if (mhCrOglSvc)
|
---|
3508 | {
|
---|
3509 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
3510 | if (pVMMDev)
|
---|
3511 | {
|
---|
3512 | /* no completion callback is specified with this call,
|
---|
3513 | * the CrOgl code will complete the CrHgsmi command once it processes it */
|
---|
3514 | rc = pVMMDev->hgcmHostFastCallAsync(mhCrOglSvc, SHCRGL_HOST_FN_CRHGSMI_CMD, &parm, NULL, NULL);
|
---|
3515 | AssertRC(rc);
|
---|
3516 | if (RT_SUCCESS(rc))
|
---|
3517 | return;
|
---|
3518 | }
|
---|
3519 | else
|
---|
3520 | rc = VERR_INVALID_STATE;
|
---|
3521 | }
|
---|
3522 |
|
---|
3523 | /* we are here because something went wrong with command processing, complete it */
|
---|
3524 | i_handleCrHgsmiCommandCompletion(rc, SHCRGL_HOST_FN_CRHGSMI_CMD, &parm);
|
---|
3525 | }
|
---|
3526 |
|
---|
3527 | void Display::i_handleCrHgsmiControlProcess(PVBOXVDMACMD_CHROMIUM_CTL pCtl, uint32_t cbCtl)
|
---|
3528 | {
|
---|
3529 | int rc = VERR_NOT_SUPPORTED;
|
---|
3530 | VBOXHGCMSVCPARM parm;
|
---|
3531 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
3532 | parm.u.pointer.addr = pCtl;
|
---|
3533 | parm.u.pointer.size = cbCtl;
|
---|
3534 |
|
---|
3535 | if (mhCrOglSvc)
|
---|
3536 | {
|
---|
3537 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
3538 | if (pVMMDev)
|
---|
3539 | {
|
---|
3540 | bool fCheckPendingViewport = (pCtl->enmType == VBOXVDMACMD_CHROMIUM_CTL_TYPE_CRHGSMI_SETUP);
|
---|
3541 | rc = pVMMDev->hgcmHostFastCallAsync(mhCrOglSvc, SHCRGL_HOST_FN_CRHGSMI_CTL, &parm,
|
---|
3542 | Display::i_displayCrHgsmiControlCompletion, this);
|
---|
3543 | AssertRC(rc);
|
---|
3544 | if (RT_SUCCESS(rc))
|
---|
3545 | {
|
---|
3546 | if (fCheckPendingViewport)
|
---|
3547 | {
|
---|
3548 | ULONG ul;
|
---|
3549 | for (ul = 0; ul < mcMonitors; ul++)
|
---|
3550 | {
|
---|
3551 | DISPLAYFBINFO *pFb = &maFramebuffers[ul];
|
---|
3552 | if (!pFb->pendingViewportInfo.fPending)
|
---|
3553 | continue;
|
---|
3554 |
|
---|
3555 | rc = i_crViewportNotify(ul, pFb->pendingViewportInfo.x, pFb->pendingViewportInfo.y,
|
---|
3556 | pFb->pendingViewportInfo.width, pFb->pendingViewportInfo.height);
|
---|
3557 | if (RT_SUCCESS(rc))
|
---|
3558 | pFb->pendingViewportInfo.fPending = false;
|
---|
3559 | else
|
---|
3560 | {
|
---|
3561 | AssertMsgFailed(("crViewportNotify failed (rc=%Rrc)\n", rc));
|
---|
3562 | rc = VINF_SUCCESS;
|
---|
3563 | }
|
---|
3564 | }
|
---|
3565 | }
|
---|
3566 | return;
|
---|
3567 | }
|
---|
3568 | }
|
---|
3569 | else
|
---|
3570 | rc = VERR_INVALID_STATE;
|
---|
3571 | }
|
---|
3572 |
|
---|
3573 | /* we are here because something went wrong with command processing, complete it */
|
---|
3574 | i_handleCrHgsmiControlCompletion(rc, SHCRGL_HOST_FN_CRHGSMI_CTL, &parm);
|
---|
3575 | }
|
---|
3576 |
|
---|
3577 | DECLCALLBACK(void) Display::i_displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd,
|
---|
3578 | uint32_t cbCmd)
|
---|
3579 | {
|
---|
3580 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3581 |
|
---|
3582 | pDrv->pDisplay->i_handleCrHgsmiCommandProcess(pCmd, cbCmd);
|
---|
3583 | }
|
---|
3584 |
|
---|
3585 | DECLCALLBACK(void) Display::i_displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCmd,
|
---|
3586 | uint32_t cbCmd)
|
---|
3587 | {
|
---|
3588 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3589 |
|
---|
3590 | pDrv->pDisplay->i_handleCrHgsmiControlProcess(pCmd, cbCmd);
|
---|
3591 | }
|
---|
3592 |
|
---|
3593 | DECLCALLBACK(void) Display::i_displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
|
---|
3594 | void *pvContext)
|
---|
3595 | {
|
---|
3596 | AssertMsgFailed(("not expected!\n"));
|
---|
3597 | Display *pDisplay = (Display *)pvContext;
|
---|
3598 | pDisplay->i_handleCrHgsmiCommandCompletion(result, u32Function, pParam);
|
---|
3599 | }
|
---|
3600 |
|
---|
3601 | DECLCALLBACK(void) Display::i_displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
|
---|
3602 | void *pvContext)
|
---|
3603 | {
|
---|
3604 | Display *pDisplay = (Display *)pvContext;
|
---|
3605 | pDisplay->i_handleCrHgsmiControlCompletion(result, u32Function, pParam);
|
---|
3606 |
|
---|
3607 | }
|
---|
3608 | #endif
|
---|
3609 |
|
---|
3610 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
3611 | DECLCALLBACK(void) Display::i_displayCrHgcmCtlSubmitCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
|
---|
3612 | void *pvContext)
|
---|
3613 | {
|
---|
3614 | RT_NOREF(u32Function);
|
---|
3615 | VBOXCRCMDCTL *pCmd = (VBOXCRCMDCTL*)pParam->u.pointer.addr;
|
---|
3616 | if (pCmd->u.pfnInternal)
|
---|
3617 | ((PFNCRCTLCOMPLETION)pCmd->u.pfnInternal)(pCmd, pParam->u.pointer.size, result, pvContext);
|
---|
3618 | }
|
---|
3619 |
|
---|
3620 | int Display::i_handleCrHgcmCtlSubmit(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
|
---|
3621 | PFNCRCTLCOMPLETION pfnCompletion,
|
---|
3622 | void *pvCompletion)
|
---|
3623 | {
|
---|
3624 | VMMDev *pVMMDev = mParent ? mParent->i_getVMMDev() : NULL;
|
---|
3625 | if (!pVMMDev)
|
---|
3626 | {
|
---|
3627 | AssertMsgFailed(("no vmmdev\n"));
|
---|
3628 | return VERR_INVALID_STATE;
|
---|
3629 | }
|
---|
3630 |
|
---|
3631 | Assert(mhCrOglSvc);
|
---|
3632 | VBOXHGCMSVCPARM parm;
|
---|
3633 | parm.type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
3634 | parm.u.pointer.addr = pCmd;
|
---|
3635 | parm.u.pointer.size = cbCmd;
|
---|
3636 |
|
---|
3637 | pCmd->u.pfnInternal = (void(*)())pfnCompletion;
|
---|
3638 | int rc = pVMMDev->hgcmHostFastCallAsync(mhCrOglSvc, SHCRGL_HOST_FN_CTL, &parm, i_displayCrHgcmCtlSubmitCompletion,
|
---|
3639 | pvCompletion);
|
---|
3640 | if (!RT_SUCCESS(rc))
|
---|
3641 | AssertMsgFailed(("hgcmHostFastCallAsync failed (rc=%Rrc)\n", rc));
|
---|
3642 |
|
---|
3643 | return rc;
|
---|
3644 | }
|
---|
3645 |
|
---|
3646 | DECLCALLBACK(int) Display::i_displayCrHgcmCtlSubmit(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
3647 | struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
|
---|
3648 | PFNCRCTLCOMPLETION pfnCompletion,
|
---|
3649 | void *pvCompletion)
|
---|
3650 | {
|
---|
3651 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3652 | Display *pThis = pDrv->pDisplay;
|
---|
3653 | return pThis->i_handleCrHgcmCtlSubmit(pCmd, cbCmd, pfnCompletion, pvCompletion);
|
---|
3654 | }
|
---|
3655 |
|
---|
3656 | int Display::i_crCtlSubmit(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion)
|
---|
3657 | {
|
---|
3658 | int rc = RTCritSectRwEnterShared(&mCrOglLock);
|
---|
3659 | if (RT_SUCCESS(rc))
|
---|
3660 | {
|
---|
3661 | if (mhCrOglSvc)
|
---|
3662 | rc = mpDrv->pVBVACallbacks->pfnCrCtlSubmit(mpDrv->pVBVACallbacks, pCmd, cbCmd, pfnCompletion, pvCompletion);
|
---|
3663 | else
|
---|
3664 | rc = VERR_NOT_SUPPORTED;
|
---|
3665 |
|
---|
3666 | RTCritSectRwLeaveShared(&mCrOglLock);
|
---|
3667 | }
|
---|
3668 | return rc;
|
---|
3669 | }
|
---|
3670 |
|
---|
3671 | int Display::i_crCtlSubmitSync(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd)
|
---|
3672 | {
|
---|
3673 | int rc = RTCritSectRwEnterShared(&mCrOglLock);
|
---|
3674 | if (RT_SUCCESS(rc))
|
---|
3675 | {
|
---|
3676 | if (mhCrOglSvc)
|
---|
3677 | rc = mpDrv->pVBVACallbacks->pfnCrCtlSubmitSync(mpDrv->pVBVACallbacks, pCmd, cbCmd);
|
---|
3678 | else
|
---|
3679 | rc = VERR_NOT_SUPPORTED;
|
---|
3680 |
|
---|
3681 | RTCritSectRwLeaveShared(&mCrOglLock);
|
---|
3682 | }
|
---|
3683 | return rc;
|
---|
3684 | }
|
---|
3685 |
|
---|
3686 | int Display::i_crCtlSubmitAsyncCmdCopy(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd)
|
---|
3687 | {
|
---|
3688 | VBOXCRCMDCTL* pCmdCopy = (VBOXCRCMDCTL*)RTMemAlloc(cbCmd);
|
---|
3689 | if (!pCmdCopy)
|
---|
3690 | {
|
---|
3691 | LogRel(("RTMemAlloc failed\n"));
|
---|
3692 | return VERR_NO_MEMORY;
|
---|
3693 | }
|
---|
3694 |
|
---|
3695 | memcpy(pCmdCopy, pCmd, cbCmd);
|
---|
3696 |
|
---|
3697 | int rc = i_crCtlSubmit(pCmdCopy, cbCmd, i_displayCrCmdFree, pCmdCopy);
|
---|
3698 | if (RT_FAILURE(rc))
|
---|
3699 | {
|
---|
3700 | LogRel(("crCtlSubmit failed (rc=%Rrc)\n", rc));
|
---|
3701 | RTMemFree(pCmdCopy);
|
---|
3702 | return rc;
|
---|
3703 | }
|
---|
3704 |
|
---|
3705 | return VINF_SUCCESS;
|
---|
3706 | }
|
---|
3707 |
|
---|
3708 | int Display::i_crCtlSubmitSyncIfHasDataForScreen(uint32_t u32ScreenID, struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd)
|
---|
3709 | {
|
---|
3710 | int rc = RTCritSectRwEnterShared(&mCrOglLock);
|
---|
3711 | AssertRCReturn(rc, rc);
|
---|
3712 |
|
---|
3713 | if ( mCrOglCallbacks.pfnHasDataForScreen
|
---|
3714 | && mCrOglCallbacks.pfnHasDataForScreen(u32ScreenID))
|
---|
3715 | rc = i_crCtlSubmitSync(pCmd, cbCmd);
|
---|
3716 | else
|
---|
3717 | rc = i_crCtlSubmitAsyncCmdCopy(pCmd, cbCmd);
|
---|
3718 |
|
---|
3719 | RTCritSectRwLeaveShared(&mCrOglLock);
|
---|
3720 |
|
---|
3721 | return rc;
|
---|
3722 | }
|
---|
3723 |
|
---|
3724 | bool Display::i_handleCrVRecScreenshotBegin(uint32_t uScreen, uint64_t u64Timestamp)
|
---|
3725 | {
|
---|
3726 | /** @todo r=bird: u64Timestamp - using the 'u64' prefix add nothing.
|
---|
3727 | * However, using one of the prefixes indicating the timestamp unit
|
---|
3728 | * would be very valuable! */
|
---|
3729 | # ifdef VBOX_WITH_VIDEOREC
|
---|
3730 | return VideoRecIsReady(mpVideoRecCtx, uScreen, u64Timestamp);
|
---|
3731 | # else
|
---|
3732 | RT_NOREF(uScreen, u64Timestamp);
|
---|
3733 | return false;
|
---|
3734 | # endif
|
---|
3735 | }
|
---|
3736 |
|
---|
3737 | void Display::i_handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t u64Timestamp)
|
---|
3738 | {
|
---|
3739 | RT_NOREF(uScreen, u64Timestamp);
|
---|
3740 | }
|
---|
3741 |
|
---|
3742 | void Display::i_handleCrVRecScreenshotPerform(uint32_t uScreen,
|
---|
3743 | uint32_t x, uint32_t y, uint32_t uPixelFormat,
|
---|
3744 | uint32_t uBitsPerPixel, uint32_t uBytesPerLine,
|
---|
3745 | uint32_t uGuestWidth, uint32_t uGuestHeight,
|
---|
3746 | uint8_t *pu8BufferAddress, uint64_t u64Timestamp)
|
---|
3747 | {
|
---|
3748 | Assert(mfCrOglVideoRecState == CRVREC_STATE_SUBMITTED);
|
---|
3749 | # ifdef VBOX_WITH_VIDEOREC
|
---|
3750 | int rc = VideoRecSendVideoFrame(mpVideoRecCtx, uScreen, x, y,
|
---|
3751 | uPixelFormat,
|
---|
3752 | uBitsPerPixel, uBytesPerLine,
|
---|
3753 | uGuestWidth, uGuestHeight,
|
---|
3754 | pu8BufferAddress, u64Timestamp);
|
---|
3755 | NOREF(rc);
|
---|
3756 | Assert(rc == VINF_SUCCESS /* || rc == VERR_TRY_AGAIN || rc == VINF_TRY_AGAIN*/);
|
---|
3757 | # else
|
---|
3758 | RT_NOREF(uScreen, x, y, uPixelFormat, \
|
---|
3759 | uBitsPerPixel, uBytesPerLine, uGuestWidth, uGuestHeight, pu8BufferAddress, u64Timestamp);
|
---|
3760 | # endif /* VBOX_WITH_VIDEOREC */
|
---|
3761 | }
|
---|
3762 |
|
---|
3763 | void Display::i_handleVRecCompletion()
|
---|
3764 | {
|
---|
3765 | Assert(mfCrOglVideoRecState == CRVREC_STATE_SUBMITTED);
|
---|
3766 | ASMAtomicWriteU32(&mfCrOglVideoRecState, CRVREC_STATE_IDLE);
|
---|
3767 | }
|
---|
3768 |
|
---|
3769 | #endif /* VBOX_WITH_HGCM && VBOX_WITH_CROGL */
|
---|
3770 |
|
---|
3771 | HRESULT Display::notifyScaleFactorChange(ULONG aScreenId, ULONG aScaleFactorWMultiplied, ULONG aScaleFactorHMultiplied)
|
---|
3772 | {
|
---|
3773 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
3774 | HRESULT hr = E_UNEXPECTED;
|
---|
3775 |
|
---|
3776 | if (aScreenId >= mcMonitors)
|
---|
3777 | return E_INVALIDARG;
|
---|
3778 |
|
---|
3779 | /* 3D acceleration enabled in VM config. */
|
---|
3780 | if (mfIsCr3DEnabled)
|
---|
3781 | {
|
---|
3782 | /* VBoxSharedCrOpenGL HGCM host service is running. */
|
---|
3783 | if (mhCrOglSvc)
|
---|
3784 | {
|
---|
3785 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
3786 | if (pVMMDev)
|
---|
3787 | {
|
---|
3788 | VBOXCRCMDCTL_HGCM *pCtl;
|
---|
3789 | pCtl = (VBOXCRCMDCTL_HGCM *)RTMemAlloc(sizeof(CRVBOXHGCMSETSCALEFACTOR) + sizeof(VBOXCRCMDCTL_HGCM));
|
---|
3790 | if (pCtl)
|
---|
3791 | {
|
---|
3792 | CRVBOXHGCMSETSCALEFACTOR *pData = (CRVBOXHGCMSETSCALEFACTOR *)(pCtl + 1);
|
---|
3793 | int rc;
|
---|
3794 |
|
---|
3795 | pData->u32Screen = aScreenId;
|
---|
3796 | pData->u32ScaleFactorWMultiplied = aScaleFactorWMultiplied;
|
---|
3797 | pData->u32ScaleFactorHMultiplied = aScaleFactorHMultiplied;
|
---|
3798 |
|
---|
3799 | pCtl->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
3800 | pCtl->Hdr.u32Function = SHCRGL_HOST_FN_SET_SCALE_FACTOR;
|
---|
3801 | pCtl->aParms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
3802 | pCtl->aParms[0].u.pointer.addr = pData;
|
---|
3803 | pCtl->aParms[0].u.pointer.size = sizeof(*pData);
|
---|
3804 |
|
---|
3805 | rc = i_crCtlSubmitSync(&pCtl->Hdr, sizeof(*pCtl));
|
---|
3806 | if (RT_FAILURE(rc))
|
---|
3807 | AssertMsgFailed(("crCtlSubmitSync failed (rc=%Rrc)\n", rc));
|
---|
3808 | else
|
---|
3809 | hr = S_OK;
|
---|
3810 |
|
---|
3811 | RTMemFree(pCtl);
|
---|
3812 | }
|
---|
3813 | else
|
---|
3814 | {
|
---|
3815 | LogRel(("Running out of memory on attempt to set OpenGL content scale factor. Ignored.\n"));
|
---|
3816 | hr = E_OUTOFMEMORY;
|
---|
3817 | }
|
---|
3818 | }
|
---|
3819 | else
|
---|
3820 | LogRel(("Internal error occurred on attempt to set OpenGL content scale factor. Ignored.\n"));
|
---|
3821 | }
|
---|
3822 | else
|
---|
3823 | LogRel(("Attempt to specify OpenGL content scale factor while corresponding HGCM host service not yet runing. Ignored.\n"));
|
---|
3824 | }
|
---|
3825 | else
|
---|
3826 | # if 0 /** @todo Thank you so very much from anyone using VMSVGA3d! */
|
---|
3827 | AssertMsgFailed(("Attempt to specify OpenGL content scale factor while 3D acceleration is disabled in VM config. Ignored.\n"));
|
---|
3828 | # else
|
---|
3829 | {
|
---|
3830 | hr = S_OK;
|
---|
3831 | /* Need an interface like this here (and the #ifdefs needs adjusting):
|
---|
3832 | PPDMIDISPLAYPORT pUpPort = mpDrv ? mpDrv->pUpPort : NULL;
|
---|
3833 | if (pUpPort && pUpPort->pfnSetScaleFactor)
|
---|
3834 | pUpPort->pfnSetScaleFactor(pUpPort, aScreeId, aScaleFactorWMultiplied, aScaleFactorHMultiplied); */
|
---|
3835 | }
|
---|
3836 | # endif
|
---|
3837 |
|
---|
3838 | return hr;
|
---|
3839 |
|
---|
3840 | #else /* !VBOX_WITH_HGCM || !VBOX_WITH_CROGL */
|
---|
3841 | RT_NOREF(aScreenId, aScaleFactorWMultiplied, aScaleFactorHMultiplied);
|
---|
3842 | AssertMsgFailed(("Attempt to specify OpenGL content scale factor while corresponding functionality is disabled."));
|
---|
3843 | return E_UNEXPECTED;
|
---|
3844 | #endif /* !VBOX_WITH_HGCM || !VBOX_WITH_CROGL */
|
---|
3845 | }
|
---|
3846 |
|
---|
3847 | HRESULT Display::notifyHiDPIOutputPolicyChange(BOOL fUnscaledHiDPI)
|
---|
3848 | {
|
---|
3849 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
3850 | HRESULT hr = E_UNEXPECTED;
|
---|
3851 |
|
---|
3852 | /* 3D acceleration enabled in VM config. */
|
---|
3853 | if (mfIsCr3DEnabled)
|
---|
3854 | {
|
---|
3855 | /* VBoxSharedCrOpenGL HGCM host service is running. */
|
---|
3856 | if (mhCrOglSvc)
|
---|
3857 | {
|
---|
3858 | VMMDev *pVMMDev = mParent->i_getVMMDev();
|
---|
3859 | if (pVMMDev)
|
---|
3860 | {
|
---|
3861 | VBOXCRCMDCTL_HGCM *pCtl;
|
---|
3862 | pCtl = (VBOXCRCMDCTL_HGCM *)RTMemAlloc(sizeof(CRVBOXHGCMSETUNSCALEDHIDPIOUTPUT) + sizeof(VBOXCRCMDCTL_HGCM));
|
---|
3863 | if (pCtl)
|
---|
3864 | {
|
---|
3865 | CRVBOXHGCMSETUNSCALEDHIDPIOUTPUT *pData = (CRVBOXHGCMSETUNSCALEDHIDPIOUTPUT *)(pCtl + 1);
|
---|
3866 | int rc;
|
---|
3867 |
|
---|
3868 | pData->fUnscaledHiDPI = RT_BOOL(fUnscaledHiDPI);
|
---|
3869 |
|
---|
3870 | pCtl->Hdr.enmType = VBOXCRCMDCTL_TYPE_HGCM;
|
---|
3871 | pCtl->Hdr.u32Function = SHCRGL_HOST_FN_SET_UNSCALED_HIDPI;
|
---|
3872 | pCtl->aParms[0].type = VBOX_HGCM_SVC_PARM_PTR;
|
---|
3873 | pCtl->aParms[0].u.pointer.addr = pData;
|
---|
3874 | pCtl->aParms[0].u.pointer.size = sizeof(*pData);
|
---|
3875 |
|
---|
3876 | rc = i_crCtlSubmitSync(&pCtl->Hdr, sizeof(*pCtl));
|
---|
3877 | if (RT_FAILURE(rc))
|
---|
3878 | AssertMsgFailed(("crCtlSubmitSync failed (rc=%Rrc)\n", rc));
|
---|
3879 | else
|
---|
3880 | hr = S_OK;
|
---|
3881 |
|
---|
3882 | RTMemFree(pCtl);
|
---|
3883 | }
|
---|
3884 | else
|
---|
3885 | {
|
---|
3886 | LogRel(("Running out of memory on attempt to notify OpenGL about HiDPI output scaling policy change. Ignored.\n"));
|
---|
3887 | hr = E_OUTOFMEMORY;
|
---|
3888 | }
|
---|
3889 | }
|
---|
3890 | else
|
---|
3891 | LogRel(("Internal error occurred on attempt to notify OpenGL about HiDPI output scaling policy change. Ignored.\n"));
|
---|
3892 | }
|
---|
3893 | else
|
---|
3894 | LogRel(("Attempt to notify OpenGL about HiDPI output scaling policy change while corresponding HGCM host service not yet runing. Ignored.\n"));
|
---|
3895 | }
|
---|
3896 | else
|
---|
3897 | {
|
---|
3898 | hr = S_OK;
|
---|
3899 | /* Need an interface like this here (and the #ifdefs needs adjusting):
|
---|
3900 | PPDMIDISPLAYPORT pUpPort = mpDrv ? mpDrv->pUpPort : NULL;
|
---|
3901 | if (pUpPort && pUpPort->pfnSetScaleFactor)
|
---|
3902 | pUpPort->pfnSetScaleFactor(pUpPort, aScreeId, aScaleFactorWMultiplied, aScaleFactorHMultiplied); */
|
---|
3903 | }
|
---|
3904 |
|
---|
3905 | return hr;
|
---|
3906 |
|
---|
3907 | #else /* !VBOX_WITH_HGCM || !VBOX_WITH_CROGL */
|
---|
3908 | RT_NOREF(fUnscaledHiDPI);
|
---|
3909 | AssertMsgFailed(("Attempt to notify OpenGL about HiDPI output scaling policy change while corresponding functionality is disabled."));
|
---|
3910 | return E_UNEXPECTED;
|
---|
3911 | #endif /* !VBOX_WITH_HGCM || !VBOX_WITH_CROGL */
|
---|
3912 | }
|
---|
3913 |
|
---|
3914 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
3915 | DECLCALLBACK(void) Display::i_displayCrVRecScreenshotPerform(void *pvCtx, uint32_t uScreen,
|
---|
3916 | uint32_t x, uint32_t y,
|
---|
3917 | uint32_t uBitsPerPixel, uint32_t uBytesPerLine,
|
---|
3918 | uint32_t uGuestWidth, uint32_t uGuestHeight,
|
---|
3919 | uint8_t *pu8BufferAddress, uint64_t u64Timestamp)
|
---|
3920 | {
|
---|
3921 | Display *pDisplay = (Display *)pvCtx;
|
---|
3922 | pDisplay->i_handleCrVRecScreenshotPerform(uScreen,
|
---|
3923 | x, y, BitmapFormat_BGR, uBitsPerPixel,
|
---|
3924 | uBytesPerLine, uGuestWidth, uGuestHeight,
|
---|
3925 | pu8BufferAddress, u64Timestamp);
|
---|
3926 | }
|
---|
3927 |
|
---|
3928 | DECLCALLBACK(bool) Display::i_displayCrVRecScreenshotBegin(void *pvCtx, uint32_t uScreen, uint64_t u64Timestamp)
|
---|
3929 | {
|
---|
3930 | Display *pDisplay = (Display *)pvCtx;
|
---|
3931 | return pDisplay->i_handleCrVRecScreenshotBegin(uScreen, u64Timestamp);
|
---|
3932 | }
|
---|
3933 |
|
---|
3934 | DECLCALLBACK(void) Display::i_displayCrVRecScreenshotEnd(void *pvCtx, uint32_t uScreen, uint64_t u64Timestamp)
|
---|
3935 | {
|
---|
3936 | Display *pDisplay = (Display *)pvCtx;
|
---|
3937 | pDisplay->i_handleCrVRecScreenshotEnd(uScreen, u64Timestamp);
|
---|
3938 | }
|
---|
3939 |
|
---|
3940 | DECLCALLBACK(void) Display::i_displayVRecCompletion(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd, int rc, void *pvCompletion)
|
---|
3941 | {
|
---|
3942 | RT_NOREF(pCmd, cbCmd, rc);
|
---|
3943 | Display *pDisplay = (Display *)pvCompletion;
|
---|
3944 | pDisplay->i_handleVRecCompletion();
|
---|
3945 | }
|
---|
3946 |
|
---|
3947 | #endif
|
---|
3948 |
|
---|
3949 |
|
---|
3950 | #ifdef VBOX_WITH_HGSMI
|
---|
3951 | DECLCALLBACK(int) Display::i_displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags,
|
---|
3952 | bool fRenderThreadMode)
|
---|
3953 | {
|
---|
3954 | LogRelFlowFunc(("uScreenId %d\n", uScreenId));
|
---|
3955 |
|
---|
3956 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3957 | Display *pThis = pDrv->pDisplay;
|
---|
3958 |
|
---|
3959 | if (pThis->maFramebuffers[uScreenId].fVBVAEnabled && pThis->maFramebuffers[uScreenId].fRenderThreadMode != fRenderThreadMode)
|
---|
3960 | {
|
---|
3961 | LogRel(("Enabling different vbva mode\n"));
|
---|
3962 | #ifdef DEBUG_misha
|
---|
3963 | AssertMsgFailed(("enabling different vbva mode\n"));
|
---|
3964 | #endif
|
---|
3965 | return VERR_INVALID_STATE;
|
---|
3966 | }
|
---|
3967 |
|
---|
3968 | pThis->maFramebuffers[uScreenId].fVBVAEnabled = true;
|
---|
3969 | pThis->maFramebuffers[uScreenId].pVBVAHostFlags = pHostFlags;
|
---|
3970 | pThis->maFramebuffers[uScreenId].fRenderThreadMode = fRenderThreadMode;
|
---|
3971 | pThis->maFramebuffers[uScreenId].fVBVAForceResize = true;
|
---|
3972 |
|
---|
3973 | vbvaSetMemoryFlagsHGSMI(uScreenId, pThis->mfu32SupportedOrders, pThis->mfVideoAccelVRDP, &pThis->maFramebuffers[uScreenId]);
|
---|
3974 |
|
---|
3975 | return VINF_SUCCESS;
|
---|
3976 | }
|
---|
3977 |
|
---|
3978 | DECLCALLBACK(void) Display::i_displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId)
|
---|
3979 | {
|
---|
3980 | LogRelFlowFunc(("uScreenId %d\n", uScreenId));
|
---|
3981 |
|
---|
3982 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
3983 | Display *pThis = pDrv->pDisplay;
|
---|
3984 |
|
---|
3985 | DISPLAYFBINFO *pFBInfo = &pThis->maFramebuffers[uScreenId];
|
---|
3986 |
|
---|
3987 | bool fRenderThreadMode = pFBInfo->fRenderThreadMode;
|
---|
3988 |
|
---|
3989 | if (uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
|
---|
3990 | {
|
---|
3991 | /* Make sure that the primary screen is visible now.
|
---|
3992 | * The guest can't use VBVA anymore, so only only the VGA device output works.
|
---|
3993 | */
|
---|
3994 | pFBInfo->flags = 0;
|
---|
3995 | if (pFBInfo->fDisabled)
|
---|
3996 | {
|
---|
3997 | pFBInfo->fDisabled = false;
|
---|
3998 | fireGuestMonitorChangedEvent(pThis->mParent->i_getEventSource(),
|
---|
3999 | GuestMonitorChangedEventType_Enabled,
|
---|
4000 | uScreenId,
|
---|
4001 | pFBInfo->xOrigin, pFBInfo->yOrigin,
|
---|
4002 | pFBInfo->w, pFBInfo->h);
|
---|
4003 | }
|
---|
4004 | }
|
---|
4005 |
|
---|
4006 | pFBInfo->fVBVAEnabled = false;
|
---|
4007 | pFBInfo->fVBVAForceResize = false;
|
---|
4008 | pFBInfo->fRenderThreadMode = false;
|
---|
4009 |
|
---|
4010 | vbvaSetMemoryFlagsHGSMI(uScreenId, 0, false, pFBInfo);
|
---|
4011 |
|
---|
4012 | pFBInfo->pVBVAHostFlags = NULL;
|
---|
4013 |
|
---|
4014 | if (!fRenderThreadMode && uScreenId == VBOX_VIDEO_PRIMARY_SCREEN)
|
---|
4015 | {
|
---|
4016 | /* Force full screen update, because VGA device must take control, do resize, etc. */
|
---|
4017 | pThis->mpDrv->pUpPort->pfnUpdateDisplayAll(pThis->mpDrv->pUpPort, /* fFailOnResize = */ false);
|
---|
4018 | }
|
---|
4019 | }
|
---|
4020 |
|
---|
4021 | DECLCALLBACK(void) Display::i_displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId)
|
---|
4022 | {
|
---|
4023 | RT_NOREF(uScreenId);
|
---|
4024 | LogFlowFunc(("uScreenId %d\n", uScreenId));
|
---|
4025 |
|
---|
4026 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
4027 | Display *pThis = pDrv->pDisplay;
|
---|
4028 |
|
---|
4029 | if (ASMAtomicReadU32(&pThis->mu32UpdateVBVAFlags) > 0)
|
---|
4030 | {
|
---|
4031 | vbvaSetMemoryFlagsAllHGSMI(pThis->mfu32SupportedOrders, pThis->mfVideoAccelVRDP, pThis->maFramebuffers,
|
---|
4032 | pThis->mcMonitors);
|
---|
4033 | ASMAtomicDecU32(&pThis->mu32UpdateVBVAFlags);
|
---|
4034 | }
|
---|
4035 | }
|
---|
4036 |
|
---|
4037 | DECLCALLBACK(void) Display::i_displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
|
---|
4038 | PCVBVACMDHDR pCmd, size_t cbCmd)
|
---|
4039 | {
|
---|
4040 | LogFlowFunc(("uScreenId %d pCmd %p cbCmd %d, @%d,%d %dx%d\n", uScreenId, pCmd, cbCmd, pCmd->x, pCmd->y, pCmd->w, pCmd->h));
|
---|
4041 |
|
---|
4042 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
4043 | Display *pThis = pDrv->pDisplay;
|
---|
4044 | DISPLAYFBINFO *pFBInfo = &pThis->maFramebuffers[uScreenId];
|
---|
4045 |
|
---|
4046 | if (pFBInfo->fDefaultFormat)
|
---|
4047 | {
|
---|
4048 | /* Make sure that framebuffer contains the same image as the guest VRAM. */
|
---|
4049 | if ( uScreenId == VBOX_VIDEO_PRIMARY_SCREEN
|
---|
4050 | && !pFBInfo->fDisabled)
|
---|
4051 | {
|
---|
4052 | pDrv->pUpPort->pfnUpdateDisplayRect(pDrv->pUpPort, pCmd->x, pCmd->y, pCmd->w, pCmd->h);
|
---|
4053 | }
|
---|
4054 | else if ( !pFBInfo->pSourceBitmap.isNull()
|
---|
4055 | && !pFBInfo->fDisabled)
|
---|
4056 | {
|
---|
4057 | /* Render VRAM content to the framebuffer. */
|
---|
4058 | BYTE *pAddress = NULL;
|
---|
4059 | ULONG ulWidth = 0;
|
---|
4060 | ULONG ulHeight = 0;
|
---|
4061 | ULONG ulBitsPerPixel = 0;
|
---|
4062 | ULONG ulBytesPerLine = 0;
|
---|
4063 | BitmapFormat_T bitmapFormat = BitmapFormat_Opaque;
|
---|
4064 |
|
---|
4065 | HRESULT hrc = pFBInfo->pSourceBitmap->QueryBitmapInfo(&pAddress,
|
---|
4066 | &ulWidth,
|
---|
4067 | &ulHeight,
|
---|
4068 | &ulBitsPerPixel,
|
---|
4069 | &ulBytesPerLine,
|
---|
4070 | &bitmapFormat);
|
---|
4071 | if (SUCCEEDED(hrc))
|
---|
4072 | {
|
---|
4073 | uint32_t width = pCmd->w;
|
---|
4074 | uint32_t height = pCmd->h;
|
---|
4075 |
|
---|
4076 | const uint8_t *pu8Src = pFBInfo->pu8FramebufferVRAM;
|
---|
4077 | int32_t xSrc = pCmd->x - pFBInfo->xOrigin;
|
---|
4078 | int32_t ySrc = pCmd->y - pFBInfo->yOrigin;
|
---|
4079 | uint32_t u32SrcWidth = pFBInfo->w;
|
---|
4080 | uint32_t u32SrcHeight = pFBInfo->h;
|
---|
4081 | uint32_t u32SrcLineSize = pFBInfo->u32LineSize;
|
---|
4082 | uint32_t u32SrcBitsPerPixel = pFBInfo->u16BitsPerPixel;
|
---|
4083 |
|
---|
4084 | uint8_t *pu8Dst = pAddress;
|
---|
4085 | int32_t xDst = xSrc;
|
---|
4086 | int32_t yDst = ySrc;
|
---|
4087 | uint32_t u32DstWidth = u32SrcWidth;
|
---|
4088 | uint32_t u32DstHeight = u32SrcHeight;
|
---|
4089 | uint32_t u32DstLineSize = u32DstWidth * 4;
|
---|
4090 | uint32_t u32DstBitsPerPixel = 32;
|
---|
4091 |
|
---|
4092 | pDrv->pUpPort->pfnCopyRect(pDrv->pUpPort,
|
---|
4093 | width, height,
|
---|
4094 | pu8Src,
|
---|
4095 | xSrc, ySrc,
|
---|
4096 | u32SrcWidth, u32SrcHeight,
|
---|
4097 | u32SrcLineSize, u32SrcBitsPerPixel,
|
---|
4098 | pu8Dst,
|
---|
4099 | xDst, yDst,
|
---|
4100 | u32DstWidth, u32DstHeight,
|
---|
4101 | u32DstLineSize, u32DstBitsPerPixel);
|
---|
4102 | }
|
---|
4103 | }
|
---|
4104 | }
|
---|
4105 |
|
---|
4106 | VBVACMDHDR hdrSaved = *pCmd;
|
---|
4107 |
|
---|
4108 | VBVACMDHDR *pHdrUnconst = (VBVACMDHDR *)pCmd;
|
---|
4109 |
|
---|
4110 | pHdrUnconst->x -= (int16_t)pFBInfo->xOrigin;
|
---|
4111 | pHdrUnconst->y -= (int16_t)pFBInfo->yOrigin;
|
---|
4112 |
|
---|
4113 | /** @todo new SendUpdate entry which can get a separate cmd header or coords. */
|
---|
4114 | pThis->mParent->i_consoleVRDPServer()->SendUpdate(uScreenId, pHdrUnconst, (uint32_t)cbCmd);
|
---|
4115 |
|
---|
4116 | *pHdrUnconst = hdrSaved;
|
---|
4117 | }
|
---|
4118 |
|
---|
4119 | DECLCALLBACK(void) Display::i_displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y,
|
---|
4120 | uint32_t cx, uint32_t cy)
|
---|
4121 | {
|
---|
4122 | LogFlowFunc(("uScreenId %d %d,%d %dx%d\n", uScreenId, x, y, cx, cy));
|
---|
4123 |
|
---|
4124 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
4125 | Display *pThis = pDrv->pDisplay;
|
---|
4126 | DISPLAYFBINFO *pFBInfo = &pThis->maFramebuffers[uScreenId];
|
---|
4127 |
|
---|
4128 | /** @todo handleFramebufferUpdate (uScreenId,
|
---|
4129 | * x - pThis->maFramebuffers[uScreenId].xOrigin,
|
---|
4130 | * y - pThis->maFramebuffers[uScreenId].yOrigin,
|
---|
4131 | * cx, cy);
|
---|
4132 | */
|
---|
4133 | pThis->i_handleDisplayUpdate(uScreenId, x - pFBInfo->xOrigin, y - pFBInfo->yOrigin, cx, cy);
|
---|
4134 | }
|
---|
4135 |
|
---|
4136 | #ifdef DEBUG_sunlover
|
---|
4137 | static void logVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, const DISPLAYFBINFO *pFBInfo)
|
---|
4138 | {
|
---|
4139 | LogRel(("displayVBVAResize: [%d] %s\n"
|
---|
4140 | " pView->u32ViewIndex %d\n"
|
---|
4141 | " pView->u32ViewOffset 0x%08X\n"
|
---|
4142 | " pView->u32ViewSize 0x%08X\n"
|
---|
4143 | " pView->u32MaxScreenSize 0x%08X\n"
|
---|
4144 | " pScreen->i32OriginX %d\n"
|
---|
4145 | " pScreen->i32OriginY %d\n"
|
---|
4146 | " pScreen->u32StartOffset 0x%08X\n"
|
---|
4147 | " pScreen->u32LineSize 0x%08X\n"
|
---|
4148 | " pScreen->u32Width %d\n"
|
---|
4149 | " pScreen->u32Height %d\n"
|
---|
4150 | " pScreen->u16BitsPerPixel %d\n"
|
---|
4151 | " pScreen->u16Flags 0x%04X\n"
|
---|
4152 | " pFBInfo->u32Offset 0x%08X\n"
|
---|
4153 | " pFBInfo->u32MaxFramebufferSize 0x%08X\n"
|
---|
4154 | " pFBInfo->u32InformationSize 0x%08X\n"
|
---|
4155 | " pFBInfo->fDisabled %d\n"
|
---|
4156 | " xOrigin, yOrigin, w, h: %d,%d %dx%d\n"
|
---|
4157 | " pFBInfo->u16BitsPerPixel %d\n"
|
---|
4158 | " pFBInfo->pu8FramebufferVRAM %p\n"
|
---|
4159 | " pFBInfo->u32LineSize 0x%08X\n"
|
---|
4160 | " pFBInfo->flags 0x%04X\n"
|
---|
4161 | " pFBInfo->pHostEvents %p\n"
|
---|
4162 | " pFBInfo->fDefaultFormat %d\n"
|
---|
4163 | " pFBInfo->fVBVAEnabled %d\n"
|
---|
4164 | " pFBInfo->fVBVAForceResize %d\n"
|
---|
4165 | " pFBInfo->pVBVAHostFlags %p\n"
|
---|
4166 | "",
|
---|
4167 | pScreen->u32ViewIndex,
|
---|
4168 | (pScreen->u16Flags & VBVA_SCREEN_F_DISABLED)? "DISABLED": "ENABLED",
|
---|
4169 | pView->u32ViewIndex,
|
---|
4170 | pView->u32ViewOffset,
|
---|
4171 | pView->u32ViewSize,
|
---|
4172 | pView->u32MaxScreenSize,
|
---|
4173 | pScreen->i32OriginX,
|
---|
4174 | pScreen->i32OriginY,
|
---|
4175 | pScreen->u32StartOffset,
|
---|
4176 | pScreen->u32LineSize,
|
---|
4177 | pScreen->u32Width,
|
---|
4178 | pScreen->u32Height,
|
---|
4179 | pScreen->u16BitsPerPixel,
|
---|
4180 | pScreen->u16Flags,
|
---|
4181 | pFBInfo->u32Offset,
|
---|
4182 | pFBInfo->u32MaxFramebufferSize,
|
---|
4183 | pFBInfo->u32InformationSize,
|
---|
4184 | pFBInfo->fDisabled,
|
---|
4185 | pFBInfo->xOrigin,
|
---|
4186 | pFBInfo->yOrigin,
|
---|
4187 | pFBInfo->w,
|
---|
4188 | pFBInfo->h,
|
---|
4189 | pFBInfo->u16BitsPerPixel,
|
---|
4190 | pFBInfo->pu8FramebufferVRAM,
|
---|
4191 | pFBInfo->u32LineSize,
|
---|
4192 | pFBInfo->flags,
|
---|
4193 | pFBInfo->pHostEvents,
|
---|
4194 | pFBInfo->fDefaultFormat,
|
---|
4195 | pFBInfo->fVBVAEnabled,
|
---|
4196 | pFBInfo->fVBVAForceResize,
|
---|
4197 | pFBInfo->pVBVAHostFlags
|
---|
4198 | ));
|
---|
4199 | }
|
---|
4200 | #endif /* DEBUG_sunlover */
|
---|
4201 |
|
---|
4202 | DECLCALLBACK(int) Display::i_displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, PCVBVAINFOVIEW pView,
|
---|
4203 | PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping)
|
---|
4204 | {
|
---|
4205 | LogRelFlowFunc(("pScreen %p, pvVRAM %p\n", pScreen, pvVRAM));
|
---|
4206 |
|
---|
4207 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
4208 | Display *pThis = pDrv->pDisplay;
|
---|
4209 |
|
---|
4210 | return pThis->processVBVAResize(pView, pScreen, pvVRAM, fResetInputMapping);
|
---|
4211 | }
|
---|
4212 |
|
---|
4213 | int Display::processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping)
|
---|
4214 | {
|
---|
4215 | AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
|
---|
4216 |
|
---|
4217 | DISPLAYFBINFO *pFBInfo = &maFramebuffers[pScreen->u32ViewIndex];
|
---|
4218 |
|
---|
4219 | if (pScreen->u16Flags & VBVA_SCREEN_F_DISABLED)
|
---|
4220 | {
|
---|
4221 | /* Ask the framebuffer to resize using a default format. The framebuffer will be black.
|
---|
4222 | * So if the frontend does not support GuestMonitorChangedEventType_Disabled event,
|
---|
4223 | * the VM window will be black. */
|
---|
4224 | uint32_t u32Width = pFBInfo->w ? pFBInfo->w : 640;
|
---|
4225 | uint32_t u32Height = pFBInfo->h ? pFBInfo->h : 480;
|
---|
4226 | int32_t xOrigin = pFBInfo->xOrigin;
|
---|
4227 | int32_t yOrigin = pFBInfo->yOrigin;
|
---|
4228 |
|
---|
4229 | alock.release();
|
---|
4230 |
|
---|
4231 | i_notifyCroglResize(pView, pScreen, pvVRAM);
|
---|
4232 |
|
---|
4233 | i_handleDisplayResize(pScreen->u32ViewIndex, 0, (uint8_t *)NULL, 0,
|
---|
4234 | u32Width, u32Height, pScreen->u16Flags, xOrigin, yOrigin, false);
|
---|
4235 |
|
---|
4236 | return VINF_SUCCESS;
|
---|
4237 | }
|
---|
4238 |
|
---|
4239 | VBVAINFOSCREEN screenInfo;
|
---|
4240 | RT_ZERO(screenInfo);
|
---|
4241 |
|
---|
4242 | if (pScreen->u16Flags & VBVA_SCREEN_F_BLANK2)
|
---|
4243 | {
|
---|
4244 | /* Init a local VBVAINFOSCREEN structure, which will be used instead of
|
---|
4245 | * the original pScreen. Set VBVA_SCREEN_F_BLANK, which will force
|
---|
4246 | * the code below to choose the "blanking" branches.
|
---|
4247 | */
|
---|
4248 | screenInfo.u32ViewIndex = pScreen->u32ViewIndex;
|
---|
4249 | screenInfo.i32OriginX = pFBInfo->xOrigin;
|
---|
4250 | screenInfo.i32OriginY = pFBInfo->yOrigin;
|
---|
4251 | screenInfo.u32StartOffset = 0; /* Irrelevant */
|
---|
4252 | screenInfo.u32LineSize = pFBInfo->u32LineSize;
|
---|
4253 | screenInfo.u32Width = pFBInfo->w;
|
---|
4254 | screenInfo.u32Height = pFBInfo->h;
|
---|
4255 | screenInfo.u16BitsPerPixel = pFBInfo->u16BitsPerPixel;
|
---|
4256 | screenInfo.u16Flags = pScreen->u16Flags | VBVA_SCREEN_F_BLANK;
|
---|
4257 |
|
---|
4258 | pScreen = &screenInfo;
|
---|
4259 | }
|
---|
4260 |
|
---|
4261 | if (fResetInputMapping)
|
---|
4262 | {
|
---|
4263 | /// @todo Rename to m* and verify whether some kind of lock is required.
|
---|
4264 | xInputMappingOrigin = 0;
|
---|
4265 | yInputMappingOrigin = 0;
|
---|
4266 | cxInputMapping = 0;
|
---|
4267 | cyInputMapping = 0;
|
---|
4268 | }
|
---|
4269 |
|
---|
4270 | alock.release();
|
---|
4271 |
|
---|
4272 | i_notifyCroglResize(pView, pScreen, pvVRAM);
|
---|
4273 |
|
---|
4274 | return i_handleDisplayResize(pScreen->u32ViewIndex, pScreen->u16BitsPerPixel,
|
---|
4275 | (uint8_t *)pvVRAM + pScreen->u32StartOffset,
|
---|
4276 | pScreen->u32LineSize, pScreen->u32Width, pScreen->u32Height, pScreen->u16Flags,
|
---|
4277 | pScreen->i32OriginX, pScreen->i32OriginY, false);
|
---|
4278 | }
|
---|
4279 |
|
---|
4280 | DECLCALLBACK(int) Display::i_displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
|
---|
4281 | uint32_t xHot, uint32_t yHot,
|
---|
4282 | uint32_t cx, uint32_t cy,
|
---|
4283 | const void *pvShape)
|
---|
4284 | {
|
---|
4285 | LogFlowFunc(("\n"));
|
---|
4286 |
|
---|
4287 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
4288 |
|
---|
4289 | uint32_t cbShape = 0;
|
---|
4290 | if (pvShape)
|
---|
4291 | {
|
---|
4292 | cbShape = (cx + 7) / 8 * cy; /* size of the AND mask */
|
---|
4293 | cbShape = ((cbShape + 3) & ~3) + cx * 4 * cy; /* + gap + size of the XOR mask */
|
---|
4294 | }
|
---|
4295 |
|
---|
4296 | /* Tell the console about it */
|
---|
4297 | pDrv->pDisplay->mParent->i_onMousePointerShapeChange(fVisible, fAlpha,
|
---|
4298 | xHot, yHot, cx, cy, (uint8_t *)pvShape, cbShape);
|
---|
4299 |
|
---|
4300 | return VINF_SUCCESS;
|
---|
4301 | }
|
---|
4302 |
|
---|
4303 | DECLCALLBACK(void) Display::i_displayVBVAGuestCapabilityUpdate(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fCapabilities)
|
---|
4304 | {
|
---|
4305 | LogFlowFunc(("\n"));
|
---|
4306 |
|
---|
4307 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
4308 | Display *pThis = pDrv->pDisplay;
|
---|
4309 |
|
---|
4310 | pThis->i_handleUpdateGuestVBVACapabilities(fCapabilities);
|
---|
4311 | }
|
---|
4312 |
|
---|
4313 | DECLCALLBACK(void) Display::i_displayVBVAInputMappingUpdate(PPDMIDISPLAYCONNECTOR pInterface, int32_t xOrigin, int32_t yOrigin,
|
---|
4314 | uint32_t cx, uint32_t cy)
|
---|
4315 | {
|
---|
4316 | LogFlowFunc(("\n"));
|
---|
4317 |
|
---|
4318 | PDRVMAINDISPLAY pDrv = PDMIDISPLAYCONNECTOR_2_MAINDISPLAY(pInterface);
|
---|
4319 | Display *pThis = pDrv->pDisplay;
|
---|
4320 |
|
---|
4321 | pThis->i_handleUpdateVBVAInputMapping(xOrigin, yOrigin, cx, cy);
|
---|
4322 | }
|
---|
4323 |
|
---|
4324 | #endif /* VBOX_WITH_HGSMI */
|
---|
4325 |
|
---|
4326 | /**
|
---|
4327 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
4328 | */
|
---|
4329 | DECLCALLBACK(void *) Display::i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
4330 | {
|
---|
4331 | PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
|
---|
4332 | PDRVMAINDISPLAY pDrv = PDMINS_2_DATA(pDrvIns, PDRVMAINDISPLAY);
|
---|
4333 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
|
---|
4334 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIDISPLAYCONNECTOR, &pDrv->IConnector);
|
---|
4335 | return NULL;
|
---|
4336 | }
|
---|
4337 |
|
---|
4338 |
|
---|
4339 | /**
|
---|
4340 | * Destruct a display driver instance.
|
---|
4341 | *
|
---|
4342 | * @returns VBox status code.
|
---|
4343 | * @param pDrvIns The driver instance data.
|
---|
4344 | */
|
---|
4345 | DECLCALLBACK(void) Display::i_drvDestruct(PPDMDRVINS pDrvIns)
|
---|
4346 | {
|
---|
4347 | PDMDRV_CHECK_VERSIONS_RETURN_VOID(pDrvIns);
|
---|
4348 | PDRVMAINDISPLAY pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINDISPLAY);
|
---|
4349 | LogRelFlowFunc(("iInstance=%d\n", pDrvIns->iInstance));
|
---|
4350 |
|
---|
4351 | pThis->pUpPort->pfnSetRenderVRAM(pThis->pUpPort, false);
|
---|
4352 |
|
---|
4353 | pThis->IConnector.pbData = NULL;
|
---|
4354 | pThis->IConnector.cbScanline = 0;
|
---|
4355 | pThis->IConnector.cBits = 32;
|
---|
4356 | pThis->IConnector.cx = 0;
|
---|
4357 | pThis->IConnector.cy = 0;
|
---|
4358 |
|
---|
4359 | if (pThis->pDisplay)
|
---|
4360 | {
|
---|
4361 | AutoWriteLock displayLock(pThis->pDisplay COMMA_LOCKVAL_SRC_POS);
|
---|
4362 | #ifdef VBOX_WITH_VIDEOREC
|
---|
4363 | pThis->pDisplay->i_videoCaptureStop();
|
---|
4364 | #endif
|
---|
4365 | #ifdef VBOX_WITH_CRHGSMI
|
---|
4366 | pThis->pDisplay->i_destructCrHgsmiData();
|
---|
4367 | #endif
|
---|
4368 | pThis->pDisplay->mpDrv = NULL;
|
---|
4369 | pThis->pDisplay->mpVMMDev = NULL;
|
---|
4370 | }
|
---|
4371 | }
|
---|
4372 |
|
---|
4373 |
|
---|
4374 | /**
|
---|
4375 | * Construct a display driver instance.
|
---|
4376 | *
|
---|
4377 | * @copydoc FNPDMDRVCONSTRUCT
|
---|
4378 | */
|
---|
4379 | DECLCALLBACK(int) Display::i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
|
---|
4380 | {
|
---|
4381 | RT_NOREF(fFlags);
|
---|
4382 | PDMDRV_CHECK_VERSIONS_RETURN(pDrvIns);
|
---|
4383 | PDRVMAINDISPLAY pThis = PDMINS_2_DATA(pDrvIns, PDRVMAINDISPLAY);
|
---|
4384 | LogRelFlowFunc(("iInstance=%d\n", pDrvIns->iInstance));
|
---|
4385 |
|
---|
4386 | /*
|
---|
4387 | * Validate configuration.
|
---|
4388 | */
|
---|
4389 | if (!CFGMR3AreValuesValid(pCfg, "Object\0"))
|
---|
4390 | return VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES;
|
---|
4391 | AssertMsgReturn(PDMDrvHlpNoAttach(pDrvIns) == VERR_PDM_NO_ATTACHED_DRIVER,
|
---|
4392 | ("Configuration error: Not possible to attach anything to this driver!\n"),
|
---|
4393 | VERR_PDM_DRVINS_NO_ATTACH);
|
---|
4394 |
|
---|
4395 | /*
|
---|
4396 | * Init Interfaces.
|
---|
4397 | */
|
---|
4398 | pDrvIns->IBase.pfnQueryInterface = Display::i_drvQueryInterface;
|
---|
4399 |
|
---|
4400 | pThis->IConnector.pfnResize = Display::i_displayResizeCallback;
|
---|
4401 | pThis->IConnector.pfnUpdateRect = Display::i_displayUpdateCallback;
|
---|
4402 | pThis->IConnector.pfnRefresh = Display::i_displayRefreshCallback;
|
---|
4403 | pThis->IConnector.pfnReset = Display::i_displayResetCallback;
|
---|
4404 | pThis->IConnector.pfnLFBModeChange = Display::i_displayLFBModeChangeCallback;
|
---|
4405 | pThis->IConnector.pfnProcessAdapterData = Display::i_displayProcessAdapterDataCallback;
|
---|
4406 | pThis->IConnector.pfnProcessDisplayData = Display::i_displayProcessDisplayDataCallback;
|
---|
4407 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
4408 | pThis->IConnector.pfnVHWACommandProcess = Display::i_displayVHWACommandProcess;
|
---|
4409 | #endif
|
---|
4410 | #ifdef VBOX_WITH_CRHGSMI
|
---|
4411 | pThis->IConnector.pfnCrHgsmiCommandProcess = Display::i_displayCrHgsmiCommandProcess;
|
---|
4412 | pThis->IConnector.pfnCrHgsmiControlProcess = Display::i_displayCrHgsmiControlProcess;
|
---|
4413 | #endif
|
---|
4414 | #if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
|
---|
4415 | pThis->IConnector.pfnCrHgcmCtlSubmit = Display::i_displayCrHgcmCtlSubmit;
|
---|
4416 | #endif
|
---|
4417 | #ifdef VBOX_WITH_HGSMI
|
---|
4418 | pThis->IConnector.pfnVBVAEnable = Display::i_displayVBVAEnable;
|
---|
4419 | pThis->IConnector.pfnVBVADisable = Display::i_displayVBVADisable;
|
---|
4420 | pThis->IConnector.pfnVBVAUpdateBegin = Display::i_displayVBVAUpdateBegin;
|
---|
4421 | pThis->IConnector.pfnVBVAUpdateProcess = Display::i_displayVBVAUpdateProcess;
|
---|
4422 | pThis->IConnector.pfnVBVAUpdateEnd = Display::i_displayVBVAUpdateEnd;
|
---|
4423 | pThis->IConnector.pfnVBVAResize = Display::i_displayVBVAResize;
|
---|
4424 | pThis->IConnector.pfnVBVAMousePointerShape = Display::i_displayVBVAMousePointerShape;
|
---|
4425 | pThis->IConnector.pfnVBVAGuestCapabilityUpdate = Display::i_displayVBVAGuestCapabilityUpdate;
|
---|
4426 | pThis->IConnector.pfnVBVAInputMappingUpdate = Display::i_displayVBVAInputMappingUpdate;
|
---|
4427 | #endif
|
---|
4428 |
|
---|
4429 | /*
|
---|
4430 | * Get the IDisplayPort interface of the above driver/device.
|
---|
4431 | */
|
---|
4432 | pThis->pUpPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIDISPLAYPORT);
|
---|
4433 | if (!pThis->pUpPort)
|
---|
4434 | {
|
---|
4435 | AssertMsgFailed(("Configuration error: No display port interface above!\n"));
|
---|
4436 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
4437 | }
|
---|
4438 | #if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_WITH_CRHGSMI)
|
---|
4439 | pThis->pVBVACallbacks = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIDISPLAYVBVACALLBACKS);
|
---|
4440 | if (!pThis->pVBVACallbacks)
|
---|
4441 | {
|
---|
4442 | AssertMsgFailed(("Configuration error: No VBVA callback interface above!\n"));
|
---|
4443 | return VERR_PDM_MISSING_INTERFACE_ABOVE;
|
---|
4444 | }
|
---|
4445 | #endif
|
---|
4446 | /*
|
---|
4447 | * Get the Display object pointer and update the mpDrv member.
|
---|
4448 | */
|
---|
4449 | void *pv;
|
---|
4450 | int rc = CFGMR3QueryPtr(pCfg, "Object", &pv);
|
---|
4451 | if (RT_FAILURE(rc))
|
---|
4452 | {
|
---|
4453 | AssertMsgFailed(("Configuration error: No/bad \"Object\" value! rc=%Rrc\n", rc));
|
---|
4454 | return rc;
|
---|
4455 | }
|
---|
4456 | Display *pDisplay = (Display *)pv; /** @todo Check this cast! */
|
---|
4457 | pThis->pDisplay = pDisplay;
|
---|
4458 | pThis->pDisplay->mpDrv = pThis;
|
---|
4459 |
|
---|
4460 | /* Disable VRAM to a buffer copy initially. */
|
---|
4461 | pThis->pUpPort->pfnSetRenderVRAM(pThis->pUpPort, false);
|
---|
4462 | pThis->IConnector.cBits = 32; /* DevVGA does nothing otherwise. */
|
---|
4463 |
|
---|
4464 | /*
|
---|
4465 | * Start periodic screen refreshes
|
---|
4466 | */
|
---|
4467 | pThis->pUpPort->pfnSetRefreshRate(pThis->pUpPort, 20);
|
---|
4468 |
|
---|
4469 | #ifdef VBOX_WITH_CRHGSMI
|
---|
4470 | pDisplay->i_setupCrHgsmiData();
|
---|
4471 | #endif
|
---|
4472 |
|
---|
4473 | #ifdef VBOX_WITH_VIDEOREC
|
---|
4474 | ComPtr<IMachine> pMachine = pDisplay->mParent->i_machine();
|
---|
4475 | BOOL fEnabled = false;
|
---|
4476 | HRESULT hrc = pMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
|
---|
4477 | AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
|
---|
4478 |
|
---|
4479 | if (fEnabled)
|
---|
4480 | {
|
---|
4481 | rc = pDisplay->i_videoCaptureStart();
|
---|
4482 | fireVideoCaptureChangedEvent(pDisplay->mParent->i_getEventSource());
|
---|
4483 | }
|
---|
4484 | #endif
|
---|
4485 |
|
---|
4486 | return rc;
|
---|
4487 | }
|
---|
4488 |
|
---|
4489 |
|
---|
4490 | /**
|
---|
4491 | * Display driver registration record.
|
---|
4492 | */
|
---|
4493 | const PDMDRVREG Display::DrvReg =
|
---|
4494 | {
|
---|
4495 | /* u32Version */
|
---|
4496 | PDM_DRVREG_VERSION,
|
---|
4497 | /* szName */
|
---|
4498 | "MainDisplay",
|
---|
4499 | /* szRCMod */
|
---|
4500 | "",
|
---|
4501 | /* szR0Mod */
|
---|
4502 | "",
|
---|
4503 | /* pszDescription */
|
---|
4504 | "Main display driver (Main as in the API).",
|
---|
4505 | /* fFlags */
|
---|
4506 | PDM_DRVREG_FLAGS_HOST_BITS_DEFAULT,
|
---|
4507 | /* fClass. */
|
---|
4508 | PDM_DRVREG_CLASS_DISPLAY,
|
---|
4509 | /* cMaxInstances */
|
---|
4510 | ~0U,
|
---|
4511 | /* cbInstance */
|
---|
4512 | sizeof(DRVMAINDISPLAY),
|
---|
4513 | /* pfnConstruct */
|
---|
4514 | Display::i_drvConstruct,
|
---|
4515 | /* pfnDestruct */
|
---|
4516 | Display::i_drvDestruct,
|
---|
4517 | /* pfnRelocate */
|
---|
4518 | NULL,
|
---|
4519 | /* pfnIOCtl */
|
---|
4520 | NULL,
|
---|
4521 | /* pfnPowerOn */
|
---|
4522 | NULL,
|
---|
4523 | /* pfnReset */
|
---|
4524 | NULL,
|
---|
4525 | /* pfnSuspend */
|
---|
4526 | NULL,
|
---|
4527 | /* pfnResume */
|
---|
4528 | NULL,
|
---|
4529 | /* pfnAttach */
|
---|
4530 | NULL,
|
---|
4531 | /* pfnDetach */
|
---|
4532 | NULL,
|
---|
4533 | /* pfnPowerOff */
|
---|
4534 | NULL,
|
---|
4535 | /* pfnSoftReset */
|
---|
4536 | NULL,
|
---|
4537 | /* u32EndVersion */
|
---|
4538 | PDM_DRVREG_VERSION
|
---|
4539 | };
|
---|
4540 |
|
---|
4541 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|