VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxHeadless/NullFramebuffer.h@ 41201

最後變更 在這個檔案從41201是 41201,由 vboxsync 提交於 13 年 前

Main+Frontends: replace custom QueryInterface method to eliminate unnecessary code variation

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 5.6 KB
 
1/*
2 * Copyright (C) 2007-2012 Oracle Corporation
3 *
4 * This file is part of VirtualBox Open Source Edition (OSE), as
5 * available from http://www.alldomusa.eu.org. This file is free software;
6 * you can redistribute it and/or modify it under the terms of the GNU
7 * General Public License (GPL) as published by the Free Software
8 * Foundation, in version 2 as it comes in the "COPYING" file of the
9 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11 */
12
13#ifndef __NULL_FRAMEBUFFER_H
14#define __NULL_FRAMEBUFFER_H
15
16#include <VBox/com/VirtualBox.h>
17#include <iprt/alloc.h>
18
19class NullFB : VBOX_SCRIPTABLE_IMPL(IFramebuffer)
20{
21public:
22 NullFB()
23 :
24 mScreen(NULL), mBuffer(NULL),
25 mUsesGuestVRAM(false),
26 mWidth(0), mHeight(0)
27#ifndef VBOX_WITH_XPCOM
28 , refcnt(0)
29#endif
30 {}
31 virtual ~NullFB()
32 {
33 if (mBuffer)
34 RTMemFree(mBuffer);
35 }
36
37#ifndef VBOX_WITH_XPCOM
38 STDMETHOD_(ULONG, AddRef)() {
39 return ::InterlockedIncrement (&refcnt);
40 }
41 STDMETHOD_(ULONG, Release)() {
42 long cnt = ::InterlockedDecrement (&refcnt);
43 if (cnt == 0)
44 delete this;
45 return cnt;
46 }
47#endif
48
49 BEGIN_COM_MAP(NullFB)
50 VBOX_DEFAULT_INTERFACE_ENTRIES(IFramebuffer)
51 END_COM_MAP()
52
53 // public methods only for internal purposes
54 HRESULT init ()
55 {
56
57 RequestResize(0, FramebufferPixelFormat_Opaque, 0, 0, 0, 640, 480, 0);
58 return S_OK;
59 }
60
61 STDMETHOD(COMGETTER(Width))(ULONG *width)
62 {
63 if (!width)
64 return E_POINTER;
65 *width = mWidth;
66 return S_OK;
67 }
68 STDMETHOD(COMGETTER(Height))(ULONG *height)
69 {
70 if (!height)
71 return E_POINTER;
72 *height = mHeight;
73 return S_OK;
74 }
75 STDMETHOD(Lock)()
76 {
77 return S_OK;
78 }
79 STDMETHOD(Unlock)()
80 {
81 return S_OK;
82 }
83 STDMETHOD(COMGETTER(Address))(BYTE **address)
84 {
85 if (!address)
86 return E_POINTER;
87 *address = mScreen;
88 return S_OK;
89 }
90 STDMETHOD(COMGETTER(BitsPerPixel))(ULONG *bitsPerPixel)
91 {
92 if (!bitsPerPixel)
93 return E_POINTER;
94 *bitsPerPixel = mBitsPerPixel;
95 return S_OK;
96 }
97 STDMETHOD(COMGETTER(BytesPerLine))(ULONG *bytesPerLine)
98 {
99 if (!bytesPerLine)
100 return E_POINTER;
101 *bytesPerLine = mBytesPerLine;
102 return S_OK;
103 }
104 STDMETHOD(COMGETTER(PixelFormat)) (ULONG *pixelFormat)
105 {
106 if (!pixelFormat)
107 return E_POINTER;
108 *pixelFormat = mPixelFormat;
109 return S_OK;
110 }
111 STDMETHOD(COMGETTER(UsesGuestVRAM)) (BOOL *usesGuestVRAM)
112 {
113 if (!usesGuestVRAM)
114 return E_POINTER;
115 *usesGuestVRAM = mUsesGuestVRAM;
116 return S_OK;
117 }
118 STDMETHOD(COMGETTER(HeightReduction)) (ULONG *heightReduction)
119 {
120 if (!heightReduction)
121 return E_POINTER;
122 /* no reduction */
123 *heightReduction = 0;
124 return S_OK;
125 }
126 STDMETHOD(COMGETTER(Overlay)) (IFramebufferOverlay **aOverlay)
127 {
128 if (!aOverlay)
129 return E_POINTER;
130 *aOverlay = 0;
131 return S_OK;
132 }
133 STDMETHOD(COMGETTER(WinId)) (LONG64 *winId)
134 {
135 if (!winId)
136 return E_POINTER;
137 *winId = 0;
138 return S_OK;
139 }
140
141 STDMETHOD(NotifyUpdate)(ULONG x, ULONG y, ULONG w, ULONG h)
142 {
143 return S_OK;
144 }
145 STDMETHOD(RequestResize)(ULONG aScreenId,
146 ULONG pixelFormat,
147 BYTE *vram,
148 ULONG bitsPerPixel,
149 ULONG bytesPerLine,
150 ULONG w,
151 ULONG h,
152 BOOL *finished)
153 {
154 if (mBuffer)
155 {
156 RTMemFree(mBuffer);
157 mBuffer = NULL;
158 }
159
160 mWidth = w;
161 mHeight = h;
162 mPixelFormat = pixelFormat;
163 if (mPixelFormat == FramebufferPixelFormat_Opaque)
164 {
165 mBitsPerPixel = 32;
166 mBytesPerLine = w * 4;
167 mBuffer = (uint8_t*)RTMemAllocZ(mBytesPerLine * h);
168 mScreen = mBuffer;
169 mUsesGuestVRAM = false;
170 }
171 else
172 {
173 mBytesPerLine = bytesPerLine;
174 mBitsPerPixel = bitsPerPixel;
175 mScreen = (uint8_t*)vram;
176 mUsesGuestVRAM = true;
177 }
178
179 if (finished)
180 *finished = true;
181 return S_OK;
182 }
183 STDMETHOD(VideoModeSupported)(ULONG width, ULONG height, ULONG bpp, BOOL *supported)
184 {
185 if (!supported)
186 return E_POINTER;
187 *supported = true;
188 return S_OK;
189 }
190 STDMETHOD(GetVisibleRegion)(BYTE *rectangles, ULONG count, ULONG *countCopied)
191 {
192 if (!rectangles)
193 return E_POINTER;
194 *rectangles = 0;
195 return S_OK;
196 }
197 STDMETHOD(SetVisibleRegion)(BYTE *rectangles, ULONG count)
198 {
199 if (!rectangles)
200 return E_POINTER;
201 return S_OK;
202 }
203
204 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand)
205 {
206 return E_NOTIMPL;
207 }
208
209private:
210 /** Guest framebuffer pixel format */
211 ULONG mPixelFormat;
212 /** Guest framebuffer color depth */
213 ULONG mBitsPerPixel;
214 /** Guest framebuffer line length */
215 ULONG mBytesPerLine;
216 /* VRAM pointer */
217 uint8_t *mScreen;
218 /* VRAM buffer */
219 uint8_t *mBuffer;
220 bool mUsesGuestVRAM;
221
222 ULONG mWidth, mHeight;
223
224#ifndef VBOX_WITH_XPCOM
225 long refcnt;
226#endif
227};
228
229#endif // __NULL_FRAMEBUFFER_H
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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