1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ____H_DISPLAYIMPL
|
---|
23 | #define ____H_DISPLAYIMPL
|
---|
24 |
|
---|
25 | #include "VirtualBoxBase.h"
|
---|
26 | #include "SchemaDefs.h"
|
---|
27 | #include <iprt/semaphore.h>
|
---|
28 | #include <VBox/pdmdrv.h>
|
---|
29 | #include <VBox/VBoxGuest.h>
|
---|
30 | #include <VBox/VBoxVideo.h>
|
---|
31 |
|
---|
32 | class Console;
|
---|
33 |
|
---|
34 | enum {
|
---|
35 | ResizeStatus_Void,
|
---|
36 | ResizeStatus_InProgress,
|
---|
37 | ResizeStatus_UpdateDisplayData
|
---|
38 | };
|
---|
39 |
|
---|
40 | typedef struct _DISPLAYFBINFO
|
---|
41 | {
|
---|
42 | uint32_t u32Offset;
|
---|
43 | uint32_t u32MaxFramebufferSize;
|
---|
44 | uint32_t u32InformationSize;
|
---|
45 |
|
---|
46 | ComPtr<IFramebuffer> pFramebuffer;
|
---|
47 |
|
---|
48 | LONG xOrigin;
|
---|
49 | LONG yOrigin;
|
---|
50 |
|
---|
51 | ULONG w;
|
---|
52 | ULONG h;
|
---|
53 |
|
---|
54 | VBOXVIDEOINFOHOSTEVENTS *pHostEvents;
|
---|
55 |
|
---|
56 | volatile uint32_t u32ResizeStatus;
|
---|
57 |
|
---|
58 | /* The Framebuffer has default format and must be updates immediately. */
|
---|
59 | bool fDefaultFormat;
|
---|
60 |
|
---|
61 | struct {
|
---|
62 | /* The rectangle that includes all dirty rectangles. */
|
---|
63 | int32_t xLeft;
|
---|
64 | int32_t xRight;
|
---|
65 | int32_t yTop;
|
---|
66 | int32_t yBottom;
|
---|
67 | } dirtyRect;
|
---|
68 |
|
---|
69 | } DISPLAYFBINFO;
|
---|
70 |
|
---|
71 | class ATL_NO_VTABLE Display :
|
---|
72 | public IConsoleCallback,
|
---|
73 | public VirtualBoxSupportErrorInfoImpl <Display, IDisplay>,
|
---|
74 | public VirtualBoxSupportTranslation <Display>,
|
---|
75 | public VirtualBoxBase,
|
---|
76 | public IDisplay
|
---|
77 | {
|
---|
78 |
|
---|
79 | public:
|
---|
80 |
|
---|
81 | DECLARE_NOT_AGGREGATABLE(Display)
|
---|
82 |
|
---|
83 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
84 |
|
---|
85 | BEGIN_COM_MAP(Display)
|
---|
86 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
87 | COM_INTERFACE_ENTRY(IDisplay)
|
---|
88 | END_COM_MAP()
|
---|
89 |
|
---|
90 | NS_DECL_ISUPPORTS
|
---|
91 |
|
---|
92 | HRESULT FinalConstruct();
|
---|
93 | void FinalRelease();
|
---|
94 |
|
---|
95 | // public initializer/uninitializer for internal purposes only
|
---|
96 | HRESULT init (Console *parent);
|
---|
97 | void uninit();
|
---|
98 |
|
---|
99 | // public methods only for internal purposes
|
---|
100 | int handleDisplayResize (unsigned uScreenId, uint32_t bpp, void *pvVRAM, uint32_t cbLine, int w, int h);
|
---|
101 | void handleDisplayUpdate (int x, int y, int cx, int cy);
|
---|
102 | IFramebuffer *getFramebuffer()
|
---|
103 | {
|
---|
104 | return maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer;
|
---|
105 | }
|
---|
106 |
|
---|
107 | int VideoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory);
|
---|
108 | void VideoAccelFlush (void);
|
---|
109 |
|
---|
110 | bool VideoAccelAllowed (void);
|
---|
111 |
|
---|
112 | #ifdef VBOX_VRDP
|
---|
113 | void VideoAccelVRDP (bool fEnable);
|
---|
114 | #endif /* VBOX_VRDP */
|
---|
115 |
|
---|
116 | // IConsoleCallback methods
|
---|
117 | STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
|
---|
118 | ULONG width, ULONG height, BYTE *shape)
|
---|
119 | {
|
---|
120 | return S_OK;
|
---|
121 | }
|
---|
122 |
|
---|
123 | STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL needsHostCursor)
|
---|
124 | {
|
---|
125 | return S_OK;
|
---|
126 | }
|
---|
127 |
|
---|
128 | STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
|
---|
129 | {
|
---|
130 | return S_OK;
|
---|
131 | }
|
---|
132 |
|
---|
133 | STDMETHOD(OnStateChange)(MachineState_T machineState);
|
---|
134 |
|
---|
135 | STDMETHOD(OnAdditionsStateChange)()
|
---|
136 | {
|
---|
137 | return S_OK;
|
---|
138 | }
|
---|
139 |
|
---|
140 | STDMETHOD(OnDVDDriveChange)()
|
---|
141 | {
|
---|
142 | return S_OK;
|
---|
143 | }
|
---|
144 |
|
---|
145 | STDMETHOD(OnFloppyDriveChange)()
|
---|
146 | {
|
---|
147 | return S_OK;
|
---|
148 | }
|
---|
149 |
|
---|
150 | STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter)
|
---|
151 | {
|
---|
152 | return S_OK;
|
---|
153 | }
|
---|
154 |
|
---|
155 | STDMETHOD(OnSerialPortChange) (ISerialPort *aSerialPort)
|
---|
156 | {
|
---|
157 | return S_OK;
|
---|
158 | }
|
---|
159 |
|
---|
160 | STDMETHOD(OnParallelPortChange) (IParallelPort *aParallelPort)
|
---|
161 | {
|
---|
162 | return S_OK;
|
---|
163 | }
|
---|
164 |
|
---|
165 | STDMETHOD(OnVRDPServerChange)()
|
---|
166 | {
|
---|
167 | return S_OK;
|
---|
168 | }
|
---|
169 |
|
---|
170 | STDMETHOD(OnUSBControllerChange)()
|
---|
171 | {
|
---|
172 | return S_OK;
|
---|
173 | }
|
---|
174 |
|
---|
175 | STDMETHOD(OnUSBDeviceStateChange)(IUSBDevice *device, BOOL attached,
|
---|
176 | IVirtualBoxErrorInfo *message)
|
---|
177 | {
|
---|
178 | return S_OK;
|
---|
179 | }
|
---|
180 |
|
---|
181 | STDMETHOD(OnSharedFolderChange) (Scope_T aScope)
|
---|
182 | {
|
---|
183 | return S_OK;
|
---|
184 | }
|
---|
185 |
|
---|
186 | STDMETHOD(OnRuntimeError)(BOOL fatal, INPTR BSTR id, INPTR BSTR message)
|
---|
187 | {
|
---|
188 | return S_OK;
|
---|
189 | }
|
---|
190 |
|
---|
191 | STDMETHOD(OnCanShowWindow)(BOOL *canShow)
|
---|
192 | {
|
---|
193 | if (canShow)
|
---|
194 | *canShow = TRUE;
|
---|
195 | return S_OK;
|
---|
196 | }
|
---|
197 |
|
---|
198 | STDMETHOD(OnShowWindow)(ULONG64 *winId)
|
---|
199 | {
|
---|
200 | if (winId)
|
---|
201 | *winId = 0;
|
---|
202 | return S_OK;
|
---|
203 | }
|
---|
204 |
|
---|
205 | // IDisplay properties
|
---|
206 | STDMETHOD(COMGETTER(Width)) (ULONG *width);
|
---|
207 | STDMETHOD(COMGETTER(Height)) (ULONG *height);
|
---|
208 | STDMETHOD(COMGETTER(BitsPerPixel)) (ULONG *bitsPerPixel);
|
---|
209 |
|
---|
210 | // IDisplay methods
|
---|
211 | STDMETHOD(SetupInternalFramebuffer)(ULONG depth);
|
---|
212 | STDMETHOD(LockFramebuffer)(BYTE **address);
|
---|
213 | STDMETHOD(UnlockFramebuffer)();
|
---|
214 | STDMETHOD(RegisterExternalFramebuffer)(IFramebuffer *frameBuf);
|
---|
215 | STDMETHOD(SetFramebuffer)(ULONG aScreenId, IFramebuffer *aFramebuffer);
|
---|
216 | STDMETHOD(GetFramebuffer)(ULONG aScreenId, IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin);
|
---|
217 | STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG bitsPerPixel, ULONG display);
|
---|
218 | STDMETHOD(TakeScreenShot)(BYTE *address, ULONG width, ULONG height);
|
---|
219 | STDMETHOD(DrawToScreen)(BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
|
---|
220 | STDMETHOD(InvalidateAndUpdate)();
|
---|
221 | STDMETHOD(ResizeCompleted)(ULONG aScreenId);
|
---|
222 | STDMETHOD(UpdateCompleted)();
|
---|
223 | STDMETHOD(SetSeamlessMode)(BOOL enabled);
|
---|
224 |
|
---|
225 | // for VirtualBoxSupportErrorInfoImpl
|
---|
226 | static const wchar_t *getComponentName() { return L"Display"; }
|
---|
227 |
|
---|
228 | static const PDMDRVREG DrvReg;
|
---|
229 |
|
---|
230 | private:
|
---|
231 |
|
---|
232 | void updateDisplayData (bool aCheckParams = false);
|
---|
233 |
|
---|
234 | static DECLCALLBACK(int) changeFramebuffer (Display *that, IFramebuffer *aFB,
|
---|
235 | bool aInternal, unsigned uScreenId);
|
---|
236 |
|
---|
237 | static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
|
---|
238 | static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
|
---|
239 | static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
|
---|
240 | static DECLCALLBACK(int) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
|
---|
241 | static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
242 | uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
|
---|
243 | static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
|
---|
244 | static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
|
---|
245 | static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
|
---|
246 | static DECLCALLBACK(void) displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize);
|
---|
247 | static DECLCALLBACK(void) displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
|
---|
248 |
|
---|
249 | ComObjPtr <Console, ComWeakRef> mParent;
|
---|
250 | /** Pointer to the associated display driver. */
|
---|
251 | struct DRVMAINDISPLAY *mpDrv;
|
---|
252 | /** Pointer to the device instance for the VMM Device. */
|
---|
253 | PPDMDEVINS mpVMMDev;
|
---|
254 | /** Set after the first attempt to find the VMM Device. */
|
---|
255 | bool mfVMMDevInited;
|
---|
256 | bool mInternalFramebuffer;
|
---|
257 |
|
---|
258 | unsigned mcMonitors;
|
---|
259 | DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
|
---|
260 |
|
---|
261 | bool mFramebufferOpened;
|
---|
262 | /** bitmask of acceleration operations supported by current framebuffer */
|
---|
263 | ULONG mSupportedAccelOps;
|
---|
264 | RTSEMEVENTMULTI mUpdateSem;
|
---|
265 |
|
---|
266 | /* arguments of the last handleDisplayResize() call */
|
---|
267 | void *mLastAddress;
|
---|
268 | uint32_t mLastBytesPerLine;
|
---|
269 | uint32_t mLastBitsPerPixel;
|
---|
270 | int mLastWidth;
|
---|
271 | int mLastHeight;
|
---|
272 |
|
---|
273 | VBVAMEMORY *mpVbvaMemory;
|
---|
274 | bool mfVideoAccelEnabled;
|
---|
275 | bool mfVideoAccelVRDP;
|
---|
276 | uint32_t mfu32SupportedOrders;
|
---|
277 |
|
---|
278 | int32_t volatile mcVideoAccelVRDPRefs;
|
---|
279 |
|
---|
280 | VBVAMEMORY *mpPendingVbvaMemory;
|
---|
281 | bool mfPendingVideoAccelEnable;
|
---|
282 | bool mfMachineRunning;
|
---|
283 |
|
---|
284 | uint8_t *mpu8VbvaPartial;
|
---|
285 | uint32_t mcbVbvaPartial;
|
---|
286 |
|
---|
287 | bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
|
---|
288 | void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
|
---|
289 |
|
---|
290 | void handleResizeCompletedEMT (void);
|
---|
291 | };
|
---|
292 |
|
---|
293 | #endif // ____H_DISPLAYIMPL
|
---|