VirtualBox

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

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

The Big Sun Rebranding Header Change

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