VirtualBox

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

Last change on this file since 65410 was 65410, checked in by vboxsync, 8 years ago

VideoRec: Interface work, added container / codec configuration stuff.

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