VirtualBox

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

Last change on this file since 40685 was 39603, checked in by vboxsync, 13 years ago

crHgsmi: cleanup

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