1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
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/pdm.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(OnStateChange)(MachineState_T machineState);
|
---|
129 |
|
---|
130 | STDMETHOD(OnAdditionsStateChange)()
|
---|
131 | {
|
---|
132 | return S_OK;
|
---|
133 | }
|
---|
134 |
|
---|
135 | STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
|
---|
136 | {
|
---|
137 | return S_OK;
|
---|
138 | }
|
---|
139 |
|
---|
140 | STDMETHOD(OnUSBDeviceStateChange)(IUSBDevice *device, BOOL attached,
|
---|
141 | IVirtualBoxErrorInfo *message)
|
---|
142 | {
|
---|
143 | return S_OK;
|
---|
144 | }
|
---|
145 |
|
---|
146 | STDMETHOD(OnRuntimeError)(BOOL fatal, INPTR BSTR id, INPTR BSTR message)
|
---|
147 | {
|
---|
148 | return S_OK;
|
---|
149 | }
|
---|
150 |
|
---|
151 | STDMETHOD(OnCanShowWindow)(BOOL *canShow)
|
---|
152 | {
|
---|
153 | if (canShow)
|
---|
154 | *canShow = TRUE;
|
---|
155 | return S_OK;
|
---|
156 | }
|
---|
157 |
|
---|
158 | STDMETHOD(OnShowWindow)(ULONG64 *winId)
|
---|
159 | {
|
---|
160 | if (winId)
|
---|
161 | *winId = 0;
|
---|
162 | return S_OK;
|
---|
163 | }
|
---|
164 |
|
---|
165 | // IDisplay properties
|
---|
166 | STDMETHOD(COMGETTER(Width)) (ULONG *width);
|
---|
167 | STDMETHOD(COMGETTER(Height)) (ULONG *height);
|
---|
168 | STDMETHOD(COMGETTER(ColorDepth)) (ULONG *colorDepth);
|
---|
169 |
|
---|
170 | // IDisplay methods
|
---|
171 | STDMETHOD(SetupInternalFramebuffer)(ULONG depth);
|
---|
172 | STDMETHOD(LockFramebuffer)(BYTE **address);
|
---|
173 | STDMETHOD(UnlockFramebuffer)();
|
---|
174 | STDMETHOD(RegisterExternalFramebuffer)(IFramebuffer *frameBuf);
|
---|
175 | STDMETHOD(SetFramebuffer)(ULONG aScreenId, IFramebuffer * aFramebuffer);
|
---|
176 | STDMETHOD(QueryFramebuffer)(ULONG aScreenId, IFramebuffer * * aFramebuffer, LONG * aXOrigin, LONG * aYOrigin);
|
---|
177 | STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG colorDepth, ULONG display);
|
---|
178 | STDMETHOD(TakeScreenShot)(BYTE *address, ULONG width, ULONG height);
|
---|
179 | STDMETHOD(DrawToScreen)(BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
|
---|
180 | STDMETHOD(InvalidateAndUpdate)();
|
---|
181 | STDMETHOD(ResizeCompleted)(ULONG aScreenId);
|
---|
182 | STDMETHOD(UpdateCompleted)();
|
---|
183 |
|
---|
184 | // for VirtualBoxSupportErrorInfoImpl
|
---|
185 | static const wchar_t *getComponentName() { return L"Display"; }
|
---|
186 |
|
---|
187 | static const PDMDRVREG DrvReg;
|
---|
188 |
|
---|
189 | private:
|
---|
190 |
|
---|
191 | void updateDisplayData (bool aCheckParams = false);
|
---|
192 |
|
---|
193 | static DECLCALLBACK(int) changeFramebuffer (Display *that, IFramebuffer *aFB,
|
---|
194 | bool aInternal, unsigned uScreenId);
|
---|
195 |
|
---|
196 | static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
|
---|
197 | static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
|
---|
198 | static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
|
---|
199 | static DECLCALLBACK(int) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
|
---|
200 | static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
|
---|
201 | uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
|
---|
202 | static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
|
---|
203 | static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
|
---|
204 | static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
|
---|
205 | static DECLCALLBACK(void) displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize);
|
---|
206 | static DECLCALLBACK(void) displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
|
---|
207 |
|
---|
208 | ComObjPtr <Console, ComWeakRef> mParent;
|
---|
209 | /** Pointer to the associated display driver. */
|
---|
210 | struct DRVMAINDISPLAY *mpDrv;
|
---|
211 | /** Pointer to the device instance for the VMM Device. */
|
---|
212 | PPDMDEVINS mpVMMDev;
|
---|
213 | /** Set after the first attempt to find the VMM Device. */
|
---|
214 | bool mfVMMDevInited;
|
---|
215 | bool mInternalFramebuffer;
|
---|
216 | // ComPtr<IFramebuffer> mFramebuffer;
|
---|
217 |
|
---|
218 | unsigned mcMonitors;
|
---|
219 | DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
|
---|
220 |
|
---|
221 | bool mFramebufferOpened;
|
---|
222 | /** bitmask of acceleration operations supported by current framebuffer */
|
---|
223 | ULONG mSupportedAccelOps;
|
---|
224 | RTSEMEVENTMULTI mUpdateSem;
|
---|
225 |
|
---|
226 | /* arguments of the last handleDisplayResize() call */
|
---|
227 | void *mLastAddress;
|
---|
228 | uint32_t mLastLineSize;
|
---|
229 | uint32_t mLastColorDepth;
|
---|
230 | int mLastWidth;
|
---|
231 | int mLastHeight;
|
---|
232 |
|
---|
233 | VBVAMEMORY *mpVbvaMemory;
|
---|
234 | bool mfVideoAccelEnabled;
|
---|
235 | bool mfVideoAccelVRDP;
|
---|
236 | uint32_t mfu32SupportedOrders;
|
---|
237 |
|
---|
238 | int32_t volatile mcVideoAccelVRDPRefs;
|
---|
239 |
|
---|
240 | VBVAMEMORY *mpPendingVbvaMemory;
|
---|
241 | bool mfPendingVideoAccelEnable;
|
---|
242 | bool mfMachineRunning;
|
---|
243 |
|
---|
244 | uint8_t *mpu8VbvaPartial;
|
---|
245 | uint32_t mcbVbvaPartial;
|
---|
246 |
|
---|
247 | bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
|
---|
248 | void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
|
---|
249 |
|
---|
250 | void handleResizeCompletedEMT (void);
|
---|
251 | // volatile uint32_t mu32ResizeStatus;
|
---|
252 | };
|
---|
253 |
|
---|
254 | #endif // ____H_DISPLAYIMPL
|
---|