VirtualBox

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

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

Main: remove the old resizing code.

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