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