VirtualBox

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

Last change on this file since 729 was 470, checked in by vboxsync, 18 years ago

Main/Frontends: Changed all interface attributes and method parameters that used to use ULONG to pass pointers around; they now use BYTE * for this purpose (should fix problems for 64-bit targets).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung 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
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 mDepth = depth;
49 mLineSize = ((width * depth + 31) / 32) * 4;
50 mData = new uint8_t[mLineSize * height];
51 memset(mData, 0, mLineSize * height);
52 return S_OK;
53}
54
55// IFramebuffer properties
56/////////////////////////////////////////////////////////////////////////////
57
58STDMETHODIMP InternalFramebuffer::COMGETTER(Address) (BYTE **address)
59{
60 if (!address)
61 return E_POINTER;
62 *address = mData;
63 return S_OK;
64}
65
66STDMETHODIMP InternalFramebuffer::COMGETTER(Width) (ULONG *width)
67{
68 if (!width)
69 return E_POINTER;
70 *width = mWidth;
71 return S_OK;
72}
73
74STDMETHODIMP InternalFramebuffer::COMGETTER(Height) (ULONG *height)
75{
76 if (!height)
77 return E_POINTER;
78 *height = mHeight;
79 return S_OK;
80}
81
82STDMETHODIMP InternalFramebuffer::COMGETTER(ColorDepth) (ULONG *colorDepth)
83{
84 if (!colorDepth)
85 return E_POINTER;
86 *colorDepth = mDepth;
87 return S_OK;
88}
89
90STDMETHODIMP InternalFramebuffer::COMGETTER(LineSize) (ULONG *lineSize)
91{
92 if (!lineSize)
93 return E_POINTER;
94 *lineSize = mLineSize;
95 return S_OK;
96}
97
98STDMETHODIMP InternalFramebuffer::COMGETTER(PixelFormat) (FramebufferPixelFormat_T *pixelFormat)
99{
100 if (!pixelFormat)
101 return E_POINTER;
102 *pixelFormat = FramebufferPixelFormat_PixelFormatDefault;
103 return S_OK;
104}
105
106STDMETHODIMP InternalFramebuffer::COMGETTER(HeightReduction) (ULONG *heightReduction)
107{
108 if (!heightReduction)
109 return E_POINTER;
110 /* no reduction */
111 *heightReduction = 0;
112 return S_OK;
113}
114
115STDMETHODIMP InternalFramebuffer::COMGETTER(Overlay) (IFramebufferOverlay **aOverlay)
116{
117 if (!aOverlay)
118 return E_POINTER;
119 /* no overlay */
120 *aOverlay = 0;
121 return S_OK;
122}
123
124// IFramebuffer methods
125/////////////////////////////////////////////////////////////////////////////
126
127STDMETHODIMP InternalFramebuffer::Lock()
128{
129 RTSemMutexRequest(mMutex, RT_INDEFINITE_WAIT);
130 return S_OK;
131}
132
133STDMETHODIMP InternalFramebuffer::Unlock()
134{
135 RTSemMutexRelease(mMutex);
136 return S_OK;
137}
138
139STDMETHODIMP InternalFramebuffer::NotifyUpdate(ULONG x, ULONG y,
140 ULONG w, ULONG h,
141 BOOL *finished)
142{
143 if (!finished)
144 return E_POINTER;
145 // no need for the caller to wait
146 *finished = true;
147 return S_OK;
148}
149
150STDMETHODIMP
151InternalFramebuffer::RequestResize(FramebufferPixelFormat_T pixelFormat, BYTE *vram,
152 ULONG lineSize, ULONG w, ULONG h,
153 BOOL *finished)
154{
155 if (!finished)
156 return E_POINTER;
157 // no need for the caller to wait
158 *finished = true;
159
160 // allocate a new buffer
161 delete mData;
162 mWidth = w;
163 mHeight = h;
164 mLineSize = ((w * mDepth + 31) / 32) * 4;
165 mData = new uint8_t[mLineSize * h];
166 memset(mData, 0, mLineSize * h);
167
168 return S_OK;
169}
170
171STDMETHODIMP InternalFramebuffer::OperationSupported(FramebufferAccelerationOperation_T operation,
172 BOOL *supported)
173{
174 if (!supported)
175 return E_POINTER;
176 /* no acceleration please, we're a slow fallback implementation! */
177 *supported = false;
178 return S_OK;
179}
180
181STDMETHODIMP InternalFramebuffer::VideoModeSupported(ULONG width, ULONG height, ULONG bpp,
182 BOOL *supported)
183{
184 if (!supported)
185 return E_POINTER;
186 /* whatever you want! */
187 *supported = true;
188 return S_OK;
189}
190
191STDMETHODIMP InternalFramebuffer::SolidFill(ULONG x, ULONG y, ULONG width, ULONG height,
192 ULONG color, BOOL *handled)
193{
194 if (!handled)
195 return E_POINTER;
196 /* eek, what do you expect from us?! */
197 *handled = false;
198 return S_OK;
199}
200
201STDMETHODIMP InternalFramebuffer::CopyScreenBits(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
202 ULONG width, ULONG height, BOOL *handled)
203{
204 if (!handled)
205 return E_POINTER;
206 /* eek, what do you expect from us?! */
207 *handled = false;
208 return S_OK;
209}
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