1 | /* $Id: DisplayImpl.h 20814 2009-06-23 10:40:53Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2008 Sun Microsystems, Inc.
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | *
|
---|
19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
20 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
21 | * additional information or have any questions.
|
---|
22 | */
|
---|
23 |
|
---|
24 | #ifndef ____H_DISPLAYIMPL
|
---|
25 | #define ____H_DISPLAYIMPL
|
---|
26 |
|
---|
27 | #include "VirtualBoxBase.h"
|
---|
28 | #include "SchemaDefs.h"
|
---|
29 |
|
---|
30 | #include <iprt/semaphore.h>
|
---|
31 | #include <VBox/pdmdrv.h>
|
---|
32 | #include <VBox/VBoxGuest.h>
|
---|
33 | #include <VBox/VBoxVideo.h>
|
---|
34 |
|
---|
35 | class Console;
|
---|
36 |
|
---|
37 | enum {
|
---|
38 | ResizeStatus_Void,
|
---|
39 | ResizeStatus_InProgress,
|
---|
40 | ResizeStatus_UpdateDisplayData
|
---|
41 | };
|
---|
42 |
|
---|
43 | typedef struct _DISPLAYFBINFO
|
---|
44 | {
|
---|
45 | uint32_t u32Offset;
|
---|
46 | uint32_t u32MaxFramebufferSize;
|
---|
47 | uint32_t u32InformationSize;
|
---|
48 |
|
---|
49 | ComPtr<IFramebuffer> pFramebuffer;
|
---|
50 |
|
---|
51 | LONG xOrigin;
|
---|
52 | LONG yOrigin;
|
---|
53 |
|
---|
54 | ULONG w;
|
---|
55 | ULONG h;
|
---|
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 | } pendingResize;
|
---|
81 |
|
---|
82 | } DISPLAYFBINFO;
|
---|
83 |
|
---|
84 | class ATL_NO_VTABLE Display :
|
---|
85 | public VirtualBoxBaseNEXT,
|
---|
86 | VBOX_SCRIPTABLE_IMPL(IConsoleCallback),
|
---|
87 | public VirtualBoxSupportErrorInfoImpl <Display, IDisplay>,
|
---|
88 | public VirtualBoxSupportTranslation <Display>,
|
---|
89 | VBOX_SCRIPTABLE_IMPL(IDisplay)
|
---|
90 | {
|
---|
91 |
|
---|
92 | public:
|
---|
93 |
|
---|
94 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Display)
|
---|
95 |
|
---|
96 | DECLARE_NOT_AGGREGATABLE(Display)
|
---|
97 |
|
---|
98 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
99 |
|
---|
100 | BEGIN_COM_MAP(Display)
|
---|
101 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
102 | COM_INTERFACE_ENTRY(IDisplay)
|
---|
103 | COM_INTERFACE_ENTRY2(IDispatch,IDisplay)
|
---|
104 | END_COM_MAP()
|
---|
105 |
|
---|
106 | NS_DECL_ISUPPORTS
|
---|
107 |
|
---|
108 | DECLARE_EMPTY_CTOR_DTOR (Display)
|
---|
109 |
|
---|
110 | HRESULT FinalConstruct();
|
---|
111 | void FinalRelease();
|
---|
112 |
|
---|
113 | // public initializer/uninitializer for internal purposes only
|
---|
114 | HRESULT init (Console *aParent);
|
---|
115 | void uninit();
|
---|
116 | int registerSSM(PVM pVM);
|
---|
117 |
|
---|
118 | // public methods only for internal purposes
|
---|
119 | int handleDisplayResize (unsigned uScreenId, uint32_t bpp, void *pvVRAM, uint32_t cbLine, int w, int h);
|
---|
120 | void handleDisplayUpdate (int x, int y, int cx, int cy);
|
---|
121 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
122 | void handleVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand);
|
---|
123 | #endif
|
---|
124 | IFramebuffer *getFramebuffer()
|
---|
125 | {
|
---|
126 | return maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer;
|
---|
127 | }
|
---|
128 |
|
---|
129 | int VideoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory);
|
---|
130 | void VideoAccelFlush (void);
|
---|
131 |
|
---|
132 | bool VideoAccelAllowed (void);
|
---|
133 |
|
---|
134 | #ifdef VBOX_WITH_VRDP
|
---|
135 | void VideoAccelVRDP (bool fEnable);
|
---|
136 | #endif /* VBOX_WITH_VRDP */
|
---|
137 |
|
---|
138 | // IConsoleCallback methods
|
---|
139 | STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
|
---|
140 | ULONG width, ULONG height, BYTE *shape)
|
---|
141 | {
|
---|
142 | return S_OK;
|
---|
143 | }
|
---|
144 |
|
---|
145 | STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL needsHostCursor)
|
---|
146 | {
|
---|
147 | return S_OK;
|
---|
148 | }
|
---|
149 |
|
---|
150 | STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
|
---|
151 | {
|
---|
152 | return S_OK;
|
---|
153 | }
|
---|
154 |
|
---|
155 | STDMETHOD(OnStateChange)(MachineState_T machineState);
|
---|
156 |
|
---|
157 | STDMETHOD(OnAdditionsStateChange)()
|
---|
158 | {
|
---|
159 | return S_OK;
|
---|
160 | }
|
---|
161 |
|
---|
162 | STDMETHOD(OnDVDDriveChange)()
|
---|
163 | {
|
---|
164 | return S_OK;
|
---|
165 | }
|
---|
166 |
|
---|
167 | STDMETHOD(OnFloppyDriveChange)()
|
---|
168 | {
|
---|
169 | return S_OK;
|
---|
170 | }
|
---|
171 |
|
---|
172 | STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter)
|
---|
173 | {
|
---|
174 | return S_OK;
|
---|
175 | }
|
---|
176 |
|
---|
177 | STDMETHOD(OnSerialPortChange) (ISerialPort *aSerialPort)
|
---|
178 | {
|
---|
179 | return S_OK;
|
---|
180 | }
|
---|
181 |
|
---|
182 | STDMETHOD(OnParallelPortChange) (IParallelPort *aParallelPort)
|
---|
183 | {
|
---|
184 | return S_OK;
|
---|
185 | }
|
---|
186 |
|
---|
187 | STDMETHOD(OnStorageControllerChange) ()
|
---|
188 | {
|
---|
189 | return S_OK;
|
---|
190 | }
|
---|
191 |
|
---|
192 | STDMETHOD(OnVRDPServerChange)()
|
---|
193 | {
|
---|
194 | return S_OK;
|
---|
195 | }
|
---|
196 |
|
---|
197 | STDMETHOD(OnUSBControllerChange)()
|
---|
198 | {
|
---|
199 | return S_OK;
|
---|
200 | }
|
---|
201 |
|
---|
202 | STDMETHOD(OnUSBDeviceStateChange)(IUSBDevice *device, BOOL attached,
|
---|
203 | IVirtualBoxErrorInfo *message)
|
---|
204 | {
|
---|
205 | return S_OK;
|
---|
206 | }
|
---|
207 |
|
---|
208 | STDMETHOD(OnSharedFolderChange) (Scope_T aScope)
|
---|
209 | {
|
---|
210 | return S_OK;
|
---|
211 | }
|
---|
212 |
|
---|
213 | STDMETHOD(OnRuntimeError)(BOOL fatal, IN_BSTR id, IN_BSTR message)
|
---|
214 | {
|
---|
215 | return S_OK;
|
---|
216 | }
|
---|
217 |
|
---|
218 | STDMETHOD(OnCanShowWindow)(BOOL *canShow)
|
---|
219 | {
|
---|
220 | if (canShow)
|
---|
221 | *canShow = TRUE;
|
---|
222 | return S_OK;
|
---|
223 | }
|
---|
224 |
|
---|
225 | STDMETHOD(OnShowWindow)(ULONG64 *winId)
|
---|
226 | {
|
---|
227 | if (winId)
|
---|
228 | *winId = 0;
|
---|
229 | return S_OK;
|
---|
230 | }
|
---|
231 |
|
---|
232 | // IDisplay properties
|
---|
233 | STDMETHOD(COMGETTER(Width)) (ULONG *width);
|
---|
234 | STDMETHOD(COMGETTER(Height)) (ULONG *height);
|
---|
235 | STDMETHOD(COMGETTER(BitsPerPixel)) (ULONG *bitsPerPixel);
|
---|
236 |
|
---|
237 | // IDisplay methods
|
---|
238 | STDMETHOD(SetFramebuffer)(ULONG aScreenId, IFramebuffer *aFramebuffer);
|
---|
239 | STDMETHOD(GetFramebuffer)(ULONG aScreenId, IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin);
|
---|
240 | STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG bitsPerPixel, ULONG display);
|
---|
241 | STDMETHOD(TakeScreenShot)(BYTE *address, ULONG width, ULONG height);
|
---|
242 | STDMETHOD(TakeScreenShotSlow)(ULONG width, ULONG height, ComSafeArrayOut(BYTE, aScreenData));
|
---|
243 | STDMETHOD(DrawToScreen)(BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
|
---|
244 | STDMETHOD(InvalidateAndUpdate)();
|
---|
245 | STDMETHOD(ResizeCompleted)(ULONG aScreenId);
|
---|
246 | STDMETHOD(UpdateCompleted)();
|
---|
247 | STDMETHOD(SetSeamlessMode)(BOOL enabled);
|
---|
248 |
|
---|
249 | STDMETHOD(CompleteVHWACommand)(BYTE *pCommand);
|
---|
250 |
|
---|
251 | // for VirtualBoxSupportErrorInfoImpl
|
---|
252 | static const wchar_t *getComponentName() { return L"Display"; }
|
---|
253 |
|
---|
254 | static const PDMDRVREG DrvReg;
|
---|
255 |
|
---|
256 | private:
|
---|
257 |
|
---|
258 | void updateDisplayData (bool aCheckParams = false);
|
---|
259 |
|
---|
260 | static DECLCALLBACK(int) changeFramebuffer (Display *that, IFramebuffer *aFB,
|
---|
261 | unsigned uScreenId);
|
---|
262 |
|
---|
263 | static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
|
---|
264 | static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
|
---|
265 | static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
|
---|
266 | static DECLCALLBACK(int) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
|
---|
267 | static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
268 | uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
|
---|
269 | static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
|
---|
270 | static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
|
---|
271 | static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
|
---|
272 | static DECLCALLBACK(void) displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize);
|
---|
273 | static DECLCALLBACK(void) displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
|
---|
274 |
|
---|
275 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
276 | static DECLCALLBACK(void) displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand);
|
---|
277 | #endif
|
---|
278 |
|
---|
279 | static DECLCALLBACK(void) displaySSMSave (PSSMHANDLE pSSM, void *pvUser);
|
---|
280 | static DECLCALLBACK(int) displaySSMLoad (PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version);
|
---|
281 |
|
---|
282 | const ComObjPtr <Console, ComWeakRef> mParent;
|
---|
283 | /** Pointer to the associated display driver. */
|
---|
284 | struct DRVMAINDISPLAY *mpDrv;
|
---|
285 | /** Pointer to the device instance for the VMM Device. */
|
---|
286 | PPDMDEVINS mpVMMDev;
|
---|
287 | /** Set after the first attempt to find the VMM Device. */
|
---|
288 | bool mfVMMDevInited;
|
---|
289 |
|
---|
290 | unsigned mcMonitors;
|
---|
291 | DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
|
---|
292 |
|
---|
293 | bool mFramebufferOpened;
|
---|
294 |
|
---|
295 | /* arguments of the last handleDisplayResize() call */
|
---|
296 | void *mLastAddress;
|
---|
297 | uint32_t mLastBytesPerLine;
|
---|
298 | uint32_t mLastBitsPerPixel;
|
---|
299 | int mLastWidth;
|
---|
300 | int mLastHeight;
|
---|
301 |
|
---|
302 | VBVAMEMORY *mpVbvaMemory;
|
---|
303 | bool mfVideoAccelEnabled;
|
---|
304 | bool mfVideoAccelVRDP;
|
---|
305 | uint32_t mfu32SupportedOrders;
|
---|
306 |
|
---|
307 | int32_t volatile mcVideoAccelVRDPRefs;
|
---|
308 |
|
---|
309 | VBVAMEMORY *mpPendingVbvaMemory;
|
---|
310 | bool mfPendingVideoAccelEnable;
|
---|
311 | bool mfMachineRunning;
|
---|
312 |
|
---|
313 | uint8_t *mpu8VbvaPartial;
|
---|
314 | uint32_t mcbVbvaPartial;
|
---|
315 |
|
---|
316 | bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
|
---|
317 | void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
|
---|
318 |
|
---|
319 | void handleResizeCompletedEMT (void);
|
---|
320 | };
|
---|
321 |
|
---|
322 | #endif // ____H_DISPLAYIMPL
|
---|
323 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|