VirtualBox

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

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

Devices/Graphics, pdm, Main: add out-of-range to host-side pointer reporting.
bugref:9376: Complete hardware cursor implementation in VMSVGA
The front-end can now send an out-of-range pointer event to say that the
pointer is outside of all guest windows. This can be useful when the cursor
is being drawn in software, as in this case it makes sense to hide it
altogether. The event is not yet passed down to the guest. Out-of-range,
like the already existing invalid data event (-1, -1) is passed as special
pointer co-ordinate values to avoid breaking API interfaces if this is
back-ported. A future change, not to be back-ported, will change the API to
get rid of the special values and do this cleanly.

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