VirtualBox

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

最後變更 在這個檔案從34772是 34754,由 vboxsync 提交於 14 年 前

Main/VMMDev: optionally report multi-monitor mouse co-ordinates relative to the whole virtual framebuffer and not to the first screen

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 11.5 KB
 
1/* $Id: DisplayImpl.h 34754 2010-12-06 14:40:03Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2008 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.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 "VirtualBoxBase.h"
22#include "SchemaDefs.h"
23
24#include <iprt/semaphore.h>
25#include <VBox/pdmdrv.h>
26#include <VBox/VMMDev.h>
27#include <VBox/VBoxVideo.h>
28
29class Console;
30
31enum {
32 ResizeStatus_Void,
33 ResizeStatus_InProgress,
34 ResizeStatus_UpdateDisplayData
35};
36
37typedef struct _DISPLAYFBINFO
38{
39 uint32_t u32Offset;
40 uint32_t u32MaxFramebufferSize;
41 uint32_t u32InformationSize;
42
43 ComPtr<IFramebuffer> pFramebuffer;
44
45 LONG xOrigin;
46 LONG yOrigin;
47
48 ULONG w;
49 ULONG h;
50
51 uint16_t u16BitsPerPixel;
52 uint8_t *pu8FramebufferVRAM;
53 uint32_t u32LineSize;
54
55 VBOXVIDEOINFOHOSTEVENTS *pHostEvents;
56
57 volatile uint32_t u32ResizeStatus;
58
59 /* The Framebuffer has default format and must be updates immediately. */
60 bool fDefaultFormat;
61
62 struct {
63 /* The rectangle that includes all dirty rectangles. */
64 int32_t xLeft;
65 int32_t xRight;
66 int32_t yTop;
67 int32_t yBottom;
68 } dirtyRect;
69
70 struct {
71 bool fPending;
72 ULONG pixelFormat;
73 void *pvVRAM;
74 uint32_t bpp;
75 uint32_t cbLine;
76 int w;
77 int h;
78 } pendingResize;
79
80#ifdef VBOX_WITH_HGSMI
81 bool fVBVAEnabled;
82 uint32_t cVBVASkipUpdate;
83 struct {
84 int32_t xLeft;
85 int32_t yTop;
86 int32_t xRight;
87 int32_t yBottom;
88 } vbvaSkippedRect;
89 PVBVAHOSTFLAGS pVBVAHostFlags;
90#endif /* VBOX_WITH_HGSMI */
91} DISPLAYFBINFO;
92
93class ATL_NO_VTABLE Display :
94 public VirtualBoxBase,
95 VBOX_SCRIPTABLE_IMPL(IEventListener),
96 VBOX_SCRIPTABLE_IMPL(IDisplay)
97{
98public:
99
100 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(Display, IDisplay)
101
102 DECLARE_NOT_AGGREGATABLE(Display)
103
104 DECLARE_PROTECT_FINAL_CONSTRUCT()
105
106 BEGIN_COM_MAP(Display)
107 COM_INTERFACE_ENTRY(ISupportErrorInfo)
108 COM_INTERFACE_ENTRY(IDisplay)
109 COM_INTERFACE_ENTRY2(IDispatch,IDisplay)
110 COM_INTERFACE_ENTRY(IEventListener)
111 END_COM_MAP()
112
113 DECLARE_EMPTY_CTOR_DTOR (Display)
114
115 HRESULT FinalConstruct();
116 void FinalRelease();
117
118 // public initializer/uninitializer for internal purposes only
119 HRESULT init (Console *aParent);
120 void uninit();
121 int registerSSM(PVM pVM);
122
123 // public methods only for internal purposes
124 int handleDisplayResize (unsigned uScreenId, uint32_t bpp, void *pvVRAM, uint32_t cbLine, int w, int h);
125 void handleDisplayUpdateLegacy (int x, int y, int cx, int cy);
126 void handleDisplayUpdate (unsigned uScreenId, int x, int y, int w, int h);
127#ifdef VBOX_WITH_VIDEOHWACCEL
128 void handleVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand);
129#endif
130#ifdef VBOX_WITH_CRHGSMI
131 void handleCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd);
132 void handleCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl);
133
134 void handleCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
135 void handleCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam);
136#endif
137 IFramebuffer *getFramebuffer()
138 {
139 return maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer;
140 }
141 void getFramebufferDimensions(int32_t *px1, int32_t *py1, int32_t *px2,
142 int32_t *py2);
143#ifdef MMSEAMLESS
144 int handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect);
145 int handleQueryVisibleRegion(uint32_t *pcRect, PRTRECT pRect);
146#endif
147
148 int VideoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory);
149 void VideoAccelFlush (void);
150
151 bool VideoAccelAllowed (void);
152
153 void VideoAccelVRDP (bool fEnable);
154
155 // IEventListener methods
156 STDMETHOD(HandleEvent)(IEvent * aEvent);
157
158 // IDisplay methods
159 STDMETHOD(GetScreenResolution)(ULONG aScreenId, ULONG *aWidth, ULONG *aHeight, ULONG *aBitsPerPixel);
160 STDMETHOD(SetFramebuffer)(ULONG aScreenId, IFramebuffer *aFramebuffer);
161 STDMETHOD(GetFramebuffer)(ULONG aScreenId, IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin);
162 STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG bitsPerPixel, ULONG display);
163 STDMETHOD(TakeScreenShot)(ULONG aScreenId, BYTE *address, ULONG width, ULONG height);
164 STDMETHOD(TakeScreenShotToArray)(ULONG aScreenId, ULONG width, ULONG height, ComSafeArrayOut(BYTE, aScreenData));
165 STDMETHOD(TakeScreenShotPNGToArray)(ULONG aScreenId, ULONG width, ULONG height, ComSafeArrayOut(BYTE, aScreenData));
166 STDMETHOD(DrawToScreen)(ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
167 STDMETHOD(InvalidateAndUpdate)();
168 STDMETHOD(ResizeCompleted)(ULONG aScreenId);
169 STDMETHOD(SetSeamlessMode)(BOOL enabled);
170
171 STDMETHOD(CompleteVHWACommand)(BYTE *pCommand);
172
173 static const PDMDRVREG DrvReg;
174
175private:
176
177 void updateDisplayData(void);
178
179#ifdef VBOX_WITH_CRHGSMI
180 void setupCrHgsmiData(void);
181 void destructCrHgsmiData(void);
182#endif
183
184 static DECLCALLBACK(int) changeFramebuffer(Display *that, IFramebuffer *aFB, unsigned uScreenId);
185
186 static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
187 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
188 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
189 static DECLCALLBACK(int) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
190 static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
191 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
192 static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
193 static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
194 static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
195 static DECLCALLBACK(void) displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize);
196 static DECLCALLBACK(void) displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
197
198#ifdef VBOX_WITH_VIDEOHWACCEL
199 static DECLCALLBACK(void) displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand);
200#endif
201
202#ifdef VBOX_WITH_CRHGSMI
203 static DECLCALLBACK(void) displayCrHgsmiCommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CMD pCmd);
204 static DECLCALLBACK(void) displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl);
205
206 static DECLCALLBACK(void) displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
207 static DECLCALLBACK(void) displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
208#endif
209
210#ifdef VBOX_WITH_HGSMI
211 static DECLCALLBACK(int) displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags);
212 static DECLCALLBACK(void) displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
213 static DECLCALLBACK(void) displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
214 static DECLCALLBACK(void) displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, const PVBVACMDHDR pCmd, size_t cbCmd);
215 static DECLCALLBACK(void) displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y, uint32_t cx, uint32_t cy);
216 static DECLCALLBACK(int) displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, const PVBVAINFOVIEW pView, const PVBVAINFOSCREEN pScreen, void *pvVRAM);
217 static DECLCALLBACK(int) displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvShape);
218#endif
219
220
221 static DECLCALLBACK(void) displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
222 static DECLCALLBACK(int) displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
223 static DECLCALLBACK(void) displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
224 static DECLCALLBACK(int) displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
225
226 Console * const mParent;
227 /** Pointer to the associated display driver. */
228 struct DRVMAINDISPLAY *mpDrv;
229 /** Pointer to the device instance for the VMM Device. */
230 PPDMDEVINS mpVMMDev;
231 /** Set after the first attempt to find the VMM Device. */
232 bool mfVMMDevInited;
233
234 unsigned mcMonitors;
235 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
236
237 bool mFramebufferOpened;
238
239 /* arguments of the last handleDisplayResize() call */
240 void *mLastAddress;
241 uint32_t mLastBytesPerLine;
242 uint32_t mLastBitsPerPixel;
243 int mLastWidth;
244 int mLastHeight;
245
246 VBVAMEMORY *mpVbvaMemory;
247 bool mfVideoAccelEnabled;
248 bool mfVideoAccelVRDP;
249 uint32_t mfu32SupportedOrders;
250
251 int32_t volatile mcVideoAccelVRDPRefs;
252
253 VBVAMEMORY *mpPendingVbvaMemory;
254 bool mfPendingVideoAccelEnable;
255 bool mfMachineRunning;
256
257 uint8_t *mpu8VbvaPartial;
258 uint32_t mcbVbvaPartial;
259
260#ifdef VBOX_WITH_CRHGSMI
261 /* for fast host hgcm calls */
262 HGCMCVSHANDLE mhCrOglSvc;
263#endif
264
265 bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
266 void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
267
268 void handleResizeCompletedEMT (void);
269
270#ifdef VBOX_WITH_OLD_VBVA_LOCK
271 RTCRITSECT mVBVALock;
272 volatile uint32_t mfu32PendingVideoAccelDisable;
273
274 int vbvaLock(void);
275 void vbvaUnlock(void);
276
277public:
278 static int displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height);
279
280private:
281 static void InvalidateAndUpdateEMT(Display *pDisplay);
282 static int drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
283
284 int videoAccelRefreshProcess(void);
285
286 /* Functions run under VBVA lock. */
287 int videoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory);
288 void videoAccelFlush (void);
289#endif /* VBOX_WITH_OLD_VBVA_LOCK */
290
291#ifdef VBOX_WITH_HGSMI
292 volatile uint32_t mu32UpdateVBVAFlags;
293#endif
294};
295
296void gdImageCopyResampled (uint8_t *dst, uint8_t *src,
297 int dstX, int dstY,
298 int srcX, int srcY,
299 int dstW, int dstH, int srcW, int srcH);
300
301
302void BitmapScale32 (uint8_t *dst,
303 int dstW, int dstH,
304 const uint8_t *src,
305 int iDeltaLine,
306 int srcW, int srcH);
307
308int DisplayMakePNG(uint8_t *pu8Data, uint32_t cx, uint32_t cy,
309 uint8_t **ppu8PNG, uint32_t *pcbPNG, uint32_t *pcxPNG, uint32_t *pcyPNG,
310 uint8_t fLimitSize);
311
312#endif // ____H_DISPLAYIMPL
313/* vi: set tabstop=4 shiftwidth=4 expandtab: */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette