VirtualBox

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

Last change on this file since 317 was 1, checked in by vboxsync, 55 years ago

import

  • 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) (ULONG *address)
59{
60 if (!address)
61 return E_POINTER;
62 *address = (ULONG)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 InternalFramebuffer::RequestResize(FramebufferPixelFormat_T pixelFormat, ULONG vram, ULONG lineSize, 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
158 // allocate a new buffer
159 delete mData;
160 mWidth = w;
161 mHeight = h;
162 mLineSize = ((w * mDepth + 31) / 32) * 4;
163 mData = new uint8_t[mLineSize * h];
164 memset(mData, 0, mLineSize * h);
165
166 return S_OK;
167}
168
169STDMETHODIMP InternalFramebuffer::OperationSupported(FramebufferAccelerationOperation_T operation,
170 BOOL *supported)
171{
172 if (!supported)
173 return E_POINTER;
174 /* no acceleration please, we're a slow fallback implementation! */
175 *supported = false;
176 return S_OK;
177}
178
179STDMETHODIMP InternalFramebuffer::VideoModeSupported(ULONG width, ULONG height, ULONG bpp,
180 BOOL *supported)
181{
182 if (!supported)
183 return E_POINTER;
184 /* whatever you want! */
185 *supported = true;
186 return S_OK;
187}
188
189STDMETHODIMP InternalFramebuffer::SolidFill(ULONG x, ULONG y, ULONG width, ULONG height,
190 ULONG color, BOOL *handled)
191{
192 if (!handled)
193 return E_POINTER;
194 /* eek, what do you expect from us?! */
195 *handled = false;
196 return S_OK;
197}
198
199STDMETHODIMP InternalFramebuffer::CopyScreenBits(ULONG xDst, ULONG yDst, ULONG xSrc, ULONG ySrc,
200 ULONG width, ULONG height, BOOL *handled)
201{
202 if (!handled)
203 return E_POINTER;
204 /* eek, what do you expect from us?! */
205 *handled = false;
206 return S_OK;
207}
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