VirtualBox

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

Last change on this file since 13837 was 13607, checked in by vboxsync, 16 years ago

Main: keywords space

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1/* $Id: DisplayImpl.h 13607 2008-10-28 10:43:42Z 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
35class Console;
36
37enum {
38 ResizeStatus_Void,
39 ResizeStatus_InProgress,
40 ResizeStatus_UpdateDisplayData
41};
42
43typedef 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} DISPLAYFBINFO;
73
74class ATL_NO_VTABLE Display :
75 public VirtualBoxBaseNEXT,
76 public IConsoleCallback,
77 public VirtualBoxSupportErrorInfoImpl <Display, IDisplay>,
78 public VirtualBoxSupportTranslation <Display>,
79 public IDisplay
80{
81
82public:
83
84 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Display)
85
86 DECLARE_NOT_AGGREGATABLE(Display)
87
88 DECLARE_PROTECT_FINAL_CONSTRUCT()
89
90 BEGIN_COM_MAP(Display)
91 COM_INTERFACE_ENTRY(ISupportErrorInfo)
92 COM_INTERFACE_ENTRY(IDisplay)
93 END_COM_MAP()
94
95 NS_DECL_ISUPPORTS
96
97 DECLARE_EMPTY_CTOR_DTOR (Display)
98
99 HRESULT FinalConstruct();
100 void FinalRelease();
101
102 // public initializer/uninitializer for internal purposes only
103 HRESULT init (Console *aParent);
104 void uninit();
105
106 // public methods only for internal purposes
107 int handleDisplayResize (unsigned uScreenId, uint32_t bpp, void *pvVRAM, uint32_t cbLine, int w, int h);
108 void handleDisplayUpdate (int x, int y, int cx, int cy);
109 IFramebuffer *getFramebuffer()
110 {
111 return maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer;
112 }
113
114 int VideoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory);
115 void VideoAccelFlush (void);
116
117 bool VideoAccelAllowed (void);
118
119#ifdef VBOX_WITH_VRDP
120 void VideoAccelVRDP (bool fEnable);
121#endif /* VBOX_WITH_VRDP */
122
123 // IConsoleCallback methods
124 STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
125 ULONG width, ULONG height, BYTE *shape)
126 {
127 return S_OK;
128 }
129
130 STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL needsHostCursor)
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(OnStateChange)(MachineState_T machineState);
141
142 STDMETHOD(OnAdditionsStateChange)()
143 {
144 return S_OK;
145 }
146
147 STDMETHOD(OnDVDDriveChange)()
148 {
149 return S_OK;
150 }
151
152 STDMETHOD(OnFloppyDriveChange)()
153 {
154 return S_OK;
155 }
156
157 STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter)
158 {
159 return S_OK;
160 }
161
162 STDMETHOD(OnSerialPortChange) (ISerialPort *aSerialPort)
163 {
164 return S_OK;
165 }
166
167 STDMETHOD(OnParallelPortChange) (IParallelPort *aParallelPort)
168 {
169 return S_OK;
170 }
171
172 STDMETHOD(OnVRDPServerChange)()
173 {
174 return S_OK;
175 }
176
177 STDMETHOD(OnUSBControllerChange)()
178 {
179 return S_OK;
180 }
181
182 STDMETHOD(OnUSBDeviceStateChange)(IUSBDevice *device, BOOL attached,
183 IVirtualBoxErrorInfo *message)
184 {
185 return S_OK;
186 }
187
188 STDMETHOD(OnSharedFolderChange) (Scope_T aScope)
189 {
190 return S_OK;
191 }
192
193 STDMETHOD(OnRuntimeError)(BOOL fatal, INPTR BSTR id, INPTR BSTR message)
194 {
195 return S_OK;
196 }
197
198 STDMETHOD(OnCanShowWindow)(BOOL *canShow)
199 {
200 if (canShow)
201 *canShow = TRUE;
202 return S_OK;
203 }
204
205 STDMETHOD(OnShowWindow)(ULONG64 *winId)
206 {
207 if (winId)
208 *winId = 0;
209 return S_OK;
210 }
211
212 // IDisplay properties
213 STDMETHOD(COMGETTER(Width)) (ULONG *width);
214 STDMETHOD(COMGETTER(Height)) (ULONG *height);
215 STDMETHOD(COMGETTER(BitsPerPixel)) (ULONG *bitsPerPixel);
216
217 // IDisplay methods
218 STDMETHOD(SetupInternalFramebuffer)(ULONG depth);
219 STDMETHOD(LockFramebuffer)(BYTE **address);
220 STDMETHOD(UnlockFramebuffer)();
221 STDMETHOD(RegisterExternalFramebuffer)(IFramebuffer *frameBuf);
222 STDMETHOD(SetFramebuffer)(ULONG aScreenId, IFramebuffer *aFramebuffer);
223 STDMETHOD(GetFramebuffer)(ULONG aScreenId, IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin);
224 STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG bitsPerPixel, ULONG display);
225 STDMETHOD(TakeScreenShot)(BYTE *address, ULONG width, ULONG height);
226 STDMETHOD(DrawToScreen)(BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
227 STDMETHOD(InvalidateAndUpdate)();
228 STDMETHOD(ResizeCompleted)(ULONG aScreenId);
229 STDMETHOD(UpdateCompleted)();
230 STDMETHOD(SetSeamlessMode)(BOOL enabled);
231
232 // for VirtualBoxSupportErrorInfoImpl
233 static const wchar_t *getComponentName() { return L"Display"; }
234
235 static const PDMDRVREG DrvReg;
236
237private:
238
239 void updateDisplayData (bool aCheckParams = false);
240
241 static DECLCALLBACK(int) changeFramebuffer (Display *that, IFramebuffer *aFB,
242 bool aInternal, unsigned uScreenId);
243
244 static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
245 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
246 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
247 static DECLCALLBACK(int) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
248 static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
249 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
250 static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
251 static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
252 static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
253 static DECLCALLBACK(void) displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize);
254 static DECLCALLBACK(void) displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
255
256 const ComObjPtr <Console, ComWeakRef> mParent;
257 /** Pointer to the associated display driver. */
258 struct DRVMAINDISPLAY *mpDrv;
259 /** Pointer to the device instance for the VMM Device. */
260 PPDMDEVINS mpVMMDev;
261 /** Set after the first attempt to find the VMM Device. */
262 bool mfVMMDevInited;
263 bool mInternalFramebuffer;
264
265 unsigned mcMonitors;
266 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
267
268 bool mFramebufferOpened;
269 /** bitmask of acceleration operations supported by current framebuffer */
270 ULONG mSupportedAccelOps;
271 RTSEMEVENTMULTI mUpdateSem;
272
273 /* arguments of the last handleDisplayResize() call */
274 void *mLastAddress;
275 uint32_t mLastBytesPerLine;
276 uint32_t mLastBitsPerPixel;
277 int mLastWidth;
278 int mLastHeight;
279
280 VBVAMEMORY *mpVbvaMemory;
281 bool mfVideoAccelEnabled;
282 bool mfVideoAccelVRDP;
283 uint32_t mfu32SupportedOrders;
284
285 int32_t volatile mcVideoAccelVRDPRefs;
286
287 VBVAMEMORY *mpPendingVbvaMemory;
288 bool mfPendingVideoAccelEnable;
289 bool mfMachineRunning;
290
291 uint8_t *mpu8VbvaPartial;
292 uint32_t mcbVbvaPartial;
293
294 bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
295 void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
296
297 void handleResizeCompletedEMT (void);
298};
299
300#endif // ____H_DISPLAYIMPL
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