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 | #include "FramebufferImpl.h"
|
---|
23 | #include <iprt/semaphore.h>
|
---|
24 |
|
---|
25 | // constructor / destructor
|
---|
26 | /////////////////////////////////////////////////////////////////////////////
|
---|
27 |
|
---|
28 | InternalFramebuffer::InternalFramebuffer()
|
---|
29 | {
|
---|
30 | mData = NULL;
|
---|
31 | RTSemMutexCreate(&mMutex);
|
---|
32 | }
|
---|
33 |
|
---|
34 | InternalFramebuffer::~InternalFramebuffer()
|
---|
35 | {
|
---|
36 | RTSemMutexDestroy(mMutex);
|
---|
37 | if (mData)
|
---|
38 | delete mData;
|
---|
39 | }
|
---|
40 |
|
---|
41 | // public methods only for internal purposes
|
---|
42 | /////////////////////////////////////////////////////////////////////////////
|
---|
43 |
|
---|
44 | HRESULT InternalFramebuffer::init(ULONG width, ULONG height, ULONG depth)
|
---|
45 | {
|
---|
46 | mWidth = width;
|
---|
47 | mHeight = height;
|
---|
48 | mDepth = depth;
|
---|
49 | mLineSize = ((width * depth + 31) / 32) * 4;
|
---|
50 | mData = new uint8_t[mLineSize * height];
|
---|
51 | memset(mData, 0, mLineSize * height);
|
---|
52 |
|
---|
53 | return S_OK;
|
---|
54 | }
|
---|
55 |
|
---|
56 | // IFramebuffer properties
|
---|
57 | /////////////////////////////////////////////////////////////////////////////
|
---|
58 |
|
---|
59 | STDMETHODIMP InternalFramebuffer::COMGETTER(Address) (BYTE **address)
|
---|
60 | {
|
---|
61 | if (!address)
|
---|
62 | return E_POINTER;
|
---|
63 | *address = mData;
|
---|
64 | return S_OK;
|
---|
65 | }
|
---|
66 |
|
---|
67 | STDMETHODIMP InternalFramebuffer::COMGETTER(Width) (ULONG *width)
|
---|
68 | {
|
---|
69 | if (!width)
|
---|
70 | return E_POINTER;
|
---|
71 | *width = mWidth;
|
---|
72 | return S_OK;
|
---|
73 | }
|
---|
74 |
|
---|
75 | STDMETHODIMP InternalFramebuffer::COMGETTER(Height) (ULONG *height)
|
---|
76 | {
|
---|
77 | if (!height)
|
---|
78 | return E_POINTER;
|
---|
79 | *height = mHeight;
|
---|
80 | return S_OK;
|
---|
81 | }
|
---|
82 |
|
---|
83 | STDMETHODIMP InternalFramebuffer::COMGETTER(ColorDepth) (ULONG *colorDepth)
|
---|
84 | {
|
---|
85 | if (!colorDepth)
|
---|
86 | return E_POINTER;
|
---|
87 | *colorDepth = mDepth;
|
---|
88 | return S_OK;
|
---|
89 | }
|
---|
90 |
|
---|
91 | STDMETHODIMP InternalFramebuffer::COMGETTER(LineSize) (ULONG *lineSize)
|
---|
92 | {
|
---|
93 | if (!lineSize)
|
---|
94 | return E_POINTER;
|
---|
95 | *lineSize = mLineSize;
|
---|
96 | return S_OK;
|
---|
97 | }
|
---|
98 |
|
---|
99 | STDMETHODIMP InternalFramebuffer::COMGETTER(PixelFormat) (FramebufferPixelFormat_T *pixelFormat)
|
---|
100 | {
|
---|
101 | if (!pixelFormat)
|
---|
102 | return E_POINTER;
|
---|
103 | *pixelFormat = FramebufferPixelFormat_PixelFormatOpaque;
|
---|
104 | return S_OK;
|
---|
105 | }
|
---|
106 |
|
---|
107 | STDMETHODIMP InternalFramebuffer::COMGETTER(HeightReduction) (ULONG *heightReduction)
|
---|
108 | {
|
---|
109 | if (!heightReduction)
|
---|
110 | return E_POINTER;
|
---|
111 | /* no reduction */
|
---|
112 | *heightReduction = 0;
|
---|
113 | return S_OK;
|
---|
114 | }
|
---|
115 |
|
---|
116 | STDMETHODIMP InternalFramebuffer::COMGETTER(Overlay) (IFramebufferOverlay **aOverlay)
|
---|
117 | {
|
---|
118 | if (!aOverlay)
|
---|
119 | return E_POINTER;
|
---|
120 | /* no overlay */
|
---|
121 | *aOverlay = 0;
|
---|
122 | return S_OK;
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|
126 | // IFramebuffer methods
|
---|
127 | /////////////////////////////////////////////////////////////////////////////
|
---|
128 |
|
---|
129 | STDMETHODIMP InternalFramebuffer::Lock()
|
---|
130 | {
|
---|
131 | RTSemMutexRequest(mMutex, RT_INDEFINITE_WAIT);
|
---|
132 | return S_OK;
|
---|
133 | }
|
---|
134 |
|
---|
135 | STDMETHODIMP InternalFramebuffer::Unlock()
|
---|
136 | {
|
---|
137 | RTSemMutexRelease(mMutex);
|
---|
138 | return S_OK;
|
---|
139 | }
|
---|
140 |
|
---|
141 | STDMETHODIMP InternalFramebuffer::NotifyUpdate(ULONG x, ULONG y,
|
---|
142 | ULONG w, ULONG h,
|
---|
143 | BOOL *finished)
|
---|
144 | {
|
---|
145 | if (!finished)
|
---|
146 | return E_POINTER;
|
---|
147 | // no need for the caller to wait
|
---|
148 | *finished = true;
|
---|
149 | return S_OK;
|
---|
150 | }
|
---|
151 |
|
---|
152 | STDMETHODIMP
|
---|
153 | InternalFramebuffer::RequestResize(ULONG iScreenId, FramebufferPixelFormat_T pixelFormat, BYTE *vram,
|
---|
154 | ULONG lineSize, ULONG w, ULONG h,
|
---|
155 | BOOL *finished)
|
---|
156 | {
|
---|
157 | if (!finished)
|
---|
158 | return E_POINTER;
|
---|
159 | // no need for the caller to wait
|
---|
160 | *finished = true;
|
---|
161 |
|
---|
162 | // allocate a new buffer
|
---|
163 | delete mData;
|
---|
164 | mWidth = w;
|
---|
165 | mHeight = h;
|
---|
166 | mLineSize = ((w * mDepth + 31) / 32) * 4;
|
---|
167 | mData = new uint8_t[mLineSize * h];
|
---|
168 | memset(mData, 0, mLineSize * h);
|
---|
169 |
|
---|
170 | return S_OK;
|
---|
171 | }
|
---|
172 |
|
---|
173 | STDMETHODIMP InternalFramebuffer::OperationSupported(FramebufferAccelerationOperation_T operation,
|
---|
174 | BOOL *supported)
|
---|
175 | {
|
---|
176 | if (!supported)
|
---|
177 | return E_POINTER;
|
---|
178 | /* no acceleration please, we're a slow fallback implementation! */
|
---|
179 | *supported = false;
|
---|
180 | return S_OK;
|
---|
181 | }
|
---|
182 |
|
---|
183 | STDMETHODIMP InternalFramebuffer::VideoModeSupported(ULONG width, ULONG height, ULONG bpp,
|
---|
184 | BOOL *supported)
|
---|
185 | {
|
---|
186 | if (!supported)
|
---|
187 | return E_POINTER;
|
---|
188 | /* whatever you want! */
|
---|
189 | *supported = true;
|
---|
190 | return S_OK;
|
---|
191 | }
|
---|
192 |
|
---|
193 | STDMETHODIMP InternalFramebuffer::SolidFill(ULONG x, ULONG y, ULONG width, ULONG height,
|
---|
194 | ULONG color, BOOL *handled)
|
---|
195 | {
|
---|
196 | if (!handled)
|
---|
197 | return E_POINTER;
|
---|
198 | /* eek, what do you expect from us?! */
|
---|
199 | *handled = false;
|
---|
200 | return S_OK;
|
---|
201 | }
|
---|
202 |
|
---|
203 | STDMETHODIMP InternalFramebuffer::CopyScreenBits(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
|
---|
204 | ULONG width, ULONG height, BOOL *handled)
|
---|
205 | {
|
---|
206 | if (!handled)
|
---|
207 | return E_POINTER;
|
---|
208 | /* eek, what do you expect from us?! */
|
---|
209 | *handled = false;
|
---|
210 | return S_OK;
|
---|
211 | }
|
---|
212 |
|
---|
213 | STDMETHODIMP InternalFramebuffer::GetVisibleRegion(BYTE *aRectangles, ULONG aCount,
|
---|
214 | ULONG *aCountCopied)
|
---|
215 | {
|
---|
216 | PRTRECT rects = (PRTRECT)aRectangles;
|
---|
217 |
|
---|
218 | if (!rects)
|
---|
219 | return E_POINTER;
|
---|
220 |
|
---|
221 | /// @todo
|
---|
222 |
|
---|
223 | NOREF(rects);
|
---|
224 | NOREF(aCount);
|
---|
225 | NOREF(aCountCopied);
|
---|
226 |
|
---|
227 | return S_OK;
|
---|
228 | }
|
---|
229 |
|
---|
230 | STDMETHODIMP InternalFramebuffer::SetVisibleRegion(BYTE *aRectangles, ULONG aCount)
|
---|
231 | {
|
---|
232 | PRTRECT rects = (PRTRECT)aRectangles;
|
---|
233 |
|
---|
234 | if (!rects)
|
---|
235 | return E_POINTER;
|
---|
236 |
|
---|
237 | /// @todo
|
---|
238 |
|
---|
239 | NOREF(rects);
|
---|
240 | NOREF(aCount);
|
---|
241 |
|
---|
242 | return S_OK;
|
---|
243 | }
|
---|