1 | /* $Id: DisplayImpl.h 82968 2020-02-04 10:35:17Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2020 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 MAIN_INCLUDED_DisplayImpl_h
|
---|
19 | #define MAIN_INCLUDED_DisplayImpl_h
|
---|
20 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
21 | # pragma once
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #include "SchemaDefs.h"
|
---|
25 |
|
---|
26 | #include <iprt/semaphore.h>
|
---|
27 | #include <VBox/vmm/pdmdrv.h>
|
---|
28 | #include <VBoxVideo.h>
|
---|
29 | #include <VBox/vmm/pdmifs.h>
|
---|
30 | #include <VBox/VMMDev.h> /* For struct VMMDevDisplayDef - why is it in that file? */
|
---|
31 | #include "DisplayWrap.h"
|
---|
32 |
|
---|
33 | #include "DisplaySourceBitmapWrap.h"
|
---|
34 | #include "GuestScreenInfoWrap.h"
|
---|
35 |
|
---|
36 |
|
---|
37 | class Console;
|
---|
38 |
|
---|
39 | typedef 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 | VBVAHOSTFLAGS RT_UNTRUSTED_VOLATILE_GUEST *pVBVAHostFlags;
|
---|
84 | #endif /* VBOX_WITH_HGSMI */
|
---|
85 |
|
---|
86 | #ifdef VBOX_WITH_RECORDING
|
---|
87 | struct
|
---|
88 | {
|
---|
89 | ComPtr<IDisplaySourceBitmap> pSourceBitmap;
|
---|
90 | } Recording;
|
---|
91 | #endif /* VBOX_WITH_RECORDING */
|
---|
92 |
|
---|
93 | /** Description of the currently plugged monitor with preferred mode,
|
---|
94 | * a.k.a the last mode hint sent. */
|
---|
95 | struct VMMDevDisplayDef monitorDesc;
|
---|
96 | } DISPLAYFBINFO;
|
---|
97 |
|
---|
98 | /* The legacy VBVA (VideoAccel) data.
|
---|
99 | *
|
---|
100 | * Backward compatibility with the guest additions 3.x or older.
|
---|
101 | */
|
---|
102 | typedef struct VIDEOACCEL
|
---|
103 | {
|
---|
104 | VBVAMEMORY *pVbvaMemory;
|
---|
105 | bool fVideoAccelEnabled;
|
---|
106 |
|
---|
107 | uint8_t *pu8VbvaPartial;
|
---|
108 | uint32_t cbVbvaPartial;
|
---|
109 |
|
---|
110 | /* Old guest additions (3.x and older) use both VMMDev and DevVGA refresh timer
|
---|
111 | * to process the VBVABUFFER memory. Therefore the legacy VBVA (VideoAccel) host
|
---|
112 | * code can be executed concurrently by VGA refresh timer and the guest VMMDev
|
---|
113 | * request in SMP VMs. The semaphore serialized this.
|
---|
114 | */
|
---|
115 | RTSEMXROADS hXRoadsVideoAccel;
|
---|
116 |
|
---|
117 | } VIDEOACCEL;
|
---|
118 |
|
---|
119 | class DisplayMouseInterface
|
---|
120 | {
|
---|
121 | public:
|
---|
122 | virtual HRESULT i_getScreenResolution(ULONG cScreen, ULONG *pcx,
|
---|
123 | ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin) = 0;
|
---|
124 | virtual void i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
|
---|
125 | int32_t *px2, int32_t *py2) = 0;
|
---|
126 | virtual HRESULT i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved) = 0;
|
---|
127 | virtual HRESULT i_reportHostCursorPosition(int32_t x, int32_t y, bool fOutOfRange) = 0;
|
---|
128 | virtual bool i_isInputMappingSet(void) = 0;
|
---|
129 | };
|
---|
130 |
|
---|
131 | class VMMDev;
|
---|
132 |
|
---|
133 | class ATL_NO_VTABLE Display :
|
---|
134 | public DisplayWrap,
|
---|
135 | public DisplayMouseInterface
|
---|
136 | {
|
---|
137 | public:
|
---|
138 |
|
---|
139 | DECLARE_EMPTY_CTOR_DTOR(Display)
|
---|
140 |
|
---|
141 | HRESULT FinalConstruct();
|
---|
142 | void FinalRelease();
|
---|
143 |
|
---|
144 | // public initializer/uninitializer for internal purposes only
|
---|
145 | HRESULT init(Console *aParent);
|
---|
146 | void uninit();
|
---|
147 | int i_registerSSM(PUVM pUVM);
|
---|
148 |
|
---|
149 | // public methods only for internal purposes
|
---|
150 | unsigned i_getMonitorCount() { return mcMonitors; }
|
---|
151 | int i_handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM,
|
---|
152 | uint32_t cbLine, uint32_t w, uint32_t h, uint16_t flags,
|
---|
153 | int32_t xOrigin, int32_t yOrigin, bool fVGAResize);
|
---|
154 | void i_handleDisplayUpdate(unsigned uScreenId, int x, int y, int w, int h);
|
---|
155 | void i_handleUpdateVMMDevSupportsGraphics(bool fSupportsGraphics);
|
---|
156 | void i_handleUpdateGuestVBVACapabilities(uint32_t fNewCapabilities);
|
---|
157 | void i_handleUpdateVBVAInputMapping(int32_t xOrigin, int32_t yOrigin, uint32_t cx, uint32_t cy);
|
---|
158 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
159 | int i_handleVHWACommandProcess(int enmCmd, bool fGuestCmd, VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand);
|
---|
160 | #endif
|
---|
161 |
|
---|
162 | int i_saveVisibleRegion(uint32_t cRect, PRTRECT pRect);
|
---|
163 | int i_handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect);
|
---|
164 | int i_handleQueryVisibleRegion(uint32_t *pcRects, PRTRECT paRects);
|
---|
165 |
|
---|
166 | void i_VRDPConnectionEvent(bool fConnect);
|
---|
167 | void i_VideoAccelVRDP(bool fEnable, int c);
|
---|
168 |
|
---|
169 | /* Legacy video acceleration requests coming from the VGA refresh timer. */
|
---|
170 | int VideoAccelEnableVGA(bool fEnable, VBVAMEMORY *pVbvaMemory);
|
---|
171 |
|
---|
172 | /* Legacy video acceleration requests coming from VMMDev. */
|
---|
173 | int VideoAccelEnableVMMDev(bool fEnable, VBVAMEMORY *pVbvaMemory);
|
---|
174 | void VideoAccelFlushVMMDev(void);
|
---|
175 |
|
---|
176 | void i_UpdateDeviceCursorCapabilities(void);
|
---|
177 |
|
---|
178 | #ifdef VBOX_WITH_RECORDING
|
---|
179 | int i_recordingInvalidate(void);
|
---|
180 | void i_recordingScreenChanged(unsigned uScreenId);
|
---|
181 | #endif
|
---|
182 |
|
---|
183 | void i_notifyPowerDown(void);
|
---|
184 |
|
---|
185 | // DisplayMouseInterface methods
|
---|
186 | virtual HRESULT i_getScreenResolution(ULONG cScreen, ULONG *pcx,
|
---|
187 | ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin)
|
---|
188 | {
|
---|
189 | return getScreenResolution(cScreen, pcx, pcy, pcBPP, pXOrigin, pYOrigin, NULL);
|
---|
190 | }
|
---|
191 | virtual void i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
|
---|
192 | int32_t *px2, int32_t *py2);
|
---|
193 | virtual HRESULT i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved);
|
---|
194 | virtual HRESULT i_reportHostCursorPosition(int32_t x, int32_t y, bool fOutOfRange);
|
---|
195 | virtual bool i_isInputMappingSet(void)
|
---|
196 | {
|
---|
197 | return cxInputMapping != 0 && cyInputMapping != 0;
|
---|
198 | }
|
---|
199 |
|
---|
200 | static const PDMDRVREG DrvReg;
|
---|
201 |
|
---|
202 | private:
|
---|
203 | // Wrapped IDisplay properties
|
---|
204 | virtual HRESULT getGuestScreenLayout(std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenLayout);
|
---|
205 |
|
---|
206 | // Wrapped IDisplay methods
|
---|
207 | virtual HRESULT getScreenResolution(ULONG aScreenId,
|
---|
208 | ULONG *aWidth,
|
---|
209 | ULONG *aHeight,
|
---|
210 | ULONG *aBitsPerPixel,
|
---|
211 | LONG *aXOrigin,
|
---|
212 | LONG *aYOrigin,
|
---|
213 | GuestMonitorStatus_T *aGuestMonitorStatus);
|
---|
214 | virtual HRESULT attachFramebuffer(ULONG aScreenId,
|
---|
215 | const ComPtr<IFramebuffer> &aFramebuffer,
|
---|
216 | com::Guid &aId);
|
---|
217 | virtual HRESULT detachFramebuffer(ULONG aScreenId,
|
---|
218 | const com::Guid &aId);
|
---|
219 | virtual HRESULT queryFramebuffer(ULONG aScreenId,
|
---|
220 | ComPtr<IFramebuffer> &aFramebuffer);
|
---|
221 | virtual HRESULT setVideoModeHint(ULONG aDisplay,
|
---|
222 | BOOL aEnabled,
|
---|
223 | BOOL aChangeOrigin,
|
---|
224 | LONG aOriginX,
|
---|
225 | LONG aOriginY,
|
---|
226 | ULONG aWidth,
|
---|
227 | ULONG aHeight,
|
---|
228 | ULONG aBitsPerPixel,
|
---|
229 | BOOL aNotify);
|
---|
230 | virtual HRESULT getVideoModeHint(ULONG aDisplay,
|
---|
231 | BOOL *aEnabled,
|
---|
232 | BOOL *aChangeOrigin,
|
---|
233 | LONG *aOriginX,
|
---|
234 | LONG *aOriginY,
|
---|
235 | ULONG *aWidth,
|
---|
236 | ULONG *aHeight,
|
---|
237 | ULONG *aBitsPerPixel);
|
---|
238 | virtual HRESULT setSeamlessMode(BOOL aEnabled);
|
---|
239 | virtual HRESULT takeScreenShot(ULONG aScreenId,
|
---|
240 | BYTE *aAddress,
|
---|
241 | ULONG aWidth,
|
---|
242 | ULONG aHeight,
|
---|
243 | BitmapFormat_T aBitmapFormat);
|
---|
244 | virtual HRESULT takeScreenShotToArray(ULONG aScreenId,
|
---|
245 | ULONG aWidth,
|
---|
246 | ULONG aHeight,
|
---|
247 | BitmapFormat_T aBitmapFormat,
|
---|
248 | std::vector<BYTE> &aScreenData);
|
---|
249 | virtual HRESULT drawToScreen(ULONG aScreenId,
|
---|
250 | BYTE *aAddress,
|
---|
251 | ULONG aX,
|
---|
252 | ULONG aY,
|
---|
253 | ULONG aWidth,
|
---|
254 | ULONG aHeight);
|
---|
255 | virtual HRESULT invalidateAndUpdate();
|
---|
256 | virtual HRESULT invalidateAndUpdateScreen(ULONG aScreenId);
|
---|
257 | virtual HRESULT completeVHWACommand(BYTE *aCommand);
|
---|
258 | virtual HRESULT viewportChanged(ULONG aScreenId,
|
---|
259 | ULONG aX,
|
---|
260 | ULONG aY,
|
---|
261 | ULONG aWidth,
|
---|
262 | ULONG aHeight);
|
---|
263 | virtual HRESULT querySourceBitmap(ULONG aScreenId,
|
---|
264 | ComPtr<IDisplaySourceBitmap> &aDisplaySourceBitmap);
|
---|
265 | virtual HRESULT notifyScaleFactorChange(ULONG aScreenId,
|
---|
266 | ULONG aScaleFactorWMultiplied,
|
---|
267 | ULONG aScaleFactorHMultiplied);
|
---|
268 | virtual HRESULT notifyHiDPIOutputPolicyChange(BOOL fUnscaledHiDPI);
|
---|
269 | virtual HRESULT setScreenLayout(ScreenLayoutMode_T aScreenLayoutMode,
|
---|
270 | const std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenInfo);
|
---|
271 | virtual HRESULT detachScreens(const std::vector<LONG> &aScreenIds);
|
---|
272 | virtual HRESULT createGuestScreenInfo(ULONG aDisplay,
|
---|
273 | GuestMonitorStatus_T aStatus,
|
---|
274 | BOOL aPrimary,
|
---|
275 | BOOL aChangeOrigin,
|
---|
276 | LONG aOriginX,
|
---|
277 | LONG aOriginY,
|
---|
278 | ULONG aWidth,
|
---|
279 | ULONG aHeight,
|
---|
280 | ULONG aBitsPerPixel,
|
---|
281 | ComPtr<IGuestScreenInfo> &aGuestScreenInfo);
|
---|
282 |
|
---|
283 | // Wrapped IEventListener properties
|
---|
284 |
|
---|
285 | // Wrapped IEventListener methods
|
---|
286 | virtual HRESULT handleEvent(const ComPtr<IEvent> &aEvent);
|
---|
287 |
|
---|
288 | // other internal methods
|
---|
289 | HRESULT takeScreenShotWorker(ULONG aScreenId,
|
---|
290 | BYTE *aAddress,
|
---|
291 | ULONG aWidth,
|
---|
292 | ULONG aHeight,
|
---|
293 | BitmapFormat_T aBitmapFormat,
|
---|
294 | ULONG *pcbOut);
|
---|
295 | int processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping);
|
---|
296 |
|
---|
297 | static DECLCALLBACK(void*) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
|
---|
298 | static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
|
---|
299 | static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
|
---|
300 | static DECLCALLBACK(void) i_drvPowerOff(PPDMDRVINS pDrvIns);
|
---|
301 | static DECLCALLBACK(int) i_displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM,
|
---|
302 | uint32_t cbLine, uint32_t cx, uint32_t cy);
|
---|
303 | static DECLCALLBACK(void) i_displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
304 | uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
|
---|
305 | static DECLCALLBACK(void) i_displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
|
---|
306 | static DECLCALLBACK(void) i_displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
|
---|
307 | static DECLCALLBACK(void) i_displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
|
---|
308 | static DECLCALLBACK(void) i_displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
309 | void *pvVRAM, uint32_t u32VRAMSize);
|
---|
310 | static DECLCALLBACK(void) i_displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
311 | void *pvVRAM, unsigned uScreenId);
|
---|
312 |
|
---|
313 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
314 | static DECLCALLBACK(int) i_displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, int enmCmd, bool fGuestCmd,
|
---|
315 | VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand);
|
---|
316 | #endif
|
---|
317 |
|
---|
318 | #ifdef VBOX_WITH_HGSMI
|
---|
319 | static DECLCALLBACK(int) i_displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
|
---|
320 | VBVAHOSTFLAGS RT_UNTRUSTED_VOLATILE_GUEST *pHostFlags);
|
---|
321 | static DECLCALLBACK(void) i_displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
|
---|
322 | static DECLCALLBACK(void) i_displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
|
---|
323 | static DECLCALLBACK(void) i_displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
|
---|
324 | struct VBVACMDHDR const RT_UNTRUSTED_VOLATILE_GUEST *pCmd, size_t cbCmd);
|
---|
325 | static DECLCALLBACK(void) i_displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y,
|
---|
326 | uint32_t cx, uint32_t cy);
|
---|
327 | static DECLCALLBACK(int) i_displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, PCVBVAINFOVIEW pView,
|
---|
328 | PCVBVAINFOSCREEN pScreen, void *pvVRAM,
|
---|
329 | bool fResetInputMapping);
|
---|
330 | static DECLCALLBACK(int) i_displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
|
---|
331 | uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
|
---|
332 | const void *pvShape);
|
---|
333 | static DECLCALLBACK(void) i_displayVBVAGuestCapabilityUpdate(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fCapabilities);
|
---|
334 |
|
---|
335 | static DECLCALLBACK(void) i_displayVBVAInputMappingUpdate(PPDMIDISPLAYCONNECTOR pInterface, int32_t xOrigin, int32_t yOrigin,
|
---|
336 | uint32_t cx, uint32_t cy);
|
---|
337 | static DECLCALLBACK(void) i_displayVBVAReportCursorPosition(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fFlags, uint32_t uScreen, uint32_t x, uint32_t y);
|
---|
338 | #endif
|
---|
339 |
|
---|
340 | static DECLCALLBACK(void) i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
|
---|
341 | static DECLCALLBACK(int) i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
|
---|
342 | static DECLCALLBACK(void) i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
|
---|
343 | static DECLCALLBACK(int) i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
|
---|
344 |
|
---|
345 | Console * const mParent;
|
---|
346 | /** Pointer to the associated display driver. */
|
---|
347 | struct DRVMAINDISPLAY *mpDrv;
|
---|
348 |
|
---|
349 | unsigned mcMonitors;
|
---|
350 | /** Input mapping rectangle top left X relative to the first screen. */
|
---|
351 | int32_t xInputMappingOrigin;
|
---|
352 | /** Input mapping rectangle top left Y relative to the first screen. */
|
---|
353 | int32_t yInputMappingOrigin;
|
---|
354 | uint32_t cxInputMapping; /**< Input mapping rectangle width. */
|
---|
355 | uint32_t cyInputMapping; /**< Input mapping rectangle height. */
|
---|
356 | DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
|
---|
357 | /** Does the VMM device have the "supports graphics" capability set?
|
---|
358 | * Does not go into the saved state as it is refreshed on restore. */
|
---|
359 | bool mfVMMDevSupportsGraphics;
|
---|
360 | /** Mirror of the current guest VBVA capabilities. */
|
---|
361 | uint32_t mfGuestVBVACapabilities;
|
---|
362 | /** Mirror of the current host cursor capabilities. */
|
---|
363 | uint32_t mfHostCursorCapabilities;
|
---|
364 |
|
---|
365 | bool mfSourceBitmapEnabled;
|
---|
366 | bool volatile fVGAResizing;
|
---|
367 |
|
---|
368 | /** Are we in seamless mode? Not saved, as we exit seamless on saving. */
|
---|
369 | bool mfSeamlessEnabled;
|
---|
370 | /** Last set seamless visible region, number of rectangles. */
|
---|
371 | uint32_t mcRectVisibleRegion;
|
---|
372 | /** Last set seamless visible region, data. Freed on final clean-up. */
|
---|
373 | PRTRECT mpRectVisibleRegion;
|
---|
374 |
|
---|
375 | bool mfVideoAccelVRDP;
|
---|
376 | uint32_t mfu32SupportedOrders;
|
---|
377 | /** Number of currently connected VRDP clients. */
|
---|
378 | int32_t volatile mcVRDPRefs;
|
---|
379 |
|
---|
380 | /* The legacy VBVA data and methods. */
|
---|
381 | VIDEOACCEL mVideoAccelLegacy;
|
---|
382 |
|
---|
383 | int i_VideoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
|
---|
384 | void i_VideoAccelFlush(PPDMIDISPLAYPORT pUpPort);
|
---|
385 | bool i_VideoAccelAllowed(void);
|
---|
386 |
|
---|
387 | int i_videoAccelRefreshProcess(PPDMIDISPLAYPORT pUpPort);
|
---|
388 | int i_videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
|
---|
389 | int i_videoAccelFlush(PPDMIDISPLAYPORT pUpPort);
|
---|
390 |
|
---|
391 | /* Legacy pre-HGSMI handlers. */
|
---|
392 | void processAdapterData(void *pvVRAM, uint32_t u32VRAMSize);
|
---|
393 | void processDisplayData(void *pvVRAM, unsigned uScreenId);
|
---|
394 |
|
---|
395 | /** Serializes access to mVideoAccelLegacy and mfVideoAccelVRDP, etc between VRDP and Display. */
|
---|
396 | RTCRITSECT mVideoAccelLock;
|
---|
397 |
|
---|
398 | #ifdef VBOX_WITH_RECORDING
|
---|
399 | /* Serializes access to video recording source bitmaps. */
|
---|
400 | RTCRITSECT mVideoRecLock;
|
---|
401 | /** Array which defines which screens are being enabled for recording. */
|
---|
402 | bool maRecordingEnabled[SchemaDefs::MaxGuestMonitors];
|
---|
403 | #endif
|
---|
404 |
|
---|
405 | public:
|
---|
406 |
|
---|
407 | static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
|
---|
408 | uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
|
---|
409 |
|
---|
410 | private:
|
---|
411 | static int i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
|
---|
412 | static int i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
|
---|
413 |
|
---|
414 | void i_updateGuestGraphicsFacility(void);
|
---|
415 |
|
---|
416 | #ifdef VBOX_WITH_HGSMI
|
---|
417 | volatile uint32_t mu32UpdateVBVAFlags;
|
---|
418 | #endif
|
---|
419 |
|
---|
420 | private:
|
---|
421 | DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Display); /* Shuts up MSC warning C4625. */
|
---|
422 | };
|
---|
423 |
|
---|
424 | /* The legacy VBVA helpers. */
|
---|
425 | int videoAccelConstruct(VIDEOACCEL *pVideoAccel);
|
---|
426 | void videoAccelDestroy(VIDEOACCEL *pVideoAccel);
|
---|
427 | void i_vbvaSetMemoryFlags(VBVAMEMORY *pVbvaMemory,
|
---|
428 | bool fVideoAccelEnabled,
|
---|
429 | bool fVideoAccelVRDP,
|
---|
430 | uint32_t fu32SupportedOrders,
|
---|
431 | DISPLAYFBINFO *paFBInfos,
|
---|
432 | unsigned cFBInfos);
|
---|
433 | int videoAccelEnterVGA(VIDEOACCEL *pVideoAccel);
|
---|
434 | void videoAccelLeaveVGA(VIDEOACCEL *pVideoAccel);
|
---|
435 | int videoAccelEnterVMMDev(VIDEOACCEL *pVideoAccel);
|
---|
436 | void videoAccelLeaveVMMDev(VIDEOACCEL *pVideoAccel);
|
---|
437 |
|
---|
438 |
|
---|
439 | /* helper function, code in DisplayResampleImage.cpp */
|
---|
440 | void BitmapScale32(uint8_t *dst, int dstW, int dstH,
|
---|
441 | const uint8_t *src, int iDeltaLine, int srcW, int srcH);
|
---|
442 |
|
---|
443 | /* helper function, code in DisplayPNGUtul.cpp */
|
---|
444 | int DisplayMakePNG(uint8_t *pbData, uint32_t cx, uint32_t cy,
|
---|
445 | uint8_t **ppu8PNG, uint32_t *pcbPNG, uint32_t *pcxPNG, uint32_t *pcyPNG,
|
---|
446 | uint8_t fLimitSize);
|
---|
447 |
|
---|
448 | class ATL_NO_VTABLE DisplaySourceBitmap:
|
---|
449 | public DisplaySourceBitmapWrap
|
---|
450 | {
|
---|
451 | public:
|
---|
452 |
|
---|
453 | DECLARE_EMPTY_CTOR_DTOR(DisplaySourceBitmap)
|
---|
454 |
|
---|
455 | HRESULT FinalConstruct();
|
---|
456 | void FinalRelease();
|
---|
457 |
|
---|
458 | /* Public initializer/uninitializer for internal purposes only. */
|
---|
459 | HRESULT init(ComObjPtr<Display> pDisplay, unsigned uScreenId, DISPLAYFBINFO *pFBInfo);
|
---|
460 | void uninit();
|
---|
461 |
|
---|
462 | bool i_usesVRAM(void) { return m.pu8Allocated == NULL; }
|
---|
463 |
|
---|
464 | private:
|
---|
465 | // wrapped IDisplaySourceBitmap properties
|
---|
466 | virtual HRESULT getScreenId(ULONG *aScreenId);
|
---|
467 |
|
---|
468 | // wrapped IDisplaySourceBitmap methods
|
---|
469 | virtual HRESULT queryBitmapInfo(BYTE **aAddress,
|
---|
470 | ULONG *aWidth,
|
---|
471 | ULONG *aHeight,
|
---|
472 | ULONG *aBitsPerPixel,
|
---|
473 | ULONG *aBytesPerLine,
|
---|
474 | BitmapFormat_T *aBitmapFormat);
|
---|
475 |
|
---|
476 | int initSourceBitmap(unsigned aScreenId, DISPLAYFBINFO *pFBInfo);
|
---|
477 |
|
---|
478 | struct Data
|
---|
479 | {
|
---|
480 | ComObjPtr<Display> pDisplay;
|
---|
481 | unsigned uScreenId;
|
---|
482 | DISPLAYFBINFO *pFBInfo;
|
---|
483 |
|
---|
484 | uint8_t *pu8Allocated;
|
---|
485 |
|
---|
486 | uint8_t *pu8Address;
|
---|
487 | ULONG ulWidth;
|
---|
488 | ULONG ulHeight;
|
---|
489 | ULONG ulBitsPerPixel;
|
---|
490 | ULONG ulBytesPerLine;
|
---|
491 | BitmapFormat_T bitmapFormat;
|
---|
492 | };
|
---|
493 |
|
---|
494 | Data m;
|
---|
495 | };
|
---|
496 |
|
---|
497 | class ATL_NO_VTABLE GuestScreenInfo:
|
---|
498 | public GuestScreenInfoWrap
|
---|
499 | {
|
---|
500 | public:
|
---|
501 |
|
---|
502 | DECLARE_EMPTY_CTOR_DTOR(GuestScreenInfo)
|
---|
503 |
|
---|
504 | HRESULT FinalConstruct();
|
---|
505 | void FinalRelease();
|
---|
506 |
|
---|
507 | /* Public initializer/uninitializer for internal purposes only. */
|
---|
508 | HRESULT init(ULONG aDisplay,
|
---|
509 | GuestMonitorStatus_T aGuestMonitorStatus,
|
---|
510 | BOOL aPrimary,
|
---|
511 | BOOL aChangeOrigin,
|
---|
512 | LONG aOriginX,
|
---|
513 | LONG aOriginY,
|
---|
514 | ULONG aWidth,
|
---|
515 | ULONG aHeight,
|
---|
516 | ULONG aBitsPerPixel);
|
---|
517 | void uninit();
|
---|
518 |
|
---|
519 | private:
|
---|
520 | // wrapped IGuestScreenInfo properties
|
---|
521 | virtual HRESULT getScreenId(ULONG *aScreenId);
|
---|
522 | virtual HRESULT getGuestMonitorStatus(GuestMonitorStatus_T *aGuestMonitorStatus);
|
---|
523 | virtual HRESULT getPrimary(BOOL *aPrimary);
|
---|
524 | virtual HRESULT getOrigin(BOOL *aOrigin);
|
---|
525 | virtual HRESULT getOriginX(LONG *aOriginX);
|
---|
526 | virtual HRESULT getOriginY(LONG *aOriginY);
|
---|
527 | virtual HRESULT getWidth(ULONG *aWidth);
|
---|
528 | virtual HRESULT getHeight(ULONG *aHeight);
|
---|
529 | virtual HRESULT getBitsPerPixel(ULONG *aBitsPerPixel);
|
---|
530 | virtual HRESULT getExtendedInfo(com::Utf8Str &aExtendedInfo);
|
---|
531 |
|
---|
532 | ULONG mScreenId;
|
---|
533 | GuestMonitorStatus_T mGuestMonitorStatus;
|
---|
534 | BOOL mPrimary;
|
---|
535 | BOOL mOrigin;
|
---|
536 | LONG mOriginX;
|
---|
537 | LONG mOriginY;
|
---|
538 | ULONG mWidth;
|
---|
539 | ULONG mHeight;
|
---|
540 | ULONG mBitsPerPixel;
|
---|
541 | };
|
---|
542 |
|
---|
543 | #endif /* !MAIN_INCLUDED_DisplayImpl_h */
|
---|
544 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|