VirtualBox

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

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

VideoRec/Main: Implemented applying audio driver configuration at runtime (when being attached).

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