VirtualBox

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

Last change on this file since 71590 was 71590, checked in by vboxsync, 7 years ago

DevVGA,HGSMI,++: Code cleanup in progress. bugref:9094

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.5 KB
Line 
1/* $Id: DisplayImpl.h 71590 2018-03-31 18:34:28Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. 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 "../src-client/VideoRec.h"
36struct VIDEORECCONTEXT;
37#endif
38
39#include "DisplaySourceBitmapWrap.h"
40
41
42class Console;
43
44typedef struct _DISPLAYFBINFO
45{
46 /* The following 3 fields (u32Offset, u32MaxFramebufferSize and u32InformationSize)
47 * are not used by the current HGSMI. They are needed for backward compatibility with
48 * pre-HGSMI additions.
49 */
50 uint32_t u32Offset;
51 uint32_t u32MaxFramebufferSize;
52 uint32_t u32InformationSize;
53
54 ComPtr<IFramebuffer> pFramebuffer;
55 com::Guid framebufferId;
56 ComPtr<IDisplaySourceBitmap> pSourceBitmap;
57 bool fDisabled;
58
59 uint32_t u32Caps;
60
61 struct
62 {
63 ComPtr<IDisplaySourceBitmap> pSourceBitmap;
64 uint8_t *pu8Address;
65 uint32_t cbLine;
66 } updateImage;
67
68 LONG xOrigin;
69 LONG yOrigin;
70
71 ULONG w;
72 ULONG h;
73
74 uint16_t u16BitsPerPixel;
75 uint8_t *pu8FramebufferVRAM;
76 uint32_t u32LineSize;
77
78 uint16_t flags;
79
80 VBOXVIDEOINFOHOSTEVENTS *pHostEvents;
81
82 /** The framebuffer has default format and must be updates immediately. */
83 bool fDefaultFormat;
84
85#ifdef VBOX_WITH_HGSMI
86 bool fVBVAEnabled;
87 bool fVBVAForceResize;
88 bool fRenderThreadMode;
89 PVBVAHOSTFLAGS pVBVAHostFlags;
90#endif /* VBOX_WITH_HGSMI */
91
92#ifdef VBOX_WITH_CROGL
93 struct
94 {
95 bool fPending;
96 ULONG x;
97 ULONG y;
98 ULONG width;
99 ULONG height;
100 } pendingViewportInfo;
101#endif /* VBOX_WITH_CROGL */
102
103#ifdef VBOX_WITH_VIDEOREC
104 struct
105 {
106 ComPtr<IDisplaySourceBitmap> pSourceBitmap;
107 } videoRec;
108#endif /* VBOX_WITH_VIDEOREC */
109} DISPLAYFBINFO;
110
111/* The legacy VBVA (VideoAccel) data.
112 *
113 * Backward compatibility with the guest additions 3.x or older.
114 */
115typedef struct VIDEOACCEL
116{
117 VBVAMEMORY *pVbvaMemory;
118 bool fVideoAccelEnabled;
119
120 uint8_t *pu8VbvaPartial;
121 uint32_t cbVbvaPartial;
122
123 /* Old guest additions (3.x and older) use both VMMDev and DevVGA refresh timer
124 * to process the VBVABUFFER memory. Therefore the legacy VBVA (VideoAccel) host
125 * code can be executed concurrently by VGA refresh timer and the guest VMMDev
126 * request in SMP VMs. The semaphore serialized this.
127 */
128 RTSEMXROADS hXRoadsVideoAccel;
129
130} VIDEOACCEL;
131
132class DisplayMouseInterface
133{
134public:
135 virtual HRESULT i_getScreenResolution(ULONG cScreen, ULONG *pcx,
136 ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin) = 0;
137 virtual void i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
138 int32_t *px2, int32_t *py2) = 0;
139 virtual HRESULT i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved) = 0;
140 virtual HRESULT i_reportHostCursorPosition(int32_t x, int32_t y) = 0;
141 virtual bool i_isInputMappingSet(void) = 0;
142};
143
144class VMMDev;
145
146class ATL_NO_VTABLE Display :
147 public DisplayWrap,
148 public DisplayMouseInterface
149{
150public:
151
152 DECLARE_EMPTY_CTOR_DTOR(Display)
153
154 HRESULT FinalConstruct();
155 void FinalRelease();
156
157 // public initializer/uninitializer for internal purposes only
158 HRESULT init(Console *aParent);
159 void uninit();
160 int i_registerSSM(PUVM pUVM);
161
162 // public methods only for internal purposes
163 int i_handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM,
164 uint32_t cbLine, uint32_t w, uint32_t h, uint16_t flags,
165 int32_t xOrigin, int32_t yOrigin, bool fVGAResize);
166 void i_handleDisplayUpdate(unsigned uScreenId, int x, int y, int w, int h);
167 void i_handleUpdateVMMDevSupportsGraphics(bool fSupportsGraphics);
168 void i_handleUpdateGuestVBVACapabilities(uint32_t fNewCapabilities);
169 void i_handleUpdateVBVAInputMapping(int32_t xOrigin, int32_t yOrigin, uint32_t cx, uint32_t cy);
170#ifdef VBOX_WITH_VIDEOHWACCEL
171 int i_handleVHWACommandProcess(int enmCmd, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand);
172#endif
173#ifdef VBOX_WITH_CRHGSMI
174 void i_handleCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
175 void i_handleCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
176 void i_handleCrHgsmiCommandProcess(PVBOXVDMACMD_CHROMIUM_CMD pCmd, uint32_t cbCmd);
177 void i_handleCrHgsmiControlProcess(PVBOXVDMACMD_CHROMIUM_CTL pCtl, uint32_t cbCtl);
178#endif
179#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
180 int i_handleCrHgcmCtlSubmit(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
181 PFNCRCTLCOMPLETION pfnCompletion,
182 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_videoRecGetEnabled(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
302 // Wrapped IEventListener properties
303
304 // Wrapped IEventListener methods
305 virtual HRESULT handleEvent(const ComPtr<IEvent> &aEvent);
306
307 // other internal methods
308 HRESULT takeScreenShotWorker(ULONG aScreenId,
309 BYTE *aAddress,
310 ULONG aWidth,
311 ULONG aHeight,
312 BitmapFormat_T aBitmapFormat,
313 ULONG *pcbOut);
314 int processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping);
315
316#ifdef VBOX_WITH_CRHGSMI
317 void i_setupCrHgsmiData(void);
318 void i_destructCrHgsmiData(void);
319#endif
320
321#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
322 int i_crViewportNotify(ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height);
323#endif
324
325 static DECLCALLBACK(void*) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
326 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
327 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
328 static DECLCALLBACK(int) i_displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM,
329 uint32_t cbLine, uint32_t cx, uint32_t cy);
330 static DECLCALLBACK(void) i_displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
331 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
332 static DECLCALLBACK(void) i_displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
333 static DECLCALLBACK(void) i_displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
334 static DECLCALLBACK(void) i_displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
335 static DECLCALLBACK(void) i_displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
336 void *pvVRAM, uint32_t u32VRAMSize);
337 static DECLCALLBACK(void) i_displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
338 void *pvVRAM, unsigned uScreenId);
339
340#ifdef VBOX_WITH_VIDEOHWACCEL
341 static DECLCALLBACK(int) i_displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, int enmCmd,
342 VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand);
343#endif
344
345#ifdef VBOX_WITH_CRHGSMI
346 static DECLCALLBACK(void) i_displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface,
347 PVBOXVDMACMD_CHROMIUM_CMD pCmd, uint32_t cbCmd);
348 static DECLCALLBACK(void) i_displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl,
349 uint32_t cbCtl);
350
351 static DECLCALLBACK(void) i_displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
352 void *pvContext);
353 static DECLCALLBACK(void) i_displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
354 void *pvContext);
355#endif
356#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
357 static DECLCALLBACK(int) i_displayCrHgcmCtlSubmit(PPDMIDISPLAYCONNECTOR pInterface,
358 struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
359 PFNCRCTLCOMPLETION pfnCompletion,
360 void *pvCompletion);
361 static DECLCALLBACK(void) i_displayCrHgcmCtlSubmitCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
362 void *pvContext);
363#endif
364#ifdef VBOX_WITH_HGSMI
365 static DECLCALLBACK(int) i_displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
366 PVBVAHOSTFLAGS pHostFlags, bool fRenderThreadMode);
367 static DECLCALLBACK(void) i_displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
368 static DECLCALLBACK(void) i_displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
369 static DECLCALLBACK(void) i_displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
370 PCVBVACMDHDR pCmd, size_t cbCmd);
371 static DECLCALLBACK(void) i_displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y,
372 uint32_t cx, uint32_t cy);
373 static DECLCALLBACK(int) i_displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, PCVBVAINFOVIEW pView,
374 PCVBVAINFOSCREEN pScreen, void *pvVRAM,
375 bool fResetInputMapping);
376 static DECLCALLBACK(int) i_displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
377 uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
378 const void *pvShape);
379 static DECLCALLBACK(void) i_displayVBVAGuestCapabilityUpdate(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fCapabilities);
380
381 static DECLCALLBACK(void) i_displayVBVAInputMappingUpdate(PPDMIDISPLAYCONNECTOR pInterface, int32_t xOrigin, int32_t yOrigin,
382 uint32_t cx, uint32_t cy);
383 static DECLCALLBACK(void) i_displayVBVAReportCursorPosition(PPDMIDISPLAYCONNECTOR pInterface, bool fData, uint32_t x, uint32_t y);
384#endif
385
386#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
387 static DECLCALLBACK(void) i_displayCrVRecScreenshotPerform(void *pvCtx, uint32_t uScreen,
388 uint32_t x, uint32_t y,
389 uint32_t uBitsPerPixel, uint32_t uBytesPerLine,
390 uint32_t uGuestWidth, uint32_t uGuestHeight,
391 uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
392 static DECLCALLBACK(bool) i_displayCrVRecScreenshotBegin(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
393 static DECLCALLBACK(void) i_displayCrVRecScreenshotEnd(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
394
395 static DECLCALLBACK(void) i_displayVRecCompletion(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
396#endif
397 static DECLCALLBACK(void) i_displayCrCmdFree(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
398
399 static DECLCALLBACK(void) i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
400 static DECLCALLBACK(int) i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
401 static DECLCALLBACK(void) i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
402 static DECLCALLBACK(int) i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
403
404 Console * const mParent;
405 /** Pointer to the associated display driver. */
406 struct DRVMAINDISPLAY *mpDrv;
407
408 unsigned mcMonitors;
409 /** Input mapping rectangle top left X relative to the first screen. */
410 int32_t xInputMappingOrigin;
411 /** Input mapping rectangle top left Y relative to the first screen. */
412 int32_t yInputMappingOrigin;
413 uint32_t cxInputMapping; /**< Input mapping rectangle width. */
414 uint32_t cyInputMapping; /**< Input mapping rectangle height. */
415 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
416 /** Does the VMM device have the "supports graphics" capability set?
417 * Does not go into the saved state as it is refreshed on restore. */
418 bool mfVMMDevSupportsGraphics;
419 /** Mirror of the current guest VBVA capabilities. */
420 uint32_t mfGuestVBVACapabilities;
421 /** Mirror of the current host cursor capabilities. */
422 uint32_t mfHostCursorCapabilities;
423
424 bool mfSourceBitmapEnabled;
425 bool volatile fVGAResizing;
426
427 /** Are we in seamless mode? Not saved, as we exit seamless on saving. */
428 bool mfSeamlessEnabled;
429 /** Last set seamless visible region, number of rectangles. */
430 uint32_t mcRectVisibleRegion;
431 /** Last set seamless visible region, data. Freed on final clean-up. */
432 PRTRECT mpRectVisibleRegion;
433
434 bool mfVideoAccelVRDP;
435 uint32_t mfu32SupportedOrders;
436 int32_t volatile mcVideoAccelVRDPRefs;
437
438 /** Accelerate3DEnabled = true && GraphicsControllerType == VBoxVGA. */
439 bool mfIsCr3DEnabled;
440
441#ifdef VBOX_WITH_CROGL
442 bool mfCrOglDataHidden;
443#endif
444
445#ifdef VBOX_WITH_CRHGSMI
446 /* for fast host hgcm calls */
447 HGCMCVSHANDLE mhCrOglSvc;
448 RTCRITSECTRW mCrOglLock;
449#endif
450#ifdef VBOX_WITH_CROGL
451 CR_MAIN_INTERFACE mCrOglCallbacks;
452 volatile uint32_t mfCrOglVideoRecState;
453 CRVBOXHGCMTAKESCREENSHOT mCrOglScreenshotData;
454 VBOXCRCMDCTL_HGCM mCrOglScreenshotCtl;
455#endif
456
457 /* The legacy VBVA data and methods. */
458 VIDEOACCEL mVideoAccelLegacy;
459
460 int i_VideoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
461 void i_VideoAccelFlush(PPDMIDISPLAYPORT pUpPort);
462 bool i_VideoAccelAllowed(void);
463
464 int i_videoAccelRefreshProcess(PPDMIDISPLAYPORT pUpPort);
465 int i_videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
466 int i_videoAccelFlush(PPDMIDISPLAYPORT pUpPort);
467
468 /* Legacy pre-HGSMI handlers. */
469 void processAdapterData(void *pvVRAM, uint32_t u32VRAMSize);
470 void processDisplayData(void *pvVRAM, unsigned uScreenId);
471
472 /** Serializes access to mVideoAccelLegacy and mfVideoAccelVRDP, etc between VRDP and Display. */
473 RTCRITSECT mVideoAccelLock;
474
475#ifdef VBOX_WITH_VIDEOREC
476 /* Serializes access to video recording source bitmaps. */
477 RTCRITSECT mVideoRecLock;
478 /** The current video recording configuration being used. */
479 VIDEORECCFG mVideoRecCfg;
480 /** The video recording context. */
481 VIDEORECCONTEXT *mpVideoRecCtx;
482 /** Array which defines which screens are being enabled for recording. */
483 bool maVideoRecEnabled[SchemaDefs::MaxGuestMonitors];
484#endif
485
486public:
487
488 static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
489 uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
490#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
491 static BOOL i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pbData,
492 uint32_t u32Width, uint32_t u32Height);
493 int i_crCtlSubmit(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
494 int i_crCtlSubmitSync(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
495 /* copies the given command and submits it asynchronously,
496 * i.e. the pCmd data may be discarded right after the call returns */
497 int i_crCtlSubmitAsyncCmdCopy(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
498 /* performs synchronous request processing if 3D backend has something to display
499 * this is primarily to work-around 3d<->main thread deadlocks on OSX
500 * in case of async completion, the command is coppied to the allocated buffer,
501 * freeded on command completion
502 * can be used for "notification" commands, when client is not interested in command result,
503 * that must synchronize with 3D backend only when some 3D data is displayed.
504 * The routine does NOT provide any info on whether command is processed asynchronously or not */
505 int i_crCtlSubmitSyncIfHasDataForScreen(uint32_t u32ScreenID, struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
506#endif
507
508private:
509 static int i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
510 static int i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
511
512 void i_updateGuestGraphicsFacility(void);
513
514#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
515 int i_crOglWindowsShow(bool fShow);
516#endif
517
518#ifdef VBOX_WITH_HGSMI
519 volatile uint32_t mu32UpdateVBVAFlags;
520#endif
521
522private:
523 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Display); /* Shuts up MSC warning C4625. */
524};
525
526/* The legacy VBVA helpers. */
527int videoAccelConstruct(VIDEOACCEL *pVideoAccel);
528void videoAccelDestroy(VIDEOACCEL *pVideoAccel);
529void i_vbvaSetMemoryFlags(VBVAMEMORY *pVbvaMemory,
530 bool fVideoAccelEnabled,
531 bool fVideoAccelVRDP,
532 uint32_t fu32SupportedOrders,
533 DISPLAYFBINFO *paFBInfos,
534 unsigned cFBInfos);
535int videoAccelEnterVGA(VIDEOACCEL *pVideoAccel);
536void videoAccelLeaveVGA(VIDEOACCEL *pVideoAccel);
537int videoAccelEnterVMMDev(VIDEOACCEL *pVideoAccel);
538void videoAccelLeaveVMMDev(VIDEOACCEL *pVideoAccel);
539
540
541/* helper function, code in DisplayResampleImage.cpp */
542void BitmapScale32(uint8_t *dst, int dstW, int dstH,
543 const uint8_t *src, int iDeltaLine, int srcW, int srcH);
544
545/* helper function, code in DisplayPNGUtul.cpp */
546int DisplayMakePNG(uint8_t *pbData, uint32_t cx, uint32_t cy,
547 uint8_t **ppu8PNG, uint32_t *pcbPNG, uint32_t *pcxPNG, uint32_t *pcyPNG,
548 uint8_t fLimitSize);
549
550class ATL_NO_VTABLE DisplaySourceBitmap:
551 public DisplaySourceBitmapWrap
552{
553public:
554
555 DECLARE_EMPTY_CTOR_DTOR(DisplaySourceBitmap)
556
557 HRESULT FinalConstruct();
558 void FinalRelease();
559
560 /* Public initializer/uninitializer for internal purposes only. */
561 HRESULT init(ComObjPtr<Display> pDisplay, unsigned uScreenId, DISPLAYFBINFO *pFBInfo);
562 void uninit();
563
564 bool i_usesVRAM(void) { return m.pu8Allocated == NULL; }
565
566private:
567 // wrapped IDisplaySourceBitmap properties
568 virtual HRESULT getScreenId(ULONG *aScreenId);
569
570 // wrapped IDisplaySourceBitmap methods
571 virtual HRESULT queryBitmapInfo(BYTE **aAddress,
572 ULONG *aWidth,
573 ULONG *aHeight,
574 ULONG *aBitsPerPixel,
575 ULONG *aBytesPerLine,
576 BitmapFormat_T *aBitmapFormat);
577
578 int initSourceBitmap(unsigned aScreenId, DISPLAYFBINFO *pFBInfo);
579
580 struct Data
581 {
582 ComObjPtr<Display> pDisplay;
583 unsigned uScreenId;
584 DISPLAYFBINFO *pFBInfo;
585
586 uint8_t *pu8Allocated;
587
588 uint8_t *pu8Address;
589 ULONG ulWidth;
590 ULONG ulHeight;
591 ULONG ulBitsPerPixel;
592 ULONG ulBytesPerLine;
593 BitmapFormat_T bitmapFormat;
594 };
595
596 Data m;
597};
598
599#endif // !____H_DISPLAYIMPL
600/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

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