VirtualBox

source: vbox/trunk/src/VBox/Main/FramebufferImpl.cpp@ 3575

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

Another attempt to fix the build problems.

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