VirtualBox

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

Last change on this file since 16954 was 16185, checked in by vboxsync, 16 years ago

handleDisplayResize postpones the resize if framebuffer is being resized (fixed xTracker #3489).

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