VirtualBox

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

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

DevVGA,VBoxC: 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.8 KB
Line 
1/* $Id: DisplayImpl.h 71626 2018-04-02 21:12:58Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#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 VBVAHOSTFLAGS RT_UNTRUSTED_VOLATILE_GUEST *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, bool fGuestCmd, 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(VBOXVDMACMD_CHROMIUM_CMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd);
177 void i_handleCrHgsmiControlProcess(VBOXVDMACMD_CHROMIUM_CTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl, uint32_t cbCtl);
178#endif
179#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
180 int i_handleCrHgcmCtlSubmit(struct VBOXCRCMDCTL RT_UNTRUSTED_VOLATILE_GUEST *pCmd, uint32_t cbCmd,
181 PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
182 void i_handleCrVRecScreenshotPerform(uint32_t uScreen,
183 uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,
184 uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
185 uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
186 /** @todo r=bird: u64TimeStamp - using the 'u64' prefix add nothing.
187 * However, using one of the prefixes indicating the timestamp unit
188 * would be very valuable! */
189 bool i_handleCrVRecScreenshotBegin(uint32_t uScreen, uint64_t u64TimeStamp);
190 void i_handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t u64TimeStamp);
191 void i_handleVRecCompletion();
192#endif
193
194 int i_notifyCroglResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM);
195
196 int i_saveVisibleRegion(uint32_t cRect, PRTRECT pRect);
197 int i_handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect);
198 int i_handleQueryVisibleRegion(uint32_t *pcRects, PRTRECT paRects);
199
200 void i_VideoAccelVRDP(bool fEnable);
201
202 /* Legacy video acceleration requests coming from the VGA refresh timer. */
203 int VideoAccelEnableVGA(bool fEnable, VBVAMEMORY *pVbvaMemory);
204
205 /* Legacy video acceleration requests coming from VMMDev. */
206 int VideoAccelEnableVMMDev(bool fEnable, VBVAMEMORY *pVbvaMemory);
207 void VideoAccelFlushVMMDev(void);
208
209#ifdef VBOX_WITH_VIDEOREC
210 PVIDEORECCFG i_videoRecGetConfig(void) { return &mVideoRecCfg; }
211 VIDEORECFEATURES i_videoRecGetEnabled(void);
212 bool i_videoRecStarted(void);
213 void i_videoRecInvalidate();
214 int i_videoRecSendAudio(const void *pvData, size_t cbData, uint64_t uDurationMs);
215 int i_videoRecStart(void);
216 void i_videoRecStop(void);
217 void i_videoRecScreenChanged(unsigned uScreenId);
218#endif
219
220 void i_notifyPowerDown(void);
221
222 // DisplayMouseInterface methods
223 virtual HRESULT i_getScreenResolution(ULONG cScreen, ULONG *pcx,
224 ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin)
225 {
226 return getScreenResolution(cScreen, pcx, pcy, pcBPP, pXOrigin, pYOrigin, NULL);
227 }
228 virtual void i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
229 int32_t *px2, int32_t *py2);
230 virtual HRESULT i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved);
231 virtual HRESULT i_reportHostCursorPosition(int32_t x, int32_t y);
232 virtual bool i_isInputMappingSet(void)
233 {
234 return cxInputMapping != 0 && cyInputMapping != 0;
235 }
236
237 static const PDMDRVREG DrvReg;
238
239private:
240 // Wrapped IDisplay properties
241 virtual HRESULT getGuestScreenLayout(std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenLayout);
242
243 // Wrapped IDisplay methods
244 virtual HRESULT getScreenResolution(ULONG aScreenId,
245 ULONG *aWidth,
246 ULONG *aHeight,
247 ULONG *aBitsPerPixel,
248 LONG *aXOrigin,
249 LONG *aYOrigin,
250 GuestMonitorStatus_T *aGuestMonitorStatus);
251 virtual HRESULT attachFramebuffer(ULONG aScreenId,
252 const ComPtr<IFramebuffer> &aFramebuffer,
253 com::Guid &aId);
254 virtual HRESULT detachFramebuffer(ULONG aScreenId,
255 const com::Guid &aId);
256 virtual HRESULT queryFramebuffer(ULONG aScreenId,
257 ComPtr<IFramebuffer> &aFramebuffer);
258 virtual HRESULT setVideoModeHint(ULONG aDisplay,
259 BOOL aEnabled,
260 BOOL aChangeOrigin,
261 LONG aOriginX,
262 LONG aOriginY,
263 ULONG aWidth,
264 ULONG aHeight,
265 ULONG aBitsPerPixel);
266 virtual HRESULT setSeamlessMode(BOOL aEnabled);
267 virtual HRESULT takeScreenShot(ULONG aScreenId,
268 BYTE *aAddress,
269 ULONG aWidth,
270 ULONG aHeight,
271 BitmapFormat_T aBitmapFormat);
272 virtual HRESULT takeScreenShotToArray(ULONG aScreenId,
273 ULONG aWidth,
274 ULONG aHeight,
275 BitmapFormat_T aBitmapFormat,
276 std::vector<BYTE> &aScreenData);
277 virtual HRESULT drawToScreen(ULONG aScreenId,
278 BYTE *aAddress,
279 ULONG aX,
280 ULONG aY,
281 ULONG aWidth,
282 ULONG aHeight);
283 virtual HRESULT invalidateAndUpdate();
284 virtual HRESULT invalidateAndUpdateScreen(ULONG aScreenId);
285 virtual HRESULT completeVHWACommand(BYTE *aCommand);
286 virtual HRESULT viewportChanged(ULONG aScreenId,
287 ULONG aX,
288 ULONG aY,
289 ULONG aWidth,
290 ULONG aHeight);
291 virtual HRESULT querySourceBitmap(ULONG aScreenId,
292 ComPtr<IDisplaySourceBitmap> &aDisplaySourceBitmap);
293 virtual HRESULT notifyScaleFactorChange(ULONG aScreenId,
294 ULONG aScaleFactorWMultiplied,
295 ULONG aScaleFactorHMultiplied);
296 virtual HRESULT notifyHiDPIOutputPolicyChange(BOOL fUnscaledHiDPI);
297 virtual HRESULT setScreenLayout(ScreenLayoutMode_T aScreenLayoutMode,
298 const std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenInfo);
299 virtual HRESULT detachScreens(const std::vector<LONG> &aScreenIds);
300
301 // Wrapped IEventListener properties
302
303 // Wrapped IEventListener methods
304 virtual HRESULT handleEvent(const ComPtr<IEvent> &aEvent);
305
306 // other internal methods
307 HRESULT takeScreenShotWorker(ULONG aScreenId,
308 BYTE *aAddress,
309 ULONG aWidth,
310 ULONG aHeight,
311 BitmapFormat_T aBitmapFormat,
312 ULONG *pcbOut);
313 int processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping);
314
315#ifdef VBOX_WITH_CRHGSMI
316 void i_setupCrHgsmiData(void);
317 void i_destructCrHgsmiData(void);
318#endif
319
320#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
321 int i_crViewportNotify(ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height);
322#endif
323
324 static DECLCALLBACK(void*) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
325 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
326 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
327 static DECLCALLBACK(int) i_displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM,
328 uint32_t cbLine, uint32_t cx, uint32_t cy);
329 static DECLCALLBACK(void) i_displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
330 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
331 static DECLCALLBACK(void) i_displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
332 static DECLCALLBACK(void) i_displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
333 static DECLCALLBACK(void) i_displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
334 static DECLCALLBACK(void) i_displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
335 void *pvVRAM, uint32_t u32VRAMSize);
336 static DECLCALLBACK(void) i_displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
337 void *pvVRAM, unsigned uScreenId);
338
339#ifdef VBOX_WITH_VIDEOHWACCEL
340 static DECLCALLBACK(int) i_displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, int enmCmd, bool fGuestCmd,
341 VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand);
342#endif
343
344#ifdef VBOX_WITH_CRHGSMI
345 static DECLCALLBACK(void) i_displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface,
346 VBOXVDMACMD_CHROMIUM_CMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd,
347 uint32_t cbCmd);
348 static DECLCALLBACK(void) i_displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface,
349 VBOXVDMACMD_CHROMIUM_CTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl,
350 uint32_t cbCtl);
351
352 static DECLCALLBACK(void) i_displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
353 void *pvContext);
354 static DECLCALLBACK(void) i_displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
355 void *pvContext);
356#endif
357#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
358 static DECLCALLBACK(int) i_displayCrHgcmCtlSubmit(PPDMIDISPLAYCONNECTOR pInterface, struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd,
359 PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
360 static DECLCALLBACK(void) i_displayCrHgcmCtlSubmitCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
361 void *pvContext);
362#endif
363#ifdef VBOX_WITH_HGSMI
364 static DECLCALLBACK(int) i_displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
365 VBVAHOSTFLAGS RT_UNTRUSTED_VOLATILE_GUEST *pHostFlags, bool fRenderThreadMode);
366 static DECLCALLBACK(void) i_displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
367 static DECLCALLBACK(void) i_displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
368 static DECLCALLBACK(void) i_displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
369 struct VBVACMDHDR const RT_UNTRUSTED_VOLATILE_GUEST *pCmd, size_t cbCmd);
370 static DECLCALLBACK(void) i_displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y,
371 uint32_t cx, uint32_t cy);
372 static DECLCALLBACK(int) i_displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, PCVBVAINFOVIEW pView,
373 PCVBVAINFOSCREEN pScreen, void *pvVRAM,
374 bool fResetInputMapping);
375 static DECLCALLBACK(int) i_displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
376 uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
377 const void *pvShape);
378 static DECLCALLBACK(void) i_displayVBVAGuestCapabilityUpdate(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fCapabilities);
379
380 static DECLCALLBACK(void) i_displayVBVAInputMappingUpdate(PPDMIDISPLAYCONNECTOR pInterface, int32_t xOrigin, int32_t yOrigin,
381 uint32_t cx, uint32_t cy);
382 static DECLCALLBACK(void) i_displayVBVAReportCursorPosition(PPDMIDISPLAYCONNECTOR pInterface, bool fData, uint32_t x, uint32_t y);
383#endif
384
385#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
386 static DECLCALLBACK(void) i_displayCrVRecScreenshotPerform(void *pvCtx, uint32_t uScreen,
387 uint32_t x, uint32_t y,
388 uint32_t uBitsPerPixel, uint32_t uBytesPerLine,
389 uint32_t uGuestWidth, uint32_t uGuestHeight,
390 uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
391 static DECLCALLBACK(bool) i_displayCrVRecScreenshotBegin(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
392 static DECLCALLBACK(void) i_displayCrVRecScreenshotEnd(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
393
394 static DECLCALLBACK(void) i_displayVRecCompletion(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
395#endif
396 static DECLCALLBACK(void) i_displayCrCmdFree(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
397
398 static DECLCALLBACK(void) i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
399 static DECLCALLBACK(int) i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
400 static DECLCALLBACK(void) i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
401 static DECLCALLBACK(int) i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
402
403 Console * const mParent;
404 /** Pointer to the associated display driver. */
405 struct DRVMAINDISPLAY *mpDrv;
406
407 unsigned mcMonitors;
408 /** Input mapping rectangle top left X relative to the first screen. */
409 int32_t xInputMappingOrigin;
410 /** Input mapping rectangle top left Y relative to the first screen. */
411 int32_t yInputMappingOrigin;
412 uint32_t cxInputMapping; /**< Input mapping rectangle width. */
413 uint32_t cyInputMapping; /**< Input mapping rectangle height. */
414 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
415 /** Does the VMM device have the "supports graphics" capability set?
416 * Does not go into the saved state as it is refreshed on restore. */
417 bool mfVMMDevSupportsGraphics;
418 /** Mirror of the current guest VBVA capabilities. */
419 uint32_t mfGuestVBVACapabilities;
420 /** Mirror of the current host cursor capabilities. */
421 uint32_t mfHostCursorCapabilities;
422
423 bool mfSourceBitmapEnabled;
424 bool volatile fVGAResizing;
425
426 /** Are we in seamless mode? Not saved, as we exit seamless on saving. */
427 bool mfSeamlessEnabled;
428 /** Last set seamless visible region, number of rectangles. */
429 uint32_t mcRectVisibleRegion;
430 /** Last set seamless visible region, data. Freed on final clean-up. */
431 PRTRECT mpRectVisibleRegion;
432
433 bool mfVideoAccelVRDP;
434 uint32_t mfu32SupportedOrders;
435 int32_t volatile mcVideoAccelVRDPRefs;
436
437 /** Accelerate3DEnabled = true && GraphicsControllerType == VBoxVGA. */
438 bool mfIsCr3DEnabled;
439
440#ifdef VBOX_WITH_CROGL
441 bool mfCrOglDataHidden;
442#endif
443
444#ifdef VBOX_WITH_CRHGSMI
445 /* for fast host hgcm calls */
446 HGCMCVSHANDLE mhCrOglSvc;
447 RTCRITSECTRW mCrOglLock;
448#endif
449#ifdef VBOX_WITH_CROGL
450 CR_MAIN_INTERFACE mCrOglCallbacks;
451 volatile uint32_t mfCrOglVideoRecState;
452 CRVBOXHGCMTAKESCREENSHOT mCrOglScreenshotData;
453 VBOXCRCMDCTL_HGCM mCrOglScreenshotCtl;
454#endif
455
456 /* The legacy VBVA data and methods. */
457 VIDEOACCEL mVideoAccelLegacy;
458
459 int i_VideoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
460 void i_VideoAccelFlush(PPDMIDISPLAYPORT pUpPort);
461 bool i_VideoAccelAllowed(void);
462
463 int i_videoAccelRefreshProcess(PPDMIDISPLAYPORT pUpPort);
464 int i_videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
465 int i_videoAccelFlush(PPDMIDISPLAYPORT pUpPort);
466
467 /* Legacy pre-HGSMI handlers. */
468 void processAdapterData(void *pvVRAM, uint32_t u32VRAMSize);
469 void processDisplayData(void *pvVRAM, unsigned uScreenId);
470
471 /** Serializes access to mVideoAccelLegacy and mfVideoAccelVRDP, etc between VRDP and Display. */
472 RTCRITSECT mVideoAccelLock;
473
474#ifdef VBOX_WITH_VIDEOREC
475 /* Serializes access to video recording source bitmaps. */
476 RTCRITSECT mVideoRecLock;
477 /** The current video recording configuration being used. */
478 VIDEORECCFG mVideoRecCfg;
479 /** The video recording context. */
480 VIDEORECCONTEXT *mpVideoRecCtx;
481 /** Array which defines which screens are being enabled for recording. */
482 bool maVideoRecEnabled[SchemaDefs::MaxGuestMonitors];
483#endif
484
485public:
486
487 static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
488 uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
489#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
490 static BOOL i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pbData,
491 uint32_t u32Width, uint32_t u32Height);
492 int i_crCtlSubmit(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd, PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
493 int i_crCtlSubmitSync(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd);
494 /* copies the given command and submits it asynchronously,
495 * i.e. the pCmd data may be discarded right after the call returns */
496 int i_crCtlSubmitAsyncCmdCopy(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
497 /* performs synchronous request processing if 3D backend has something to display
498 * this is primarily to work-around 3d<->main thread deadlocks on OSX
499 * in case of async completion, the command is coppied to the allocated buffer,
500 * freeded on command completion
501 * can be used for "notification" commands, when client is not interested in command result,
502 * that must synchronize with 3D backend only when some 3D data is displayed.
503 * The routine does NOT provide any info on whether command is processed asynchronously or not */
504 int i_crCtlSubmitSyncIfHasDataForScreen(uint32_t u32ScreenID, struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
505#endif
506
507private:
508 static int i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
509 static int i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
510
511 void i_updateGuestGraphicsFacility(void);
512
513#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
514 int i_crOglWindowsShow(bool fShow);
515#endif
516
517#ifdef VBOX_WITH_HGSMI
518 volatile uint32_t mu32UpdateVBVAFlags;
519#endif
520
521private:
522 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Display); /* Shuts up MSC warning C4625. */
523};
524
525/* The legacy VBVA helpers. */
526int videoAccelConstruct(VIDEOACCEL *pVideoAccel);
527void videoAccelDestroy(VIDEOACCEL *pVideoAccel);
528void i_vbvaSetMemoryFlags(VBVAMEMORY *pVbvaMemory,
529 bool fVideoAccelEnabled,
530 bool fVideoAccelVRDP,
531 uint32_t fu32SupportedOrders,
532 DISPLAYFBINFO *paFBInfos,
533 unsigned cFBInfos);
534int videoAccelEnterVGA(VIDEOACCEL *pVideoAccel);
535void videoAccelLeaveVGA(VIDEOACCEL *pVideoAccel);
536int videoAccelEnterVMMDev(VIDEOACCEL *pVideoAccel);
537void videoAccelLeaveVMMDev(VIDEOACCEL *pVideoAccel);
538
539
540/* helper function, code in DisplayResampleImage.cpp */
541void BitmapScale32(uint8_t *dst, int dstW, int dstH,
542 const uint8_t *src, int iDeltaLine, int srcW, int srcH);
543
544/* helper function, code in DisplayPNGUtul.cpp */
545int DisplayMakePNG(uint8_t *pbData, uint32_t cx, uint32_t cy,
546 uint8_t **ppu8PNG, uint32_t *pcbPNG, uint32_t *pcxPNG, uint32_t *pcyPNG,
547 uint8_t fLimitSize);
548
549class ATL_NO_VTABLE DisplaySourceBitmap:
550 public DisplaySourceBitmapWrap
551{
552public:
553
554 DECLARE_EMPTY_CTOR_DTOR(DisplaySourceBitmap)
555
556 HRESULT FinalConstruct();
557 void FinalRelease();
558
559 /* Public initializer/uninitializer for internal purposes only. */
560 HRESULT init(ComObjPtr<Display> pDisplay, unsigned uScreenId, DISPLAYFBINFO *pFBInfo);
561 void uninit();
562
563 bool i_usesVRAM(void) { return m.pu8Allocated == NULL; }
564
565private:
566 // wrapped IDisplaySourceBitmap properties
567 virtual HRESULT getScreenId(ULONG *aScreenId);
568
569 // wrapped IDisplaySourceBitmap methods
570 virtual HRESULT queryBitmapInfo(BYTE **aAddress,
571 ULONG *aWidth,
572 ULONG *aHeight,
573 ULONG *aBitsPerPixel,
574 ULONG *aBytesPerLine,
575 BitmapFormat_T *aBitmapFormat);
576
577 int initSourceBitmap(unsigned aScreenId, DISPLAYFBINFO *pFBInfo);
578
579 struct Data
580 {
581 ComObjPtr<Display> pDisplay;
582 unsigned uScreenId;
583 DISPLAYFBINFO *pFBInfo;
584
585 uint8_t *pu8Allocated;
586
587 uint8_t *pu8Address;
588 ULONG ulWidth;
589 ULONG ulHeight;
590 ULONG ulBitsPerPixel;
591 ULONG ulBytesPerLine;
592 BitmapFormat_T bitmapFormat;
593 };
594
595 Data m;
596};
597
598#endif // !____H_DISPLAYIMPL
599/* 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