VirtualBox

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

Last change on this file since 78784 was 78784, checked in by vboxsync, 6 years ago

API: add getVideoModeHint.
bugref:9472: API: let the GUI notice video mode hints from other sources.
This Display object API method lets a caller retrieve information about the
virtual monitor attached to a virtual display output, including the preferred
mode (was: last mode hint). The name is legacy and will be changed to
getMonitorInfo in 7.0.

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