VirtualBox

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

Last change on this file since 61609 was 61564, checked in by vboxsync, 9 years ago

Main: IDisplay changed queryScreenLayout to be an attribute

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