VirtualBox

source: vbox/trunk/src/VBox/Main/include/DisplayImpl.h@ 75345

Last change on this file since 75345 was 75345, checked in by vboxsync, 6 years ago

Recording: VBOX_WITH_VIDEOREC -> VBOX_WITH_RECORDING.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 27.9 KB
Line 
1/* $Id: DisplayImpl.h 75345 2018-11-09 10:03:36Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2018 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#ifndef ____H_DISPLAYIMPL
19#define ____H_DISPLAYIMPL
20
21#include "SchemaDefs.h"
22
23#include <iprt/semaphore.h>
24#include <VBox/vmm/pdmdrv.h>
25#include <VBox/VMMDev.h>
26#include <VBoxVideo.h>
27#include <VBox/vmm/pdmifs.h>
28#include "DisplayWrap.h"
29
30#ifdef VBOX_WITH_CROGL
31# include <VBox/HostServices/VBoxCrOpenGLSvc.h>
32#endif
33
34#include "DisplaySourceBitmapWrap.h"
35#include "GuestScreenInfoWrap.h"
36
37
38class Console;
39
40typedef struct _DISPLAYFBINFO
41{
42 /* The following 3 fields (u32Offset, u32MaxFramebufferSize and u32InformationSize)
43 * are not used by the current HGSMI. They are needed for backward compatibility with
44 * pre-HGSMI additions.
45 */
46 uint32_t u32Offset;
47 uint32_t u32MaxFramebufferSize;
48 uint32_t u32InformationSize;
49
50 ComPtr<IFramebuffer> pFramebuffer;
51 com::Guid framebufferId;
52 ComPtr<IDisplaySourceBitmap> pSourceBitmap;
53 bool fDisabled;
54
55 uint32_t u32Caps;
56
57 struct
58 {
59 ComPtr<IDisplaySourceBitmap> pSourceBitmap;
60 uint8_t *pu8Address;
61 uint32_t cbLine;
62 } updateImage;
63
64 LONG xOrigin;
65 LONG yOrigin;
66
67 ULONG w;
68 ULONG h;
69
70 uint16_t u16BitsPerPixel;
71 uint8_t *pu8FramebufferVRAM;
72 uint32_t u32LineSize;
73
74 uint16_t flags;
75
76 VBOXVIDEOINFOHOSTEVENTS *pHostEvents;
77
78 /** The framebuffer has default format and must be updates immediately. */
79 bool fDefaultFormat;
80
81#ifdef VBOX_WITH_HGSMI
82 bool fVBVAEnabled;
83 bool fVBVAForceResize;
84 bool fRenderThreadMode;
85 VBVAHOSTFLAGS RT_UNTRUSTED_VOLATILE_GUEST *pVBVAHostFlags;
86#endif /* VBOX_WITH_HGSMI */
87
88#ifdef VBOX_WITH_CROGL
89 struct
90 {
91 bool fPending;
92 ULONG x;
93 ULONG y;
94 ULONG width;
95 ULONG height;
96 } pendingViewportInfo;
97#endif /* VBOX_WITH_CROGL */
98
99#ifdef VBOX_WITH_RECORDING
100 struct
101 {
102 ComPtr<IDisplaySourceBitmap> pSourceBitmap;
103 } videoRec;
104#endif /* VBOX_WITH_RECORDING */
105} DISPLAYFBINFO;
106
107/* The legacy VBVA (VideoAccel) data.
108 *
109 * Backward compatibility with the guest additions 3.x or older.
110 */
111typedef struct VIDEOACCEL
112{
113 VBVAMEMORY *pVbvaMemory;
114 bool fVideoAccelEnabled;
115
116 uint8_t *pu8VbvaPartial;
117 uint32_t cbVbvaPartial;
118
119 /* Old guest additions (3.x and older) use both VMMDev and DevVGA refresh timer
120 * to process the VBVABUFFER memory. Therefore the legacy VBVA (VideoAccel) host
121 * code can be executed concurrently by VGA refresh timer and the guest VMMDev
122 * request in SMP VMs. The semaphore serialized this.
123 */
124 RTSEMXROADS hXRoadsVideoAccel;
125
126} VIDEOACCEL;
127
128class DisplayMouseInterface
129{
130public:
131 virtual HRESULT i_getScreenResolution(ULONG cScreen, ULONG *pcx,
132 ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin) = 0;
133 virtual void i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
134 int32_t *px2, int32_t *py2) = 0;
135 virtual HRESULT i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved) = 0;
136 virtual HRESULT i_reportHostCursorPosition(int32_t x, int32_t y) = 0;
137 virtual bool i_isInputMappingSet(void) = 0;
138};
139
140class VMMDev;
141
142class ATL_NO_VTABLE Display :
143 public DisplayWrap,
144 public DisplayMouseInterface
145{
146public:
147
148 DECLARE_EMPTY_CTOR_DTOR(Display)
149
150 HRESULT FinalConstruct();
151 void FinalRelease();
152
153 // public initializer/uninitializer for internal purposes only
154 HRESULT init(Console *aParent);
155 void uninit();
156 int i_registerSSM(PUVM pUVM);
157
158 // public methods only for internal purposes
159 int i_handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM,
160 uint32_t cbLine, uint32_t w, uint32_t h, uint16_t flags,
161 int32_t xOrigin, int32_t yOrigin, bool fVGAResize);
162 void i_handleDisplayUpdate(unsigned uScreenId, int x, int y, int w, int h);
163 void i_handleUpdateVMMDevSupportsGraphics(bool fSupportsGraphics);
164 void i_handleUpdateGuestVBVACapabilities(uint32_t fNewCapabilities);
165 void i_handleUpdateVBVAInputMapping(int32_t xOrigin, int32_t yOrigin, uint32_t cx, uint32_t cy);
166#ifdef VBOX_WITH_VIDEOHWACCEL
167 int i_handleVHWACommandProcess(int enmCmd, bool fGuestCmd, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand);
168#endif
169#ifdef VBOX_WITH_CRHGSMI
170 void i_handleCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
171 void i_handleCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
172 void i_handleCrHgsmiCommandProcess(VBOXVDMACMD_CHROMIUM_CMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd);
173 void i_handleCrHgsmiControlProcess(VBOXVDMACMD_CHROMIUM_CTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl, uint32_t cbCtl);
174#endif
175#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
176 int i_handleCrHgcmCtlSubmit(struct VBOXCRCMDCTL RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd,
177 PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
178 void i_handleCrVRecScreenshotPerform(uint32_t uScreen,
179 uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,
180 uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
181 uint8_t *pu8BufferAddress, uint64_t uTimestampMs);
182 bool i_handleCrVRecScreenshotBegin(uint32_t uScreen, uint64_t uTimestampMs);
183 void i_handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t uTimestampMs);
184 void i_handleVRecCompletion();
185#endif
186
187 int i_notifyCroglResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM);
188
189 int i_saveVisibleRegion(uint32_t cRect, PRTRECT pRect);
190 int i_handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect);
191 int i_handleQueryVisibleRegion(uint32_t *pcRects, PRTRECT paRects);
192
193 void i_VideoAccelVRDP(bool fEnable);
194
195 /* Legacy video acceleration requests coming from the VGA refresh timer. */
196 int VideoAccelEnableVGA(bool fEnable, VBVAMEMORY *pVbvaMemory);
197
198 /* Legacy video acceleration requests coming from VMMDev. */
199 int VideoAccelEnableVMMDev(bool fEnable, VBVAMEMORY *pVbvaMemory);
200 void VideoAccelFlushVMMDev(void);
201
202#ifdef VBOX_WITH_RECORDING
203 int i_videoRecInvalidate(void);
204 void i_videoRecScreenChanged(unsigned uScreenId);
205#endif
206
207 void i_notifyPowerDown(void);
208
209 // DisplayMouseInterface methods
210 virtual HRESULT i_getScreenResolution(ULONG cScreen, ULONG *pcx,
211 ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin)
212 {
213 return getScreenResolution(cScreen, pcx, pcy, pcBPP, pXOrigin, pYOrigin, NULL);
214 }
215 virtual void i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
216 int32_t *px2, int32_t *py2);
217 virtual HRESULT i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved);
218 virtual HRESULT i_reportHostCursorPosition(int32_t x, int32_t y);
219 virtual bool i_isInputMappingSet(void)
220 {
221 return cxInputMapping != 0 && cyInputMapping != 0;
222 }
223
224 static const PDMDRVREG DrvReg;
225
226private:
227 // Wrapped IDisplay properties
228 virtual HRESULT getGuestScreenLayout(std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenLayout);
229
230 // Wrapped IDisplay methods
231 virtual HRESULT getScreenResolution(ULONG aScreenId,
232 ULONG *aWidth,
233 ULONG *aHeight,
234 ULONG *aBitsPerPixel,
235 LONG *aXOrigin,
236 LONG *aYOrigin,
237 GuestMonitorStatus_T *aGuestMonitorStatus);
238 virtual HRESULT attachFramebuffer(ULONG aScreenId,
239 const ComPtr<IFramebuffer> &aFramebuffer,
240 com::Guid &aId);
241 virtual HRESULT detachFramebuffer(ULONG aScreenId,
242 const com::Guid &aId);
243 virtual HRESULT queryFramebuffer(ULONG aScreenId,
244 ComPtr<IFramebuffer> &aFramebuffer);
245 virtual HRESULT setVideoModeHint(ULONG aDisplay,
246 BOOL aEnabled,
247 BOOL aChangeOrigin,
248 LONG aOriginX,
249 LONG aOriginY,
250 ULONG aWidth,
251 ULONG aHeight,
252 ULONG aBitsPerPixel);
253 virtual HRESULT setSeamlessMode(BOOL aEnabled);
254 virtual HRESULT takeScreenShot(ULONG aScreenId,
255 BYTE *aAddress,
256 ULONG aWidth,
257 ULONG aHeight,
258 BitmapFormat_T aBitmapFormat);
259 virtual HRESULT takeScreenShotToArray(ULONG aScreenId,
260 ULONG aWidth,
261 ULONG aHeight,
262 BitmapFormat_T aBitmapFormat,
263 std::vector<BYTE> &aScreenData);
264 virtual HRESULT drawToScreen(ULONG aScreenId,
265 BYTE *aAddress,
266 ULONG aX,
267 ULONG aY,
268 ULONG aWidth,
269 ULONG aHeight);
270 virtual HRESULT invalidateAndUpdate();
271 virtual HRESULT invalidateAndUpdateScreen(ULONG aScreenId);
272 virtual HRESULT completeVHWACommand(BYTE *aCommand);
273 virtual HRESULT viewportChanged(ULONG aScreenId,
274 ULONG aX,
275 ULONG aY,
276 ULONG aWidth,
277 ULONG aHeight);
278 virtual HRESULT querySourceBitmap(ULONG aScreenId,
279 ComPtr<IDisplaySourceBitmap> &aDisplaySourceBitmap);
280 virtual HRESULT notifyScaleFactorChange(ULONG aScreenId,
281 ULONG aScaleFactorWMultiplied,
282 ULONG aScaleFactorHMultiplied);
283 virtual HRESULT notifyHiDPIOutputPolicyChange(BOOL fUnscaledHiDPI);
284 virtual HRESULT setScreenLayout(ScreenLayoutMode_T aScreenLayoutMode,
285 const std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenInfo);
286 virtual HRESULT detachScreens(const std::vector<LONG> &aScreenIds);
287 virtual HRESULT createGuestScreenInfo(ULONG aDisplay,
288 GuestMonitorStatus_T aStatus,
289 BOOL aPrimary,
290 BOOL aChangeOrigin,
291 LONG aOriginX,
292 LONG aOriginY,
293 ULONG aWidth,
294 ULONG aHeight,
295 ULONG aBitsPerPixel,
296 ComPtr<IGuestScreenInfo> &aGuestScreenInfo);
297
298 // Wrapped IEventListener properties
299
300 // Wrapped IEventListener methods
301 virtual HRESULT handleEvent(const ComPtr<IEvent> &aEvent);
302
303 // other internal methods
304 HRESULT takeScreenShotWorker(ULONG aScreenId,
305 BYTE *aAddress,
306 ULONG aWidth,
307 ULONG aHeight,
308 BitmapFormat_T aBitmapFormat,
309 ULONG *pcbOut);
310 int processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping);
311
312#ifdef VBOX_WITH_CRHGSMI
313 void i_setupCrHgsmiData(void);
314 void i_destructCrHgsmiData(void);
315#endif
316
317#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
318 int i_crViewportNotify(ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height);
319#endif
320
321 static DECLCALLBACK(void*) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
322 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
323 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
324 static DECLCALLBACK(int) i_displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM,
325 uint32_t cbLine, uint32_t cx, uint32_t cy);
326 static DECLCALLBACK(void) i_displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
327 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
328 static DECLCALLBACK(void) i_displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
329 static DECLCALLBACK(void) i_displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
330 static DECLCALLBACK(void) i_displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
331 static DECLCALLBACK(void) i_displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
332 void *pvVRAM, uint32_t u32VRAMSize);
333 static DECLCALLBACK(void) i_displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
334 void *pvVRAM, unsigned uScreenId);
335
336#ifdef VBOX_WITH_VIDEOHWACCEL
337 static DECLCALLBACK(int) i_displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, int enmCmd, bool fGuestCmd,
338 VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand);
339#endif
340
341#ifdef VBOX_WITH_CRHGSMI
342 static DECLCALLBACK(void) i_displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface,
343 VBOXVDMACMD_CHROMIUM_CMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd,
344 uint32_t cbCmd);
345 static DECLCALLBACK(void) i_displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface,
346 VBOXVDMACMD_CHROMIUM_CTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl,
347 uint32_t cbCtl);
348
349 static DECLCALLBACK(void) i_displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
350 void *pvContext);
351 static DECLCALLBACK(void) i_displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
352 void *pvContext);
353#endif
354#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
355 static DECLCALLBACK(int) i_displayCrHgcmCtlSubmit(PPDMIDISPLAYCONNECTOR pInterface, struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd,
356 PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
357 static DECLCALLBACK(void) i_displayCrHgcmCtlSubmitCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
358 void *pvContext);
359#endif
360#ifdef VBOX_WITH_HGSMI
361 static DECLCALLBACK(int) i_displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
362 VBVAHOSTFLAGS RT_UNTRUSTED_VOLATILE_GUEST *pHostFlags, bool fRenderThreadMode);
363 static DECLCALLBACK(void) i_displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
364 static DECLCALLBACK(void) i_displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
365 static DECLCALLBACK(void) i_displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
366 struct VBVACMDHDR const RT_UNTRUSTED_VOLATILE_GUEST *pCmd, size_t cbCmd);
367 static DECLCALLBACK(void) i_displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y,
368 uint32_t cx, uint32_t cy);
369 static DECLCALLBACK(int) i_displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, PCVBVAINFOVIEW pView,
370 PCVBVAINFOSCREEN pScreen, void *pvVRAM,
371 bool fResetInputMapping);
372 static DECLCALLBACK(int) i_displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
373 uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
374 const void *pvShape);
375 static DECLCALLBACK(void) i_displayVBVAGuestCapabilityUpdate(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fCapabilities);
376
377 static DECLCALLBACK(void) i_displayVBVAInputMappingUpdate(PPDMIDISPLAYCONNECTOR pInterface, int32_t xOrigin, int32_t yOrigin,
378 uint32_t cx, uint32_t cy);
379 static DECLCALLBACK(void) i_displayVBVAReportCursorPosition(PPDMIDISPLAYCONNECTOR pInterface, bool fData, uint32_t x, uint32_t y);
380#endif
381
382#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
383 static DECLCALLBACK(void) i_displayCrVRecScreenshotPerform(void *pvCtx, uint32_t uScreen,
384 uint32_t x, uint32_t y,
385 uint32_t uBitsPerPixel, uint32_t uBytesPerLine,
386 uint32_t uGuestWidth, uint32_t uGuestHeight,
387 uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
388 static DECLCALLBACK(bool) i_displayCrVRecScreenshotBegin(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
389 static DECLCALLBACK(void) i_displayCrVRecScreenshotEnd(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
390
391 static DECLCALLBACK(void) i_displayVRecCompletion(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
392#endif
393 static DECLCALLBACK(void) i_displayCrCmdFree(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
394
395 static DECLCALLBACK(void) i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
396 static DECLCALLBACK(int) i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
397 static DECLCALLBACK(void) i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
398 static DECLCALLBACK(int) i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
399
400 Console * const mParent;
401 /** Pointer to the associated display driver. */
402 struct DRVMAINDISPLAY *mpDrv;
403
404 unsigned mcMonitors;
405 /** Input mapping rectangle top left X relative to the first screen. */
406 int32_t xInputMappingOrigin;
407 /** Input mapping rectangle top left Y relative to the first screen. */
408 int32_t yInputMappingOrigin;
409 uint32_t cxInputMapping; /**< Input mapping rectangle width. */
410 uint32_t cyInputMapping; /**< Input mapping rectangle height. */
411 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
412 /** Does the VMM device have the "supports graphics" capability set?
413 * Does not go into the saved state as it is refreshed on restore. */
414 bool mfVMMDevSupportsGraphics;
415 /** Mirror of the current guest VBVA capabilities. */
416 uint32_t mfGuestVBVACapabilities;
417 /** Mirror of the current host cursor capabilities. */
418 uint32_t mfHostCursorCapabilities;
419
420 bool mfSourceBitmapEnabled;
421 bool volatile fVGAResizing;
422
423 /** Are we in seamless mode? Not saved, as we exit seamless on saving. */
424 bool mfSeamlessEnabled;
425 /** Last set seamless visible region, number of rectangles. */
426 uint32_t mcRectVisibleRegion;
427 /** Last set seamless visible region, data. Freed on final clean-up. */
428 PRTRECT mpRectVisibleRegion;
429
430 bool mfVideoAccelVRDP;
431 uint32_t mfu32SupportedOrders;
432 int32_t volatile mcVideoAccelVRDPRefs;
433
434 /** Accelerate3DEnabled = true && GraphicsControllerType == VBoxVGA. */
435 bool mfIsCr3DEnabled;
436
437#ifdef VBOX_WITH_CROGL
438 bool mfCrOglDataHidden;
439#endif
440
441#ifdef VBOX_WITH_CRHGSMI
442 /* for fast host hgcm calls */
443 HGCMCVSHANDLE mhCrOglSvc;
444 RTCRITSECTRW mCrOglLock;
445#endif
446#ifdef VBOX_WITH_CROGL
447 CR_MAIN_INTERFACE mCrOglCallbacks;
448 volatile uint32_t mfCrOglVideoRecState;
449 CRVBOXHGCMTAKESCREENSHOT mCrOglScreenshotData;
450 VBOXCRCMDCTL_HGCM mCrOglScreenshotCtl;
451#endif
452
453 /* The legacy VBVA data and methods. */
454 VIDEOACCEL mVideoAccelLegacy;
455
456 int i_VideoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
457 void i_VideoAccelFlush(PPDMIDISPLAYPORT pUpPort);
458 bool i_VideoAccelAllowed(void);
459
460 int i_videoAccelRefreshProcess(PPDMIDISPLAYPORT pUpPort);
461 int i_videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
462 int i_videoAccelFlush(PPDMIDISPLAYPORT pUpPort);
463
464 /* Legacy pre-HGSMI handlers. */
465 void processAdapterData(void *pvVRAM, uint32_t u32VRAMSize);
466 void processDisplayData(void *pvVRAM, unsigned uScreenId);
467
468 /** Serializes access to mVideoAccelLegacy and mfVideoAccelVRDP, etc between VRDP and Display. */
469 RTCRITSECT mVideoAccelLock;
470
471#ifdef VBOX_WITH_RECORDING
472 /* Serializes access to video recording source bitmaps. */
473 RTCRITSECT mVideoRecLock;
474 /** Array which defines which screens are being enabled for capturing. */
475 bool maVideoRecEnabled[SchemaDefs::MaxGuestMonitors];
476#endif
477
478public:
479
480 static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
481 uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
482#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
483 static BOOL i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pbData,
484 uint32_t u32Width, uint32_t u32Height);
485 int i_crCtlSubmit(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd, PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
486 int i_crCtlSubmitSync(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd);
487 /* copies the given command and submits it asynchronously,
488 * i.e. the pCmd data may be discarded right after the call returns */
489 int i_crCtlSubmitAsyncCmdCopy(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
490 /* performs synchronous request processing if 3D backend has something to display
491 * this is primarily to work-around 3d<->main thread deadlocks on OSX
492 * in case of async completion, the command is coppied to the allocated buffer,
493 * freeded on command completion
494 * can be used for "notification" commands, when client is not interested in command result,
495 * that must synchronize with 3D backend only when some 3D data is displayed.
496 * The routine does NOT provide any info on whether command is processed asynchronously or not */
497 int i_crCtlSubmitSyncIfHasDataForScreen(uint32_t u32ScreenID, struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
498#endif
499
500private:
501 static int i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
502 static int i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
503
504 void i_updateGuestGraphicsFacility(void);
505
506#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
507 int i_crOglWindowsShow(bool fShow);
508#endif
509
510#ifdef VBOX_WITH_HGSMI
511 volatile uint32_t mu32UpdateVBVAFlags;
512#endif
513
514private:
515 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Display); /* Shuts up MSC warning C4625. */
516};
517
518/* The legacy VBVA helpers. */
519int videoAccelConstruct(VIDEOACCEL *pVideoAccel);
520void videoAccelDestroy(VIDEOACCEL *pVideoAccel);
521void i_vbvaSetMemoryFlags(VBVAMEMORY *pVbvaMemory,
522 bool fVideoAccelEnabled,
523 bool fVideoAccelVRDP,
524 uint32_t fu32SupportedOrders,
525 DISPLAYFBINFO *paFBInfos,
526 unsigned cFBInfos);
527int videoAccelEnterVGA(VIDEOACCEL *pVideoAccel);
528void videoAccelLeaveVGA(VIDEOACCEL *pVideoAccel);
529int videoAccelEnterVMMDev(VIDEOACCEL *pVideoAccel);
530void videoAccelLeaveVMMDev(VIDEOACCEL *pVideoAccel);
531
532
533/* helper function, code in DisplayResampleImage.cpp */
534void BitmapScale32(uint8_t *dst, int dstW, int dstH,
535 const uint8_t *src, int iDeltaLine, int srcW, int srcH);
536
537/* helper function, code in DisplayPNGUtul.cpp */
538int DisplayMakePNG(uint8_t *pbData, uint32_t cx, uint32_t cy,
539 uint8_t **ppu8PNG, uint32_t *pcbPNG, uint32_t *pcxPNG, uint32_t *pcyPNG,
540 uint8_t fLimitSize);
541
542class ATL_NO_VTABLE DisplaySourceBitmap:
543 public DisplaySourceBitmapWrap
544{
545public:
546
547 DECLARE_EMPTY_CTOR_DTOR(DisplaySourceBitmap)
548
549 HRESULT FinalConstruct();
550 void FinalRelease();
551
552 /* Public initializer/uninitializer for internal purposes only. */
553 HRESULT init(ComObjPtr<Display> pDisplay, unsigned uScreenId, DISPLAYFBINFO *pFBInfo);
554 void uninit();
555
556 bool i_usesVRAM(void) { return m.pu8Allocated == NULL; }
557
558private:
559 // wrapped IDisplaySourceBitmap properties
560 virtual HRESULT getScreenId(ULONG *aScreenId);
561
562 // wrapped IDisplaySourceBitmap methods
563 virtual HRESULT queryBitmapInfo(BYTE **aAddress,
564 ULONG *aWidth,
565 ULONG *aHeight,
566 ULONG *aBitsPerPixel,
567 ULONG *aBytesPerLine,
568 BitmapFormat_T *aBitmapFormat);
569
570 int initSourceBitmap(unsigned aScreenId, DISPLAYFBINFO *pFBInfo);
571
572 struct Data
573 {
574 ComObjPtr<Display> pDisplay;
575 unsigned uScreenId;
576 DISPLAYFBINFO *pFBInfo;
577
578 uint8_t *pu8Allocated;
579
580 uint8_t *pu8Address;
581 ULONG ulWidth;
582 ULONG ulHeight;
583 ULONG ulBitsPerPixel;
584 ULONG ulBytesPerLine;
585 BitmapFormat_T bitmapFormat;
586 };
587
588 Data m;
589};
590
591class ATL_NO_VTABLE GuestScreenInfo:
592 public GuestScreenInfoWrap
593{
594public:
595
596 DECLARE_EMPTY_CTOR_DTOR(GuestScreenInfo)
597
598 HRESULT FinalConstruct();
599 void FinalRelease();
600
601 /* Public initializer/uninitializer for internal purposes only. */
602 HRESULT init(ULONG aDisplay,
603 GuestMonitorStatus_T aGuestMonitorStatus,
604 BOOL aPrimary,
605 BOOL aChangeOrigin,
606 LONG aOriginX,
607 LONG aOriginY,
608 ULONG aWidth,
609 ULONG aHeight,
610 ULONG aBitsPerPixel);
611 void uninit();
612
613private:
614 // wrapped IGuestScreenInfo properties
615 virtual HRESULT getScreenId(ULONG *aScreenId);
616 virtual HRESULT getGuestMonitorStatus(GuestMonitorStatus_T *aGuestMonitorStatus);
617 virtual HRESULT getPrimary(BOOL *aPrimary);
618 virtual HRESULT getOrigin(BOOL *aOrigin);
619 virtual HRESULT getOriginX(LONG *aOriginX);
620 virtual HRESULT getOriginY(LONG *aOriginY);
621 virtual HRESULT getWidth(ULONG *aWidth);
622 virtual HRESULT getHeight(ULONG *aHeight);
623 virtual HRESULT getBitsPerPixel(ULONG *aBitsPerPixel);
624 virtual HRESULT getExtendedInfo(com::Utf8Str &aExtendedInfo);
625
626 ULONG mScreenId;
627 GuestMonitorStatus_T mGuestMonitorStatus;
628 BOOL mPrimary;
629 BOOL mOrigin;
630 LONG mOriginX;
631 LONG mOriginY;
632 ULONG mWidth;
633 ULONG mHeight;
634 ULONG mBitsPerPixel;
635};
636
637#endif // !____H_DISPLAYIMPL
638/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette