VirtualBox

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

Last change on this file since 3254 was 3153, checked in by vboxsync, 17 years ago

Multimonitor support.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.0 KB
Line 
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
32class Console;
33
34enum {
35 ResizeStatus_Void,
36 ResizeStatus_InProgress,
37 ResizeStatus_UpdateDisplayData
38};
39
40typedef 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
71class ATL_NO_VTABLE Display :
72 public IConsoleCallback,
73 public VirtualBoxSupportErrorInfoImpl <Display, IDisplay>,
74 public VirtualBoxSupportTranslation <Display>,
75 public VirtualBoxBase,
76 public IDisplay
77{
78
79public:
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#ifdef VRDP_MC
114 void VideoAccelVRDP (bool fEnable);
115#else
116 void VideoAccelVRDP (bool fEnable, uint32_t fu32SupportedOrders);
117#endif /* VRDP_MC */
118#endif /* VBOX_VRDP */
119
120 // IConsoleCallback methods
121 STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
122 ULONG width, ULONG height, BYTE *shape)
123 {
124 return S_OK;
125 }
126
127 STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL needsHostCursor)
128 {
129 return S_OK;
130 }
131
132 STDMETHOD(OnStateChange)(MachineState_T machineState);
133
134 STDMETHOD(OnAdditionsStateChange)()
135 {
136 return S_OK;
137 }
138
139 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
140 {
141 return S_OK;
142 }
143
144 STDMETHOD(OnUSBDeviceStateChange)(IUSBDevice *device, BOOL attached,
145 IVirtualBoxErrorInfo *message)
146 {
147 return S_OK;
148 }
149
150 STDMETHOD(OnRuntimeError)(BOOL fatal, INPTR BSTR id, INPTR BSTR message)
151 {
152 return S_OK;
153 }
154
155 STDMETHOD(OnCanShowWindow)(BOOL *canShow)
156 {
157 if (canShow)
158 *canShow = TRUE;
159 return S_OK;
160 }
161
162 STDMETHOD(OnShowWindow)(ULONG64 *winId)
163 {
164 if (winId)
165 *winId = 0;
166 return S_OK;
167 }
168
169 // IDisplay properties
170 STDMETHOD(COMGETTER(Width)) (ULONG *width);
171 STDMETHOD(COMGETTER(Height)) (ULONG *height);
172 STDMETHOD(COMGETTER(ColorDepth)) (ULONG *colorDepth);
173
174 // IDisplay methods
175 STDMETHOD(SetupInternalFramebuffer)(ULONG depth);
176 STDMETHOD(LockFramebuffer)(BYTE **address);
177 STDMETHOD(UnlockFramebuffer)();
178 STDMETHOD(RegisterExternalFramebuffer)(IFramebuffer *frameBuf);
179 STDMETHOD(SetFramebuffer)(ULONG aScreenId, IFramebuffer * aFramebuffer);
180 STDMETHOD(QueryFramebuffer)(ULONG aScreenId, IFramebuffer * * aFramebuffer, LONG * aXOrigin, LONG * aYOrigin);
181 STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG colorDepth, ULONG display);
182 STDMETHOD(TakeScreenShot)(BYTE *address, ULONG width, ULONG height);
183 STDMETHOD(DrawToScreen)(BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
184 STDMETHOD(InvalidateAndUpdate)();
185 STDMETHOD(ResizeCompleted)(ULONG aScreenId);
186 STDMETHOD(UpdateCompleted)();
187
188 // for VirtualBoxSupportErrorInfoImpl
189 static const wchar_t *getComponentName() { return L"Display"; }
190
191 static const PDMDRVREG DrvReg;
192
193private:
194
195 void updateDisplayData (bool aCheckParams = false);
196
197 static DECLCALLBACK(int) changeFramebuffer (Display *that, IFramebuffer *aFB,
198 bool aInternal, unsigned uScreenId);
199
200 static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
201 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
202 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
203 static DECLCALLBACK(int) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
204 static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
205 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
206 static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
207 static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
208 static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
209 static DECLCALLBACK(void) displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize);
210 static DECLCALLBACK(void) displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
211
212 ComObjPtr <Console, ComWeakRef> mParent;
213 /** Pointer to the associated display driver. */
214 struct DRVMAINDISPLAY *mpDrv;
215 /** Pointer to the device instance for the VMM Device. */
216 PPDMDEVINS mpVMMDev;
217 /** Set after the first attempt to find the VMM Device. */
218 bool mfVMMDevInited;
219 bool mInternalFramebuffer;
220// ComPtr<IFramebuffer> mFramebuffer;
221
222 unsigned mcMonitors;
223 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
224
225 bool mFramebufferOpened;
226 /** bitmask of acceleration operations supported by current framebuffer */
227 ULONG mSupportedAccelOps;
228 RTSEMEVENTMULTI mUpdateSem;
229
230 /* arguments of the last handleDisplayResize() call */
231 void *mLastAddress;
232 uint32_t mLastLineSize;
233 uint32_t mLastColorDepth;
234 int mLastWidth;
235 int mLastHeight;
236
237 VBVAMEMORY *mpVbvaMemory;
238 bool mfVideoAccelEnabled;
239 bool mfVideoAccelVRDP;
240 uint32_t mfu32SupportedOrders;
241
242 int32_t volatile mcVideoAccelVRDPRefs;
243
244 VBVAMEMORY *mpPendingVbvaMemory;
245 bool mfPendingVideoAccelEnable;
246 bool mfMachineRunning;
247
248 uint8_t *mpu8VbvaPartial;
249 uint32_t mcbVbvaPartial;
250
251 bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
252 void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
253
254 void handleResizeCompletedEMT (void);
255// volatile uint32_t mu32ResizeStatus;
256};
257
258#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