VirtualBox

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

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

pdmifs/DevVGA/DisplayImpl: add screen id to pfnVBVAReportCursorPosition.
bugref:9376: Complete hardware cursor implementation in VMSVGA.
vboxvideo in Linux passes cursor position information relative to a particular
screen, but we loose this information when we pass it on to the front-end.
Since no front-end has used the information yet this was not noticed. This
change fixes that and converts the co-ordinates to frame-buffer global ones
as early as possible.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.0 KB
Line 
1/* $Id: DisplayImpl.h 77130 2019-02-01 16:55:20Z 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) = 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_VideoAccelVRDP(bool fEnable);
196
197 /* Legacy video acceleration requests coming from the VGA refresh timer. */
198 int VideoAccelEnableVGA(bool fEnable, VBVAMEMORY *pVbvaMemory);
199
200 /* Legacy video acceleration requests coming from VMMDev. */
201 int VideoAccelEnableVMMDev(bool fEnable, VBVAMEMORY *pVbvaMemory);
202 void VideoAccelFlushVMMDev(void);
203
204#ifdef VBOX_WITH_RECORDING
205 int i_recordingInvalidate(void);
206 void i_recordingScreenChanged(unsigned uScreenId);
207#endif
208
209 void i_notifyPowerDown(void);
210
211 // DisplayMouseInterface methods
212 virtual HRESULT i_getScreenResolution(ULONG cScreen, ULONG *pcx,
213 ULONG *pcy, ULONG *pcBPP, LONG *pXOrigin, LONG *pYOrigin)
214 {
215 return getScreenResolution(cScreen, pcx, pcy, pcBPP, pXOrigin, pYOrigin, NULL);
216 }
217 virtual void i_getFramebufferDimensions(int32_t *px1, int32_t *py1,
218 int32_t *px2, int32_t *py2);
219 virtual HRESULT i_reportHostCursorCapabilities(uint32_t fCapabilitiesAdded, uint32_t fCapabilitiesRemoved);
220 virtual HRESULT i_reportHostCursorPosition(int32_t x, int32_t y);
221 virtual bool i_isInputMappingSet(void)
222 {
223 return cxInputMapping != 0 && cyInputMapping != 0;
224 }
225
226 static const PDMDRVREG DrvReg;
227
228private:
229 // Wrapped IDisplay properties
230 virtual HRESULT getGuestScreenLayout(std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenLayout);
231
232 // Wrapped IDisplay methods
233 virtual HRESULT getScreenResolution(ULONG aScreenId,
234 ULONG *aWidth,
235 ULONG *aHeight,
236 ULONG *aBitsPerPixel,
237 LONG *aXOrigin,
238 LONG *aYOrigin,
239 GuestMonitorStatus_T *aGuestMonitorStatus);
240 virtual HRESULT attachFramebuffer(ULONG aScreenId,
241 const ComPtr<IFramebuffer> &aFramebuffer,
242 com::Guid &aId);
243 virtual HRESULT detachFramebuffer(ULONG aScreenId,
244 const com::Guid &aId);
245 virtual HRESULT queryFramebuffer(ULONG aScreenId,
246 ComPtr<IFramebuffer> &aFramebuffer);
247 virtual HRESULT setVideoModeHint(ULONG aDisplay,
248 BOOL aEnabled,
249 BOOL aChangeOrigin,
250 LONG aOriginX,
251 LONG aOriginY,
252 ULONG aWidth,
253 ULONG aHeight,
254 ULONG aBitsPerPixel);
255 virtual HRESULT setSeamlessMode(BOOL aEnabled);
256 virtual HRESULT takeScreenShot(ULONG aScreenId,
257 BYTE *aAddress,
258 ULONG aWidth,
259 ULONG aHeight,
260 BitmapFormat_T aBitmapFormat);
261 virtual HRESULT takeScreenShotToArray(ULONG aScreenId,
262 ULONG aWidth,
263 ULONG aHeight,
264 BitmapFormat_T aBitmapFormat,
265 std::vector<BYTE> &aScreenData);
266 virtual HRESULT drawToScreen(ULONG aScreenId,
267 BYTE *aAddress,
268 ULONG aX,
269 ULONG aY,
270 ULONG aWidth,
271 ULONG aHeight);
272 virtual HRESULT invalidateAndUpdate();
273 virtual HRESULT invalidateAndUpdateScreen(ULONG aScreenId);
274 virtual HRESULT completeVHWACommand(BYTE *aCommand);
275 virtual HRESULT viewportChanged(ULONG aScreenId,
276 ULONG aX,
277 ULONG aY,
278 ULONG aWidth,
279 ULONG aHeight);
280 virtual HRESULT querySourceBitmap(ULONG aScreenId,
281 ComPtr<IDisplaySourceBitmap> &aDisplaySourceBitmap);
282 virtual HRESULT notifyScaleFactorChange(ULONG aScreenId,
283 ULONG aScaleFactorWMultiplied,
284 ULONG aScaleFactorHMultiplied);
285 virtual HRESULT notifyHiDPIOutputPolicyChange(BOOL fUnscaledHiDPI);
286 virtual HRESULT setScreenLayout(ScreenLayoutMode_T aScreenLayoutMode,
287 const std::vector<ComPtr<IGuestScreenInfo> > &aGuestScreenInfo);
288 virtual HRESULT detachScreens(const std::vector<LONG> &aScreenIds);
289 virtual HRESULT createGuestScreenInfo(ULONG aDisplay,
290 GuestMonitorStatus_T aStatus,
291 BOOL aPrimary,
292 BOOL aChangeOrigin,
293 LONG aOriginX,
294 LONG aOriginY,
295 ULONG aWidth,
296 ULONG aHeight,
297 ULONG aBitsPerPixel,
298 ComPtr<IGuestScreenInfo> &aGuestScreenInfo);
299
300 // Wrapped IEventListener properties
301
302 // Wrapped IEventListener methods
303 virtual HRESULT handleEvent(const ComPtr<IEvent> &aEvent);
304
305 // other internal methods
306 HRESULT takeScreenShotWorker(ULONG aScreenId,
307 BYTE *aAddress,
308 ULONG aWidth,
309 ULONG aHeight,
310 BitmapFormat_T aBitmapFormat,
311 ULONG *pcbOut);
312 int processVBVAResize(PCVBVAINFOVIEW pView, PCVBVAINFOSCREEN pScreen, void *pvVRAM, bool fResetInputMapping);
313
314#ifdef VBOX_WITH_CRHGSMI
315 void i_setupCrHgsmiData(void);
316 void i_destructCrHgsmiData(void);
317#endif
318
319#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
320 int i_crViewportNotify(ULONG aScreenId, ULONG x, ULONG y, ULONG width, ULONG height);
321#endif
322
323 static DECLCALLBACK(void*) i_drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
324 static DECLCALLBACK(int) i_drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
325 static DECLCALLBACK(void) i_drvDestruct(PPDMDRVINS pDrvIns);
326 static DECLCALLBACK(void) i_drvPowerOff(PPDMDRVINS pDrvIns);
327 static DECLCALLBACK(int) i_displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM,
328 uint32_t cbLine, uint32_t cx, uint32_t cy);
329 static DECLCALLBACK(void) i_displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
330 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
331 static DECLCALLBACK(void) i_displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
332 static DECLCALLBACK(void) i_displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
333 static DECLCALLBACK(void) i_displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
334 static DECLCALLBACK(void) i_displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
335 void *pvVRAM, uint32_t u32VRAMSize);
336 static DECLCALLBACK(void) i_displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface,
337 void *pvVRAM, unsigned uScreenId);
338
339#ifdef VBOX_WITH_VIDEOHWACCEL
340 static DECLCALLBACK(int) i_displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, int enmCmd, bool fGuestCmd,
341 VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand);
342#endif
343
344#ifdef VBOX_WITH_CRHGSMI
345 static DECLCALLBACK(void) i_displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface,
346 VBOXVDMACMD_CHROMIUM_CMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd,
347 uint32_t cbCmd);
348 static DECLCALLBACK(void) i_displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface,
349 VBOXVDMACMD_CHROMIUM_CTL RT_UNTRUSTED_VOLATILE_GUEST *pCtl,
350 uint32_t cbCtl);
351
352 static DECLCALLBACK(void) i_displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
353 void *pvContext);
354 static DECLCALLBACK(void) i_displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
355 void *pvContext);
356#endif
357#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
358 static DECLCALLBACK(int) i_displayCrHgcmCtlSubmit(PPDMIDISPLAYCONNECTOR pInterface, struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd,
359 PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
360 static DECLCALLBACK(void) i_displayCrHgcmCtlSubmitCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam,
361 void *pvContext);
362#endif
363#ifdef VBOX_WITH_HGSMI
364 static DECLCALLBACK(int) i_displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
365 VBVAHOSTFLAGS RT_UNTRUSTED_VOLATILE_GUEST *pHostFlags, bool fRenderThreadMode);
366 static DECLCALLBACK(void) i_displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
367 static DECLCALLBACK(void) i_displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
368 static DECLCALLBACK(void) i_displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId,
369 struct VBVACMDHDR const RT_UNTRUSTED_VOLATILE_GUEST *pCmd, size_t cbCmd);
370 static DECLCALLBACK(void) i_displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y,
371 uint32_t cx, uint32_t cy);
372 static DECLCALLBACK(int) i_displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, PCVBVAINFOVIEW pView,
373 PCVBVAINFOSCREEN pScreen, void *pvVRAM,
374 bool fResetInputMapping);
375 static DECLCALLBACK(int) i_displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha,
376 uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
377 const void *pvShape);
378 static DECLCALLBACK(void) i_displayVBVAGuestCapabilityUpdate(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fCapabilities);
379
380 static DECLCALLBACK(void) i_displayVBVAInputMappingUpdate(PPDMIDISPLAYCONNECTOR pInterface, int32_t xOrigin, int32_t yOrigin,
381 uint32_t cx, uint32_t cy);
382 static DECLCALLBACK(void) i_displayVBVAReportCursorPosition(PPDMIDISPLAYCONNECTOR pInterface, uint32_t fFlags, uint32_t uScreen, uint32_t x, uint32_t y);
383#endif
384
385#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
386 static DECLCALLBACK(void) i_displayCrVRecScreenshotPerform(void *pvCtx, uint32_t uScreen,
387 uint32_t x, uint32_t y,
388 uint32_t uBitsPerPixel, uint32_t uBytesPerLine,
389 uint32_t uGuestWidth, uint32_t uGuestHeight,
390 uint8_t *pu8BufferAddress, uint64_t u64TimeStamp);
391 static DECLCALLBACK(bool) i_displayCrVRecScreenshotBegin(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
392 static DECLCALLBACK(void) i_displayCrVRecScreenshotEnd(void *pvCtx, uint32_t uScreen, uint64_t u64TimeStamp);
393
394 static DECLCALLBACK(void) i_displayVRecCompletion(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
395#endif
396 static DECLCALLBACK(void) i_displayCrCmdFree(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd, int rc, void *pvCompletion);
397
398 static DECLCALLBACK(void) i_displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
399 static DECLCALLBACK(int) i_displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
400 static DECLCALLBACK(void) i_displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
401 static DECLCALLBACK(int) i_displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
402
403 Console * const mParent;
404 /** Pointer to the associated display driver. */
405 struct DRVMAINDISPLAY *mpDrv;
406
407 unsigned mcMonitors;
408 /** Input mapping rectangle top left X relative to the first screen. */
409 int32_t xInputMappingOrigin;
410 /** Input mapping rectangle top left Y relative to the first screen. */
411 int32_t yInputMappingOrigin;
412 uint32_t cxInputMapping; /**< Input mapping rectangle width. */
413 uint32_t cyInputMapping; /**< Input mapping rectangle height. */
414 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
415 /** Does the VMM device have the "supports graphics" capability set?
416 * Does not go into the saved state as it is refreshed on restore. */
417 bool mfVMMDevSupportsGraphics;
418 /** Mirror of the current guest VBVA capabilities. */
419 uint32_t mfGuestVBVACapabilities;
420 /** Mirror of the current host cursor capabilities. */
421 uint32_t mfHostCursorCapabilities;
422
423 bool mfSourceBitmapEnabled;
424 bool volatile fVGAResizing;
425
426 /** Are we in seamless mode? Not saved, as we exit seamless on saving. */
427 bool mfSeamlessEnabled;
428 /** Last set seamless visible region, number of rectangles. */
429 uint32_t mcRectVisibleRegion;
430 /** Last set seamless visible region, data. Freed on final clean-up. */
431 PRTRECT mpRectVisibleRegion;
432
433 bool mfVideoAccelVRDP;
434 uint32_t mfu32SupportedOrders;
435 int32_t volatile mcVideoAccelVRDPRefs;
436
437 /** Accelerate3DEnabled = true && GraphicsControllerType == VBoxVGA. */
438 bool mfIsCr3DEnabled;
439
440#ifdef VBOX_WITH_CROGL
441 bool mfCrOglDataHidden;
442#endif
443
444#ifdef VBOX_WITH_CRHGSMI
445 /* for fast host hgcm calls */
446 HGCMCVSHANDLE mhCrOglSvc;
447 RTCRITSECTRW mCrOglLock;
448#endif
449#ifdef VBOX_WITH_CROGL
450 CR_MAIN_INTERFACE mCrOglCallbacks;
451 volatile uint32_t mfCrOglVideoRecState;
452 CRVBOXHGCMTAKESCREENSHOT mCrOglScreenshotData;
453 VBOXCRCMDCTL_HGCM mCrOglScreenshotCtl;
454#endif
455
456 /* The legacy VBVA data and methods. */
457 VIDEOACCEL mVideoAccelLegacy;
458
459 int i_VideoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
460 void i_VideoAccelFlush(PPDMIDISPLAYPORT pUpPort);
461 bool i_VideoAccelAllowed(void);
462
463 int i_videoAccelRefreshProcess(PPDMIDISPLAYPORT pUpPort);
464 int i_videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory, PPDMIDISPLAYPORT pUpPort);
465 int i_videoAccelFlush(PPDMIDISPLAYPORT pUpPort);
466
467 /* Legacy pre-HGSMI handlers. */
468 void processAdapterData(void *pvVRAM, uint32_t u32VRAMSize);
469 void processDisplayData(void *pvVRAM, unsigned uScreenId);
470
471 /** Serializes access to mVideoAccelLegacy and mfVideoAccelVRDP, etc between VRDP and Display. */
472 RTCRITSECT mVideoAccelLock;
473
474#ifdef VBOX_WITH_RECORDING
475 /* Serializes access to video recording source bitmaps. */
476 RTCRITSECT mVideoRecLock;
477 /** Array which defines which screens are being enabled for recording. */
478 bool maRecordingEnabled[SchemaDefs::MaxGuestMonitors];
479#endif
480
481public:
482
483 static int i_displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppbData, size_t *pcbData,
484 uint32_t *pcx, uint32_t *pcy, bool *pfMemFree);
485#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
486 static BOOL i_displayCheckTakeScreenshotCrOgl(Display *pDisplay, ULONG aScreenId, uint8_t *pbData,
487 uint32_t u32Width, uint32_t u32Height);
488 int i_crCtlSubmit(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd, PFNCRCTLCOMPLETION pfnCompletion, void *pvCompletion);
489 int i_crCtlSubmitSync(struct VBOXCRCMDCTL *pCmd, uint32_t cbCmd);
490 /* copies the given command and submits it asynchronously,
491 * i.e. the pCmd data may be discarded right after the call returns */
492 int i_crCtlSubmitAsyncCmdCopy(struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
493 /* performs synchronous request processing if 3D backend has something to display
494 * this is primarily to work-around 3d<->main thread deadlocks on OSX
495 * in case of async completion, the command is coppied to the allocated buffer,
496 * freeded on command completion
497 * can be used for "notification" commands, when client is not interested in command result,
498 * that must synchronize with 3D backend only when some 3D data is displayed.
499 * The routine does NOT provide any info on whether command is processed asynchronously or not */
500 int i_crCtlSubmitSyncIfHasDataForScreen(uint32_t u32ScreenID, struct VBOXCRCMDCTL* pCmd, uint32_t cbCmd);
501#endif
502
503private:
504 static int i_InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
505 static int i_drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
506
507 void i_updateGuestGraphicsFacility(void);
508
509#if defined(VBOX_WITH_HGCM) && defined(VBOX_WITH_CROGL)
510 int i_crOglWindowsShow(bool fShow);
511#endif
512
513#ifdef VBOX_WITH_HGSMI
514 volatile uint32_t mu32UpdateVBVAFlags;
515#endif
516
517private:
518 DECLARE_CLS_COPY_CTOR_ASSIGN_NOOP(Display); /* Shuts up MSC warning C4625. */
519};
520
521/* The legacy VBVA helpers. */
522int videoAccelConstruct(VIDEOACCEL *pVideoAccel);
523void videoAccelDestroy(VIDEOACCEL *pVideoAccel);
524void i_vbvaSetMemoryFlags(VBVAMEMORY *pVbvaMemory,
525 bool fVideoAccelEnabled,
526 bool fVideoAccelVRDP,
527 uint32_t fu32SupportedOrders,
528 DISPLAYFBINFO *paFBInfos,
529 unsigned cFBInfos);
530int videoAccelEnterVGA(VIDEOACCEL *pVideoAccel);
531void videoAccelLeaveVGA(VIDEOACCEL *pVideoAccel);
532int videoAccelEnterVMMDev(VIDEOACCEL *pVideoAccel);
533void videoAccelLeaveVMMDev(VIDEOACCEL *pVideoAccel);
534
535
536/* helper function, code in DisplayResampleImage.cpp */
537void BitmapScale32(uint8_t *dst, int dstW, int dstH,
538 const uint8_t *src, int iDeltaLine, int srcW, int srcH);
539
540/* helper function, code in DisplayPNGUtul.cpp */
541int DisplayMakePNG(uint8_t *pbData, uint32_t cx, uint32_t cy,
542 uint8_t **ppu8PNG, uint32_t *pcbPNG, uint32_t *pcxPNG, uint32_t *pcyPNG,
543 uint8_t fLimitSize);
544
545class ATL_NO_VTABLE DisplaySourceBitmap:
546 public DisplaySourceBitmapWrap
547{
548public:
549
550 DECLARE_EMPTY_CTOR_DTOR(DisplaySourceBitmap)
551
552 HRESULT FinalConstruct();
553 void FinalRelease();
554
555 /* Public initializer/uninitializer for internal purposes only. */
556 HRESULT init(ComObjPtr<Display> pDisplay, unsigned uScreenId, DISPLAYFBINFO *pFBInfo);
557 void uninit();
558
559 bool i_usesVRAM(void) { return m.pu8Allocated == NULL; }
560
561private:
562 // wrapped IDisplaySourceBitmap properties
563 virtual HRESULT getScreenId(ULONG *aScreenId);
564
565 // wrapped IDisplaySourceBitmap methods
566 virtual HRESULT queryBitmapInfo(BYTE **aAddress,
567 ULONG *aWidth,
568 ULONG *aHeight,
569 ULONG *aBitsPerPixel,
570 ULONG *aBytesPerLine,
571 BitmapFormat_T *aBitmapFormat);
572
573 int initSourceBitmap(unsigned aScreenId, DISPLAYFBINFO *pFBInfo);
574
575 struct Data
576 {
577 ComObjPtr<Display> pDisplay;
578 unsigned uScreenId;
579 DISPLAYFBINFO *pFBInfo;
580
581 uint8_t *pu8Allocated;
582
583 uint8_t *pu8Address;
584 ULONG ulWidth;
585 ULONG ulHeight;
586 ULONG ulBitsPerPixel;
587 ULONG ulBytesPerLine;
588 BitmapFormat_T bitmapFormat;
589 };
590
591 Data m;
592};
593
594class ATL_NO_VTABLE GuestScreenInfo:
595 public GuestScreenInfoWrap
596{
597public:
598
599 DECLARE_EMPTY_CTOR_DTOR(GuestScreenInfo)
600
601 HRESULT FinalConstruct();
602 void FinalRelease();
603
604 /* Public initializer/uninitializer for internal purposes only. */
605 HRESULT init(ULONG aDisplay,
606 GuestMonitorStatus_T aGuestMonitorStatus,
607 BOOL aPrimary,
608 BOOL aChangeOrigin,
609 LONG aOriginX,
610 LONG aOriginY,
611 ULONG aWidth,
612 ULONG aHeight,
613 ULONG aBitsPerPixel);
614 void uninit();
615
616private:
617 // wrapped IGuestScreenInfo properties
618 virtual HRESULT getScreenId(ULONG *aScreenId);
619 virtual HRESULT getGuestMonitorStatus(GuestMonitorStatus_T *aGuestMonitorStatus);
620 virtual HRESULT getPrimary(BOOL *aPrimary);
621 virtual HRESULT getOrigin(BOOL *aOrigin);
622 virtual HRESULT getOriginX(LONG *aOriginX);
623 virtual HRESULT getOriginY(LONG *aOriginY);
624 virtual HRESULT getWidth(ULONG *aWidth);
625 virtual HRESULT getHeight(ULONG *aHeight);
626 virtual HRESULT getBitsPerPixel(ULONG *aBitsPerPixel);
627 virtual HRESULT getExtendedInfo(com::Utf8Str &aExtendedInfo);
628
629 ULONG mScreenId;
630 GuestMonitorStatus_T mGuestMonitorStatus;
631 BOOL mPrimary;
632 BOOL mOrigin;
633 LONG mOriginX;
634 LONG mOriginY;
635 ULONG mWidth;
636 ULONG mHeight;
637 ULONG mBitsPerPixel;
638};
639
640#endif /* !MAIN_INCLUDED_DisplayImpl_h */
641/* 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