VirtualBox

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

Last change on this file since 3793 was 3793, checked in by vboxsync, 18 years ago

Inform guest about seamless mode changes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 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 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(BitsPerPixel)) (ULONG *bitsPerPixel);
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(GetFramebuffer)(ULONG aScreenId, IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin);
177 STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG bitsPerPixel, 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 STDMETHOD(SetSeamlessMode)(BOOL enabled);
184
185 // for VirtualBoxSupportErrorInfoImpl
186 static const wchar_t *getComponentName() { return L"Display"; }
187
188 static const PDMDRVREG DrvReg;
189
190private:
191
192 void updateDisplayData (bool aCheckParams = false);
193
194 static DECLCALLBACK(int) changeFramebuffer (Display *that, IFramebuffer *aFB,
195 bool aInternal, unsigned uScreenId);
196
197 static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface);
198 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfgHandle);
199 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
200 static DECLCALLBACK(int) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
201 static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
202 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
203 static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
204 static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
205 static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
206 static DECLCALLBACK(void) displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize);
207 static DECLCALLBACK(void) displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
208
209 ComObjPtr <Console, ComWeakRef> mParent;
210 /** Pointer to the associated display driver. */
211 struct DRVMAINDISPLAY *mpDrv;
212 /** Pointer to the device instance for the VMM Device. */
213 PPDMDEVINS mpVMMDev;
214 /** Set after the first attempt to find the VMM Device. */
215 bool mfVMMDevInited;
216 bool mInternalFramebuffer;
217// ComPtr<IFramebuffer> mFramebuffer;
218
219 unsigned mcMonitors;
220 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
221
222 bool mFramebufferOpened;
223 /** bitmask of acceleration operations supported by current framebuffer */
224 ULONG mSupportedAccelOps;
225 RTSEMEVENTMULTI mUpdateSem;
226
227 /* arguments of the last handleDisplayResize() call */
228 void *mLastAddress;
229 uint32_t mLastBytesPerLine;
230 uint32_t mLastBitsPerPixel;
231 int mLastWidth;
232 int mLastHeight;
233
234 VBVAMEMORY *mpVbvaMemory;
235 bool mfVideoAccelEnabled;
236 bool mfVideoAccelVRDP;
237 uint32_t mfu32SupportedOrders;
238
239 int32_t volatile mcVideoAccelVRDPRefs;
240
241 VBVAMEMORY *mpPendingVbvaMemory;
242 bool mfPendingVideoAccelEnable;
243 bool mfMachineRunning;
244
245 uint8_t *mpu8VbvaPartial;
246 uint32_t mcbVbvaPartial;
247
248 bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
249 void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
250
251 void handleResizeCompletedEMT (void);
252// volatile uint32_t mu32ResizeStatus;
253};
254
255#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