VirtualBox

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

Last change on this file since 35164 was 35148, checked in by vboxsync, 14 years ago

Main/Display: take into account disabled screens for pointer reporting

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

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