VirtualBox

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

最後變更 在這個檔案從28787是 28602,由 vboxsync 提交於 15 年 前

Main/Display: resize a new framebuffer (xTracker 4655)

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 12.0 KB
 
1/* $Id: DisplayImpl.h 28602 2010-04-22 15:45:36Z vboxsync $ */
2/** @file
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_DISPLAYIMPL
23#define ____H_DISPLAYIMPL
24
25#include "VirtualBoxBase.h"
26#include "SchemaDefs.h"
27
28#include <iprt/semaphore.h>
29#include <VBox/pdmdrv.h>
30#include <VBox/VMMDev.h>
31#include <VBox/VBoxVideo.h>
32
33class Console;
34
35enum {
36 ResizeStatus_Void,
37 ResizeStatus_InProgress,
38 ResizeStatus_UpdateDisplayData
39};
40
41typedef struct _DISPLAYFBINFO
42{
43 uint32_t u32Offset;
44 uint32_t u32MaxFramebufferSize;
45 uint32_t u32InformationSize;
46
47 ComPtr<IFramebuffer> pFramebuffer;
48
49 LONG xOrigin;
50 LONG yOrigin;
51
52 ULONG w;
53 ULONG h;
54
55 uint16_t u16BitsPerPixel;
56 uint8_t *pu8FramebufferVRAM;
57 uint32_t u32LineSize;
58
59 VBOXVIDEOINFOHOSTEVENTS *pHostEvents;
60
61 volatile uint32_t u32ResizeStatus;
62
63 /* The Framebuffer has default format and must be updates immediately. */
64 bool fDefaultFormat;
65
66 struct {
67 /* The rectangle that includes all dirty rectangles. */
68 int32_t xLeft;
69 int32_t xRight;
70 int32_t yTop;
71 int32_t yBottom;
72 } dirtyRect;
73
74 struct {
75 bool fPending;
76 ULONG pixelFormat;
77 void *pvVRAM;
78 uint32_t bpp;
79 uint32_t cbLine;
80 int w;
81 int h;
82 } pendingResize;
83
84#ifdef VBOX_WITH_HGSMI
85 bool fVBVAEnabled;
86 uint32_t cVBVASkipUpdate;
87 struct {
88 int32_t xLeft;
89 int32_t yTop;
90 int32_t xRight;
91 int32_t yBottom;
92 } vbvaSkippedRect;
93 PVBVAHOSTFLAGS pVBVAHostFlags;
94#endif /* VBOX_WITH_HGSMI */
95} DISPLAYFBINFO;
96
97class ATL_NO_VTABLE Display :
98 public VirtualBoxBase,
99 VBOX_SCRIPTABLE_IMPL(IConsoleCallback),
100 public VirtualBoxSupportErrorInfoImpl<Display, IDisplay>,
101 public VirtualBoxSupportTranslation<Display>,
102 VBOX_SCRIPTABLE_IMPL(IDisplay)
103{
104
105public:
106
107 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Display)
108
109 DECLARE_NOT_AGGREGATABLE(Display)
110
111 DECLARE_PROTECT_FINAL_CONSTRUCT()
112
113 BEGIN_COM_MAP(Display)
114 COM_INTERFACE_ENTRY(ISupportErrorInfo)
115 COM_INTERFACE_ENTRY(IDisplay)
116 COM_INTERFACE_ENTRY2(IDispatch,IDisplay)
117 END_COM_MAP()
118
119 DECLARE_EMPTY_CTOR_DTOR (Display)
120
121 HRESULT FinalConstruct();
122 void FinalRelease();
123
124 // public initializer/uninitializer for internal purposes only
125 HRESULT init (Console *aParent);
126 void uninit();
127 int registerSSM(PVM pVM);
128
129 // public methods only for internal purposes
130 int handleDisplayResize (unsigned uScreenId, uint32_t bpp, void *pvVRAM, uint32_t cbLine, int w, int h);
131 void handleDisplayUpdate (int x, int y, int cx, int cy);
132#ifdef VBOX_WITH_VIDEOHWACCEL
133 void handleVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand);
134#endif
135 IFramebuffer *getFramebuffer()
136 {
137 return maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer;
138 }
139#ifdef MMSEAMLESS
140 int handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect);
141 int handleQueryVisibleRegion(uint32_t *pcRect, PRTRECT pRect);
142#endif
143
144 int VideoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory);
145 void VideoAccelFlush (void);
146
147 bool VideoAccelAllowed (void);
148
149#ifdef VBOX_WITH_VRDP
150 void VideoAccelVRDP (bool fEnable);
151#endif /* VBOX_WITH_VRDP */
152
153 // IConsoleCallback methods
154 STDMETHOD(OnMousePointerShapeChange)(BOOL visible, BOOL alpha, ULONG xHot, ULONG yHot,
155 ULONG width, ULONG height, BYTE *shape)
156 {
157 return S_OK;
158 }
159
160 STDMETHOD(OnMouseCapabilityChange)(BOOL supportsAbsolute, BOOL supportsRelative, BOOL needsHostCursor)
161 {
162 return S_OK;
163 }
164
165 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
166 {
167 return S_OK;
168 }
169
170 STDMETHOD(OnStateChange)(MachineState_T machineState);
171
172 STDMETHOD(OnAdditionsStateChange)()
173 {
174 return S_OK;
175 }
176
177 STDMETHOD(OnNetworkAdapterChange) (INetworkAdapter *aNetworkAdapter)
178 {
179 return S_OK;
180 }
181
182 STDMETHOD(OnSerialPortChange) (ISerialPort *aSerialPort)
183 {
184 return S_OK;
185 }
186
187 STDMETHOD(OnParallelPortChange) (IParallelPort *aParallelPort)
188 {
189 return S_OK;
190 }
191
192 STDMETHOD(OnStorageControllerChange) ()
193 {
194 return S_OK;
195 }
196
197 STDMETHOD(OnMediumChange)(IMediumAttachment *aMediumAttachment)
198 {
199 return S_OK;
200 }
201
202 STDMETHOD(OnCPUChange)(ULONG aCPU, BOOL aRemove)
203 {
204 return S_OK;
205 }
206
207 STDMETHOD(OnVRDPServerChange)()
208 {
209 return S_OK;
210 }
211
212 STDMETHOD(OnRemoteDisplayInfoChange)()
213 {
214 return S_OK;
215 }
216
217 STDMETHOD(OnUSBControllerChange)()
218 {
219 return S_OK;
220 }
221
222 STDMETHOD(OnUSBDeviceStateChange)(IUSBDevice *device, BOOL attached,
223 IVirtualBoxErrorInfo *message)
224 {
225 return S_OK;
226 }
227
228 STDMETHOD(OnSharedFolderChange) (Scope_T aScope)
229 {
230 return S_OK;
231 }
232
233 STDMETHOD(OnRuntimeError)(BOOL fatal, IN_BSTR id, IN_BSTR message)
234 {
235 return S_OK;
236 }
237
238 STDMETHOD(OnCanShowWindow)(BOOL *canShow)
239 {
240 if (canShow)
241 *canShow = TRUE;
242 return S_OK;
243 }
244
245 STDMETHOD(OnShowWindow)(ULONG64 *winId)
246 {
247 if (winId)
248 *winId = 0;
249 return S_OK;
250 }
251
252 // IDisplay methods
253 STDMETHOD(GetScreenResolution)(ULONG aScreenId, ULONG *aWidth, ULONG *aHeight, ULONG *aBitsPerPixel);
254 STDMETHOD(SetFramebuffer)(ULONG aScreenId, IFramebuffer *aFramebuffer);
255 STDMETHOD(GetFramebuffer)(ULONG aScreenId, IFramebuffer **aFramebuffer, LONG *aXOrigin, LONG *aYOrigin);
256 STDMETHOD(SetVideoModeHint)(ULONG width, ULONG height, ULONG bitsPerPixel, ULONG display);
257 STDMETHOD(TakeScreenShot)(ULONG aScreenId, BYTE *address, ULONG width, ULONG height);
258 STDMETHOD(TakeScreenShotToArray)(ULONG aScreenId, ULONG width, ULONG height, ComSafeArrayOut(BYTE, aScreenData));
259 STDMETHOD(DrawToScreen)(ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
260 STDMETHOD(InvalidateAndUpdate)();
261 STDMETHOD(ResizeCompleted)(ULONG aScreenId);
262 STDMETHOD(SetSeamlessMode)(BOOL enabled);
263
264 STDMETHOD(CompleteVHWACommand)(BYTE *pCommand);
265
266 // for VirtualBoxSupportErrorInfoImpl
267 static const wchar_t *getComponentName() { return L"Display"; }
268
269 static const PDMDRVREG DrvReg;
270
271private:
272
273 void updateDisplayData(void);
274
275 static DECLCALLBACK(int) changeFramebuffer(Display *that, IFramebuffer *aFB, unsigned uScreenId);
276
277 static DECLCALLBACK(void*) drvQueryInterface(PPDMIBASE pInterface, const char *pszIID);
278 static DECLCALLBACK(int) drvConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags);
279 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns);
280 static DECLCALLBACK(int) displayResizeCallback(PPDMIDISPLAYCONNECTOR pInterface, uint32_t bpp, void *pvVRAM, uint32_t cbLine, uint32_t cx, uint32_t cy);
281 static DECLCALLBACK(void) displayUpdateCallback(PPDMIDISPLAYCONNECTOR pInterface,
282 uint32_t x, uint32_t y, uint32_t cx, uint32_t cy);
283 static DECLCALLBACK(void) displayRefreshCallback(PPDMIDISPLAYCONNECTOR pInterface);
284 static DECLCALLBACK(void) displayResetCallback(PPDMIDISPLAYCONNECTOR pInterface);
285 static DECLCALLBACK(void) displayLFBModeChangeCallback(PPDMIDISPLAYCONNECTOR pInterface, bool fEnabled);
286 static DECLCALLBACK(void) displayProcessAdapterDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, uint32_t u32VRAMSize);
287 static DECLCALLBACK(void) displayProcessDisplayDataCallback(PPDMIDISPLAYCONNECTOR pInterface, void *pvVRAM, unsigned uScreenId);
288
289#ifdef VBOX_WITH_VIDEOHWACCEL
290 static DECLCALLBACK(void) displayVHWACommandProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVHWACMD pCommand);
291#endif
292
293#ifdef VBOX_WITH_HGSMI
294 static DECLCALLBACK(int) displayVBVAEnable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, PVBVAHOSTFLAGS pHostFlags);
295 static DECLCALLBACK(void) displayVBVADisable(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
296 static DECLCALLBACK(void) displayVBVAUpdateBegin(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId);
297 static DECLCALLBACK(void) displayVBVAUpdateProcess(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, const PVBVACMDHDR pCmd, size_t cbCmd);
298 static DECLCALLBACK(void) displayVBVAUpdateEnd(PPDMIDISPLAYCONNECTOR pInterface, unsigned uScreenId, int32_t x, int32_t y, uint32_t cx, uint32_t cy);
299 static DECLCALLBACK(int) displayVBVAResize(PPDMIDISPLAYCONNECTOR pInterface, const PVBVAINFOVIEW pView, const PVBVAINFOSCREEN pScreen, void *pvVRAM);
300 static DECLCALLBACK(int) displayVBVAMousePointerShape(PPDMIDISPLAYCONNECTOR pInterface, bool fVisible, bool fAlpha, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy, const void *pvShape);
301#endif
302
303
304 static DECLCALLBACK(void) displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
305 static DECLCALLBACK(int) displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
306 static DECLCALLBACK(void) displaySSMSave(PSSMHANDLE pSSM, void *pvUser);
307 static DECLCALLBACK(int) displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
308
309 Console * const mParent;
310 /** Pointer to the associated display driver. */
311 struct DRVMAINDISPLAY *mpDrv;
312 /** Pointer to the device instance for the VMM Device. */
313 PPDMDEVINS mpVMMDev;
314 /** Set after the first attempt to find the VMM Device. */
315 bool mfVMMDevInited;
316
317 unsigned mcMonitors;
318 DISPLAYFBINFO maFramebuffers[SchemaDefs::MaxGuestMonitors];
319
320 bool mFramebufferOpened;
321
322 /* arguments of the last handleDisplayResize() call */
323 void *mLastAddress;
324 uint32_t mLastBytesPerLine;
325 uint32_t mLastBitsPerPixel;
326 int mLastWidth;
327 int mLastHeight;
328
329 VBVAMEMORY *mpVbvaMemory;
330 bool mfVideoAccelEnabled;
331 bool mfVideoAccelVRDP;
332 uint32_t mfu32SupportedOrders;
333
334 int32_t volatile mcVideoAccelVRDPRefs;
335
336 VBVAMEMORY *mpPendingVbvaMemory;
337 bool mfPendingVideoAccelEnable;
338 bool mfMachineRunning;
339
340 uint8_t *mpu8VbvaPartial;
341 uint32_t mcbVbvaPartial;
342
343 bool vbvaFetchCmd (VBVACMDHDR **ppHdr, uint32_t *pcbCmd);
344 void vbvaReleaseCmd (VBVACMDHDR *pHdr, int32_t cbCmd);
345
346 void handleResizeCompletedEMT (void);
347
348#ifdef VBOX_WITH_OLD_VBVA_LOCK
349 RTCRITSECT mVBVALock;
350 volatile uint32_t mfu32PendingVideoAccelDisable;
351
352 int vbvaLock(void);
353 void vbvaUnlock(void);
354
355public:
356 static int displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height);
357
358private:
359 static void InvalidateAndUpdateEMT(Display *pDisplay);
360 static int drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
361
362 int videoAccelRefreshProcess(void);
363
364 /* Functions run under VBVA lock. */
365 int videoAccelEnable (bool fEnable, VBVAMEMORY *pVbvaMemory);
366 void videoAccelFlush (void);
367#endif /* VBOX_WITH_OLD_VBVA_LOCK */
368
369#ifdef VBOX_WITH_HGSMI
370 volatile uint32_t mu32UpdateVBVAFlags;
371#endif
372};
373
374void gdImageCopyResampled (uint8_t *dst, uint8_t *src,
375 int dstX, int dstY,
376 int srcX, int srcY,
377 int dstW, int dstH, int srcW, int srcH);
378
379
380#endif // ____H_DISPLAYIMPL
381/* vi: set tabstop=4 shiftwidth=4 expandtab: */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette