VirtualBox

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

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

src-client: Define LOG_GROUP according to interface or similar.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.9 KB
Line 
1/* $Id: DisplayImpl.h 67914 2017-07-11 20:46:37Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2016 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
36
37class Console;
38struct VIDEORECCONTEXT;
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 PVBVAHOSTFLAGS 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_VIDEOREC
100 struct
101 {
102 ComPtr<IDisplaySourceBitmap> pSourceBitmap;
103 } videoCapture;
104#endif /* VBOX_WITH_VIDEOREC */
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(PVBOXVHWACMD 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(PVBOXVDMACMD_CHROMIUM_CMD pCmd, uint32_t cbCmd);
173 void i_handleCrHgsmiControlProcess(PVBOXVDMACMD_CHROMIUM_CTL pCtl, uint32_t cbCtl);
174#endif
175#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
176 int i_handleCrHgcmCtlSubmit(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
177 PFNCRCTLCOMPLETION pfnCompletion,
178 void *pvCompletion);
179 void i_handleCrVRecScreenshotPerform(uint32_t uScreen,
180 uint32_t x, uint32_t y, uint32_t uPixelFormat, uint32_t uBitsPerPixel,
181 uint32_t uBytesPerLine, uint32_t uGuestWidth, uint32_t uGuestHeight,
182 uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
183 /** @todo r=bird: u64TimeStamp - using the 'u64' prefix add nothing.
184 * However, using one of the prefixes indicating the timestamp unit
185 * would be very valuable! */
186 bool i_handleCrVRecScreenshotBegin(uint32_t uScreen, uint64_t u64TimeStamp);
187 void i_handleCrVRecScreenshotEnd(uint32_t uScreen, uint64_t u64TimeStamp);
188 void i_handleVRecCompletion();
189#endif
190
191 int i_notifyCroglResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM);
192
193 int i_saveVisibleRegion(uint32_t cRect, PRTRECT pRect);
194 int i_handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect);
195 int i_handleQueryVisibleRegion(uint32_t *pcRects, PRTRECT paRects);
196
197 void i_VideoAccelVRDP(bool fEnable);
198
199 /* Legacy video acceleration requests coming from the VGA refresh timer. */
200 int VideoAccelEnableVGA(bool fEnable, VBVAMEMORY *pVbvaMemory);
201
202 /* Legacy video acceleration requests coming from VMMDev. */
203 int VideoAccelEnableVMMDev(bool fEnable, VBVAMEMORY *pVbvaMemory);
204 void VideoAccelFlushVMMDev(void);
205
206 int i_videoCaptureEnableScreens(ComSafeArrayIn(BOOL, aScreens));
207 int i_videoCaptureSendAudio(const void *pvData, size_t cbData, uint64_t uTimestampMs);
208 int i_videoCaptureStart();
209 void i_videoCaptureStop();
210#ifdef VBOX_WITH_VIDEOREC
211 void videoCaptureScreenChanged(unsigned uScreenId);
212#endif
213
214 void i_notifyPowerDown(void);
215
216 // DisplayMouseInterface methods
217 virtual HRESULT i_getScreenResolution(ULONG cScreen, ULONG *pcx,
218 ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin)
219 {
220 return getScreenResolution(cScreen, pcx, pcy, pcBPP, pXOrigin, pYOrigin, NULL);
221 }
222 virtual void i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
223 int32_t *px2, int32_t *py2);
224 virtual HRESULT i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved);
225 virtual HRESULT i_reportHostCursorPosition(int32_t x, int32_t y);
226 virtual bool i_isInputMappingSet(void)
227 {
228 return cxInputMapping != 0 && cyInputMapping != 0;
229 }
230
231 static const PDMDRVREG DrvReg;
232
233private:
234 // Wrapped IDisplay properties
235 virtual HRESULT getGuestScreenLayout(std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenLayout);
236
237 // Wrapped IDisplay methods
238 virtual HRESULT getScreenResolution(ULONG aScreenId,
239 ULONG *aWidth,
240 ULONG *aHeight,
241 ULONG *aBitsPerPixel,
242 LONG *aXOrigin,
243 LONG *aYOrigin,
244 GuestMonitorStatus_T *aGuestMonitorStatus);
245 virtual HRESULT attachFramebuffer(ULONG aScreenId,
246 const ComPtr<IFramebuffer> &aFramebuffer,
247 com::Guid &aId);
248 virtual HRESULT detachFramebuffer(ULONG aScreenId,
249 const com::Guid &aId);
250 virtual HRESULT queryFramebuffer(ULONG aScreenId,
251 ComPtr<IFramebuffer> &aFramebuffer);
252 virtual HRESULT setVideoModeHint(ULONG aDisplay,
253 BOOL aEnabled,
254 BOOL aChangeOrigin,
255 LONG aOriginX,
256 LONG aOriginY,
257 ULONG aWidth,
258 ULONG aHeight,
259 ULONG aBitsPerPixel);
260 virtual HRESULT setSeamlessMode(BOOL aEnabled);
261 virtual HRESULT takeScreenShot(ULONG aScreenId,
262 BYTE *aAddress,
263 ULONG aWidth,
264 ULONG aHeight,
265 BitmapFormat_T aBitmapFormat);
266 virtual HRESULT takeScreenShotToArray(ULONG aScreenId,
267 ULONG aWidth,
268 ULONG aHeight,
269 BitmapFormat_T aBitmapFormat,
270 std::vector<BYTE> &aScreenData);
271 virtual HRESULT drawToScreen(ULONG aScreenId,
272 BYTE *aAddress,
273 ULONG aX,
274 ULONG aY,
275 ULONG aWidth,
276 ULONG aHeight);
277 virtual HRESULT invalidateAndUpdate();
278 virtual HRESULT invalidateAndUpdateScreen(ULONG aScreenId);
279 virtual HRESULT completeVHWACommand(BYTE *aCommand);
280 virtual HRESULT viewportChanged(ULONG aScreenId,
281 ULONG aX,
282 ULONG aY,
283 ULONG aWidth,
284 ULONG aHeight);
285 virtual HRESULT querySourceBitmap(ULONG aScreenId,
286 ComPtr<IDisplaySourceBitmap> &aDisplaySourceBitmap);
287 virtual HRESULT notifyScaleFactorChange(ULONG aScreenId,
288 ULONG aScaleFactorWMultiplied,
289 ULONG aScaleFactorHMultiplied);
290 virtual HRESULT notifyHiDPIOutputPolicyChange(BOOL fUnscaledHiDPI);
291 virtual HRESULT setScreenLayout(ScreenLayoutMode_T aScreenLayoutMode,
292 const std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenInfo);
293
294 // Wrapped IEventListener properties
295
296 // Wrapped IEventListener methods
297 virtual HRESULT handleEvent(const ComPtr<IEvent> &aEvent);
298
299 // other internal methods
300 HRESULT takeScreenShotWorker(ULONG aScreenId,
301 BYTE *aAddress,
302 ULONG aWidth,
303 ULONG aHeight,
304 BitmapFormat_T aBitmapFormat,
305 ULONG *pcbOut);
306 int processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping);
307
308#ifdef VBOX_WITH_CRHGSMI
309 void i_setupCrHgsmiData(void);
310 void i_destructCrHgsmiData(void);
311#endif
312
313#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
314 int i_crViewportNotify(ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height);
315#endif
316
317 static DECLCALLBACK(void*) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
318 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
319 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
320 static DECLCALLBACK(int) i_displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM,
321 uint32_t cbLine, uint32_t cx, uint32_t cy);
322 static DECLCALLBACK(void) i_displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
323 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
324 static DECLCALLBACK(void) i_displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
325 static DECLCALLBACK(void) i_displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
326 static DECLCALLBACK(void) i_displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
327 static DECLCALLBACK(void) i_displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
328 void *pvVRAM, uint32_t u32VRAMSize);
329 static DECLCALLBACK(void) i_displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
330 void *pvVRAM, unsigned uScreenId);
331
332#ifdef VBOX_WITH_VIDEOHWACCEL
333 static DECLCALLBACK(int) i_displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand);
334#endif
335
336#ifdef VBOX_WITH_CRHGSMI
337 static DECLCALLBACK(void) i_displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface,
338 PVBOXVDMACMD_CHROMIUM_CMD pCmd, uint32_t cbCmd);
339 static DECLCALLBACK(void) i_displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl,
340 uint32_t cbCtl);
341
342 static DECLCALLBACK(void) i_displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
343 void *pvContext);
344 static DECLCALLBACK(void) i_displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
345 void *pvContext);
346#endif
347#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
348 static DECLCALLBACK(int) i_displayCrHgcmCtlSubmit(PPDMIDISPLAYCONNECTOR pInterface,
349 struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd,
350 PFNCRCTLCOMPLETION pfnCompletion,
351 void *pvCompletion);
352 static DECLCALLBACK(void) i_displayCrHgcmCtlSubmitCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
353 void *pvContext);
354#endif
355#ifdef VBOX_WITH_HGSMI
356 static DECLCALLBACK(int) i_displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
357 PVBVAHOSTFLAGS pHostFlags, bool fRenderThreadMode);
358 static DECLCALLBACK(void) i_displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
359 static DECLCALLBACK(void) i_displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
360 static DECLCALLBACK(void) i_displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
361 PCVBVACMDHDR pCmd, size_t cbCmd);
362 static DECLCALLBACK(void) i_displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y,
363 uint32_t cx, uint32_t cy);
364 static DECLCALLBACK(int) i_displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, PCVBVAINFOVIEW pView,
365 PCVBVAINFOSCREEN pScreen, void *pvVRAM,
366 bool fResetInputMapping);
367 static DECLCALLBACK(int) i_displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
368 uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
369 const void *pvShape);
370 static DECLCALLBACK(void) i_displayVBVAGuestCapabilityUpdate(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fCapabilities);
371
372 static DECLCALLBACK(void) i_displayVBVAInputMappingUpdate(PPDMIDISPLAYCONNECTOR pInterface, int32_t xOrigin, int32_t yOrigin,
373 uint32_t cx, uint32_t cy);
374#endif
375
376#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
377 static DECLCALLBACK(void) i_displayCrVRecScreenshotPerform(void *pvCtx, uint32_t uScreen,
378 uint32_t x, uint32_t y,
379 uint32_t uBitsPerPixel, uint32_t uBytesPerLine,
380 uint32_t uGuestWidth, uint32_t uGuestHeight,
381 uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
382 static DECLCALLBACK(bool) i_displayCrVRecScreenshotBegin(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
383 static DECLCALLBACK(void) i_displayCrVRecScreenshotEnd(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
384
385 static DECLCALLBACK(void) i_displayVRecCompletion(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
386#endif
387 static DECLCALLBACK(void) i_displayCrCmdFree(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
388
389 static DECLCALLBACK(void) i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
390 static DECLCALLBACK(int) i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
391 static DECLCALLBACK(void) i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
392 static DECLCALLBACK(int) i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
393
394 Console * const mParent;
395 /** Pointer to the associated display driver. */
396 struct DRVMAINDISPLAY *mpDrv;
397 /** Pointer to the device instance for the VMM Device. */
398 PPDMDEVINS mpVMMDev;
399 /** Set after the first attempt to find the VMM Device. */
400 bool mfVMMDevInited;
401
402 unsigned mcMonitors;
403 /** Input mapping rectangle top left X relative to the first screen. */
404 int32_t xInputMappingOrigin;
405 /** Input mapping rectangle top left Y relative to the first screen. */
406 int32_t yInputMappingOrigin;
407 uint32_t cxInputMapping; /**< Input mapping rectangle width. */
408 uint32_t cyInputMapping; /**< Input mapping rectangle height. */
409 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
410 /** Does the VMM device have the "supports graphics" capability set?
411 * Does not go into the saved state as it is refreshed on restore. */
412 bool mfVMMDevSupportsGraphics;
413 /** Mirror of the current guest VBVA capabilities. */
414 uint32_t mfGuestVBVACapabilities;
415 /** Mirror of the current host cursor capabilities. */
416 uint32_t mfHostCursorCapabilities;
417
418 bool mfSourceBitmapEnabled;
419 bool volatile fVGAResizing;
420
421 /** Are we in seamless mode? Not saved, as we exit seamless on saving. */
422 bool mfSeamlessEnabled;
423 /** Last set seamless visible region, number of rectangles. */
424 uint32_t mcRectVisibleRegion;
425 /** Last set seamless visible region, data. Freed on final clean-up. */
426 PRTRECT mpRectVisibleRegion;
427
428 bool mfVideoAccelVRDP;
429 uint32_t mfu32SupportedOrders;
430 int32_t volatile mcVideoAccelVRDPRefs;
431
432 /** Accelerate3DEnabled = true && GraphicsControllerType == VBoxVGA. */
433 bool mfIsCr3DEnabled;
434
435#ifdef VBOX_WITH_CROGL
436 bool mfCrOglDataHidden;
437#endif
438
439#ifdef VBOX_WITH_CRHGSMI
440 /* for fast host hgcm calls */
441 HGCMCVSHANDLE mhCrOglSvc;
442 RTCRITSECTRW mCrOglLock;
443#endif
444#ifdef VBOX_WITH_CROGL
445 CR_MAIN_INTERFACE mCrOglCallbacks;
446 volatile uint32_t mfCrOglVideoRecState;
447 CRVBOXHGCMTAKESCREENSHOT mCrOglScreenshotData;
448 VBOXCRCMDCTL_HGCM mCrOglScreenshotCtl;
449#endif
450
451 /* The legacy VBVA data and methods. */
452 VIDEOACCEL mVideoAccelLegacy;
453
454 int i_VideoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
455 void i_VideoAccelFlush(PPDMIDISPLAYPORT pUpPort);
456 bool i_VideoAccelAllowed(void);
457
458 int i_videoAccelRefreshProcess(PPDMIDISPLAYPORT pUpPort);
459 int i_videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
460 int i_videoAccelFlush(PPDMIDISPLAYPORT pUpPort);
461
462 /* Legacy pre-HGSMI handlers. */
463 void processAdapterData(void *pvVRAM, uint32_t u32VRAMSize);
464 void processDisplayData(void *pvVRAM, unsigned uScreenId);
465
466 /* Serializes access to mVideoAccelLegacy and mfVideoAccelVRDP, etc between VRDP and Display. */
467 RTCRITSECT mVideoAccelLock;
468#ifdef VBOX_WITH_VIDEOREC
469 /* Serializes access to video capture source bitmaps. */
470 RTCRITSECT mVideoCaptureLock;
471#endif
472
473public:
474
475 static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
476 uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
477#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
478 static BOOL i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pbData,
479 uint32_t u32Width, uint32_t u32Height);
480 int i_crCtlSubmit(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
481 int i_crCtlSubmitSync(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
482 /* copies the given command and submits it asynchronously,
483 * i.e. the pCmd data may be discarded right after the call returns */
484 int i_crCtlSubmitAsyncCmdCopy(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
485 /* performs synchronous request processing if 3D backend has something to display
486 * this is primarily to work-around 3d<->main thread deadlocks on OSX
487 * in case of async completion, the command is coppied to the allocated buffer,
488 * freeded on command completion
489 * can be used for "notification" commands, when client is not interested in command result,
490 * that must synchronize with 3D backend only when some 3D data is displayed.
491 * The routine does NOT provide any info on whether command is processed asynchronously or not */
492 int i_crCtlSubmitSyncIfHasDataForScreen(uint32_t u32ScreenID, struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
493#endif
494
495private:
496 static int i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
497 static int i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
498
499 void i_updateGuestGraphicsFacility(void);
500
501#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
502 int i_crOglWindowsShow(bool fShow);
503#endif
504
505#ifdef VBOX_WITH_HGSMI
506 volatile uint32_t mu32UpdateVBVAFlags;
507#endif
508
509#ifdef VBOX_WITH_VIDEOREC
510 VIDEORECCONTEXT *mpVideoRecCtx;
511 bool maVideoRecEnabled[SchemaDefs::MaxGuestMonitors];
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
591#endif // !____H_DISPLAYIMPL
592/* 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