1 | /* $Id: VBoxFBOverlay.h 72057 2018-04-27 11:55:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - VBoxFrameBuffer Overly classes declarations.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
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 | #ifndef __VBoxFBOverlay_h__
|
---|
18 | #define __VBoxFBOverlay_h__
|
---|
19 |
|
---|
20 | #if defined(VBOX_GUI_USE_QGL) || defined(VBOX_WITH_VIDEOHWACCEL)
|
---|
21 |
|
---|
22 | /* Defines: */
|
---|
23 | //#define VBOXQGL_PROF_BASE 1
|
---|
24 | //#define VBOXQGL_DBG_SURF 1
|
---|
25 | //#define VBOXVHWADBG_RENDERCHECK
|
---|
26 | #define VBOXVHWA_ALLOW_PRIMARY_AND_OVERLAY_ONLY 1
|
---|
27 |
|
---|
28 | /* Qt includes: */
|
---|
29 | #ifdef RT_OS_WINDOWS
|
---|
30 | # include <iprt/win/windows.h> /* QGLWidget drags in Windows.h; -Wall forces us to use wrapper. */
|
---|
31 | # include <iprt/stdint.h> /* QGLWidget drags in stdint.h; -Wall forces us to use wrapper. */
|
---|
32 | #endif
|
---|
33 | #include <QGLWidget>
|
---|
34 |
|
---|
35 | /* GUI includes: */
|
---|
36 | #include "UIDefs.h"
|
---|
37 | #include "VBoxFBOverlayCommon.h"
|
---|
38 | #include "runtime/UIFrameBuffer.h"
|
---|
39 | #include "runtime/UIMachineView.h"
|
---|
40 |
|
---|
41 | /* COM includes: */
|
---|
42 | #include "COMEnums.h"
|
---|
43 |
|
---|
44 | #include "CDisplay.h"
|
---|
45 |
|
---|
46 | /* Other VBox includes: */
|
---|
47 | #include <iprt/assert.h>
|
---|
48 | #include <iprt/critsect.h>
|
---|
49 | #include <iprt/asm.h>
|
---|
50 | #include <iprt/err.h>
|
---|
51 | #include <iprt/list.h>
|
---|
52 | #include <VBox/VBoxGL2D.h>
|
---|
53 | #ifdef VBOXVHWA_PROFILE_FPS
|
---|
54 | # include <iprt/stream.h>
|
---|
55 | #endif /* VBOXVHWA_PROFILE_FPS */
|
---|
56 |
|
---|
57 | #ifndef S_FALSE
|
---|
58 | # define S_FALSE ((HRESULT)1L)
|
---|
59 | #endif
|
---|
60 |
|
---|
61 | #ifdef DEBUG_misha
|
---|
62 | # define VBOXVHWA_PROFILE_FPS
|
---|
63 | #endif /* DEBUG_misha */
|
---|
64 |
|
---|
65 | /* Forward declarations: */
|
---|
66 | class CSession;
|
---|
67 |
|
---|
68 | #ifdef DEBUG
|
---|
69 | class VBoxVHWADbgTimer
|
---|
70 | {
|
---|
71 | public:
|
---|
72 | VBoxVHWADbgTimer(uint32_t cPeriods);
|
---|
73 | ~VBoxVHWADbgTimer();
|
---|
74 | void frame();
|
---|
75 | uint64_t everagePeriod() {return mPeriodSum / mcPeriods; }
|
---|
76 | double fps() {return ((double)1000000000.0) / everagePeriod(); }
|
---|
77 | uint64_t frames() {return mcFrames; }
|
---|
78 | private:
|
---|
79 | uint64_t mPeriodSum;
|
---|
80 | uint64_t *mpaPeriods;
|
---|
81 | uint64_t mPrevTime;
|
---|
82 | uint64_t mcFrames;
|
---|
83 | uint32_t mcPeriods;
|
---|
84 | uint32_t miPeriod;
|
---|
85 | };
|
---|
86 |
|
---|
87 | #endif /* DEBUG */
|
---|
88 |
|
---|
89 | class VBoxVHWASettings
|
---|
90 | {
|
---|
91 | public:
|
---|
92 | VBoxVHWASettings ();
|
---|
93 | void init(CSession &session);
|
---|
94 |
|
---|
95 | int fourccEnabledCount() const { return mFourccEnabledCount; }
|
---|
96 | const uint32_t * fourccEnabledList() const { return mFourccEnabledList; }
|
---|
97 |
|
---|
98 | bool isStretchLinearEnabled() const { return mStretchLinearEnabled; }
|
---|
99 |
|
---|
100 | static int calcIntersection (int c1, const uint32_t *a1, int c2, const uint32_t *a2, int cOut, uint32_t *aOut);
|
---|
101 |
|
---|
102 | int getIntersection (const VBoxVHWAInfo &aInfo, int cOut, uint32_t *aOut)
|
---|
103 | {
|
---|
104 | return calcIntersection (mFourccEnabledCount, mFourccEnabledList, aInfo.getFourccSupportedCount(), aInfo.getFourccSupportedList(), cOut, aOut);
|
---|
105 | }
|
---|
106 |
|
---|
107 | bool isSupported(const VBoxVHWAInfo &aInfo, uint32_t format)
|
---|
108 | {
|
---|
109 | return calcIntersection (mFourccEnabledCount, mFourccEnabledList, 1, &format, 0, NULL)
|
---|
110 | && calcIntersection (aInfo.getFourccSupportedCount(), aInfo.getFourccSupportedList(), 1, &format, 0, NULL);
|
---|
111 | }
|
---|
112 | private:
|
---|
113 | uint32_t mFourccEnabledList[VBOXVHWA_NUMFOURCC];
|
---|
114 | int mFourccEnabledCount;
|
---|
115 | bool mStretchLinearEnabled;
|
---|
116 | };
|
---|
117 |
|
---|
118 | class VBoxVHWADirtyRect
|
---|
119 | {
|
---|
120 | public:
|
---|
121 | VBoxVHWADirtyRect() :
|
---|
122 | mIsClear(true)
|
---|
123 | {}
|
---|
124 |
|
---|
125 | VBoxVHWADirtyRect(const QRect & aRect)
|
---|
126 | {
|
---|
127 | if(aRect.isEmpty())
|
---|
128 | {
|
---|
129 | mIsClear = false;
|
---|
130 | mRect = aRect;
|
---|
131 | }
|
---|
132 | else
|
---|
133 | {
|
---|
134 | mIsClear = true;
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | bool isClear() const { return mIsClear; }
|
---|
139 |
|
---|
140 | void add(const QRect & aRect)
|
---|
141 | {
|
---|
142 | if(aRect.isEmpty())
|
---|
143 | return;
|
---|
144 |
|
---|
145 | mRect = mIsClear ? aRect : mRect.united(aRect);
|
---|
146 | mIsClear = false;
|
---|
147 | }
|
---|
148 |
|
---|
149 | void add(const VBoxVHWADirtyRect & aRect)
|
---|
150 | {
|
---|
151 | if(aRect.isClear())
|
---|
152 | return;
|
---|
153 | add(aRect.rect());
|
---|
154 | }
|
---|
155 |
|
---|
156 | void set(const QRect & aRect)
|
---|
157 | {
|
---|
158 | if(aRect.isEmpty())
|
---|
159 | {
|
---|
160 | mIsClear = true;
|
---|
161 | }
|
---|
162 | else
|
---|
163 | {
|
---|
164 | mRect = aRect;
|
---|
165 | mIsClear = false;
|
---|
166 | }
|
---|
167 | }
|
---|
168 |
|
---|
169 | void clear() { mIsClear = true; }
|
---|
170 |
|
---|
171 | const QRect & rect() const {return mRect;}
|
---|
172 |
|
---|
173 | const QRect & toRect()
|
---|
174 | {
|
---|
175 | if(isClear())
|
---|
176 | {
|
---|
177 | mRect.setCoords(0, 0, -1, -1);
|
---|
178 | }
|
---|
179 | return mRect;
|
---|
180 | }
|
---|
181 |
|
---|
182 | bool intersects(const QRect & aRect) const {return mIsClear ? false : mRect.intersects(aRect);}
|
---|
183 |
|
---|
184 | bool intersects(const VBoxVHWADirtyRect & aRect) const {return mIsClear ? false : aRect.intersects(mRect);}
|
---|
185 |
|
---|
186 | QRect united(const QRect & aRect) const {return mIsClear ? aRect : aRect.united(mRect);}
|
---|
187 |
|
---|
188 | bool contains(const QRect & aRect) const {return mIsClear ? false : aRect.contains(mRect);}
|
---|
189 |
|
---|
190 | void subst(const VBoxVHWADirtyRect & aRect) { if(!mIsClear && aRect.contains(mRect)) clear(); }
|
---|
191 |
|
---|
192 | private:
|
---|
193 | QRect mRect;
|
---|
194 | bool mIsClear;
|
---|
195 | };
|
---|
196 |
|
---|
197 | class VBoxVHWAColorKey
|
---|
198 | {
|
---|
199 | public:
|
---|
200 | VBoxVHWAColorKey() :
|
---|
201 | mUpper(0),
|
---|
202 | mLower(0)
|
---|
203 | {}
|
---|
204 |
|
---|
205 | VBoxVHWAColorKey(uint32_t aUpper, uint32_t aLower) :
|
---|
206 | mUpper(aUpper),
|
---|
207 | mLower(aLower)
|
---|
208 | {}
|
---|
209 |
|
---|
210 | uint32_t upper() const {return mUpper; }
|
---|
211 | uint32_t lower() const {return mLower; }
|
---|
212 |
|
---|
213 | bool operator==(const VBoxVHWAColorKey & other) const { return mUpper == other.mUpper && mLower == other.mLower; }
|
---|
214 | bool operator!=(const VBoxVHWAColorKey & other) const { return !(*this == other); }
|
---|
215 | private:
|
---|
216 | uint32_t mUpper;
|
---|
217 | uint32_t mLower;
|
---|
218 | };
|
---|
219 |
|
---|
220 | class VBoxVHWAColorComponent
|
---|
221 | {
|
---|
222 | public:
|
---|
223 | VBoxVHWAColorComponent() :
|
---|
224 | mMask(0),
|
---|
225 | mRange(0),
|
---|
226 | mOffset(32),
|
---|
227 | mcBits(0)
|
---|
228 | {}
|
---|
229 |
|
---|
230 | VBoxVHWAColorComponent(uint32_t aMask);
|
---|
231 |
|
---|
232 | uint32_t mask() const { return mMask; }
|
---|
233 | uint32_t range() const { return mRange; }
|
---|
234 | uint32_t offset() const { return mOffset; }
|
---|
235 | uint32_t cBits() const { return mcBits; }
|
---|
236 | uint32_t colorVal(uint32_t col) const { return (col & mMask) >> mOffset; }
|
---|
237 | float colorValNorm(uint32_t col) const { return ((float)colorVal(col))/mRange; }
|
---|
238 | private:
|
---|
239 | uint32_t mMask;
|
---|
240 | uint32_t mRange;
|
---|
241 | uint32_t mOffset;
|
---|
242 | uint32_t mcBits;
|
---|
243 | };
|
---|
244 |
|
---|
245 | class VBoxVHWAColorFormat
|
---|
246 | {
|
---|
247 | public:
|
---|
248 |
|
---|
249 | VBoxVHWAColorFormat(uint32_t bitsPerPixel, uint32_t r, uint32_t g, uint32_t b);
|
---|
250 | VBoxVHWAColorFormat(uint32_t fourcc);
|
---|
251 | VBoxVHWAColorFormat() :
|
---|
252 | mBitsPerPixel(0) /* needed for isValid() to work */
|
---|
253 | {}
|
---|
254 | GLint internalFormat() const {return mInternalFormat; }
|
---|
255 | GLenum format() const {return mFormat; }
|
---|
256 | GLenum type() const {return mType; }
|
---|
257 | bool isValid() const {return mBitsPerPixel != 0; }
|
---|
258 | uint32_t fourcc() const {return mDataFormat;}
|
---|
259 | uint32_t bitsPerPixel() const { return mBitsPerPixel; }
|
---|
260 | uint32_t bitsPerPixelTex() const { return mBitsPerPixelTex; }
|
---|
261 | void pixel2Normalized(uint32_t pix, float *r, float *g, float *b) const;
|
---|
262 | uint32_t widthCompression() const {return mWidthCompression;}
|
---|
263 | uint32_t heightCompression() const {return mHeightCompression;}
|
---|
264 | const VBoxVHWAColorComponent& r() const {return mR;}
|
---|
265 | const VBoxVHWAColorComponent& g() const {return mG;}
|
---|
266 | const VBoxVHWAColorComponent& b() const {return mB;}
|
---|
267 | const VBoxVHWAColorComponent& a() const {return mA;}
|
---|
268 |
|
---|
269 | bool equals (const VBoxVHWAColorFormat & other) const;
|
---|
270 |
|
---|
271 | ulong toVBoxPixelFormat() const
|
---|
272 | {
|
---|
273 | if (!mDataFormat)
|
---|
274 | {
|
---|
275 | /* RGB data */
|
---|
276 | switch (mFormat)
|
---|
277 | {
|
---|
278 | case GL_BGRA_EXT:
|
---|
279 | return KBitmapFormat_BGR;
|
---|
280 | }
|
---|
281 | }
|
---|
282 | return KBitmapFormat_Opaque;
|
---|
283 | }
|
---|
284 |
|
---|
285 | private:
|
---|
286 | void init(uint32_t bitsPerPixel, uint32_t r, uint32_t g, uint32_t b);
|
---|
287 | void init(uint32_t fourcc);
|
---|
288 |
|
---|
289 | GLint mInternalFormat;
|
---|
290 | GLenum mFormat;
|
---|
291 | GLenum mType;
|
---|
292 | uint32_t mDataFormat;
|
---|
293 |
|
---|
294 | uint32_t mBitsPerPixel;
|
---|
295 | uint32_t mBitsPerPixelTex;
|
---|
296 | uint32_t mWidthCompression;
|
---|
297 | uint32_t mHeightCompression;
|
---|
298 | VBoxVHWAColorComponent mR;
|
---|
299 | VBoxVHWAColorComponent mG;
|
---|
300 | VBoxVHWAColorComponent mB;
|
---|
301 | VBoxVHWAColorComponent mA;
|
---|
302 | };
|
---|
303 |
|
---|
304 | class VBoxVHWATexture
|
---|
305 | {
|
---|
306 | public:
|
---|
307 | VBoxVHWATexture() :
|
---|
308 | mAddress(NULL),
|
---|
309 | mTexture(0),
|
---|
310 | mBytesPerPixel(0),
|
---|
311 | mBytesPerPixelTex(0),
|
---|
312 | mBytesPerLine(0),
|
---|
313 | mScaleFuncttion(GL_NEAREST)
|
---|
314 | {}
|
---|
315 | VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion);
|
---|
316 | virtual ~VBoxVHWATexture();
|
---|
317 | virtual void init(uchar *pvMem);
|
---|
318 | void setAddress(uchar *pvMem) {mAddress = pvMem;}
|
---|
319 | void update(const QRect * pRect) { doUpdate(mAddress, pRect);}
|
---|
320 | void bind() {glBindTexture(texTarget(), mTexture);}
|
---|
321 |
|
---|
322 | virtual void texCoord(int x, int y);
|
---|
323 | virtual void multiTexCoord(GLenum texUnit, int x, int y);
|
---|
324 |
|
---|
325 | const QRect & texRect() {return mTexRect;}
|
---|
326 | const QRect & rect() {return mRect;}
|
---|
327 | uchar * address(){ return mAddress; }
|
---|
328 | uint32_t rectSizeTex(const QRect * pRect) {return pRect->width() * pRect->height() * mBytesPerPixelTex;}
|
---|
329 | uchar * pointAddress(int x, int y)
|
---|
330 | {
|
---|
331 | x = toXTex(x);
|
---|
332 | y = toYTex(y);
|
---|
333 | return pointAddressTex(x, y);
|
---|
334 | }
|
---|
335 | uint32_t pointOffsetTex(int x, int y) { return y*mBytesPerLine + x*mBytesPerPixelTex; }
|
---|
336 | uchar * pointAddressTex(int x, int y) { return mAddress + pointOffsetTex(x, y); }
|
---|
337 | int toXTex(int x) {return x/mColorFormat.widthCompression();}
|
---|
338 | int toYTex(int y) {return y/mColorFormat.heightCompression();}
|
---|
339 | ulong memSize(){ return mBytesPerLine * mRect.height(); }
|
---|
340 | uint32_t bytesPerLine() {return mBytesPerLine; }
|
---|
341 | #ifdef DEBUG_misha
|
---|
342 | void dbgDump();
|
---|
343 | #endif
|
---|
344 |
|
---|
345 | protected:
|
---|
346 | virtual void doUpdate(uchar * pAddress, const QRect * pRect);
|
---|
347 | virtual void initParams();
|
---|
348 | virtual void load();
|
---|
349 | virtual GLenum texTarget() {return GL_TEXTURE_2D; }
|
---|
350 | GLuint texture() {return mTexture;}
|
---|
351 |
|
---|
352 | QRect mTexRect; /* texture size */
|
---|
353 | QRect mRect; /* img size */
|
---|
354 | uchar * mAddress;
|
---|
355 | GLuint mTexture;
|
---|
356 | uint32_t mBytesPerPixel;
|
---|
357 | uint32_t mBytesPerPixelTex;
|
---|
358 | uint32_t mBytesPerLine;
|
---|
359 | VBoxVHWAColorFormat mColorFormat;
|
---|
360 | GLint mScaleFuncttion;
|
---|
361 | private:
|
---|
362 | void uninit();
|
---|
363 |
|
---|
364 | friend class VBoxVHWAFBO;
|
---|
365 | };
|
---|
366 |
|
---|
367 | class VBoxVHWATextureNP2 : public VBoxVHWATexture
|
---|
368 | {
|
---|
369 | public:
|
---|
370 | VBoxVHWATextureNP2() : VBoxVHWATexture() {}
|
---|
371 | VBoxVHWATextureNP2(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
|
---|
372 | VBoxVHWATexture(aRect, aFormat, bytesPerLine, scaleFuncttion){
|
---|
373 | mTexRect = QRect(0, 0, aRect.width()/aFormat.widthCompression(), aRect.height()/aFormat.heightCompression());
|
---|
374 | }
|
---|
375 | };
|
---|
376 |
|
---|
377 | class VBoxVHWATextureNP2Rect : public VBoxVHWATextureNP2
|
---|
378 | {
|
---|
379 | public:
|
---|
380 | VBoxVHWATextureNP2Rect() : VBoxVHWATextureNP2() {}
|
---|
381 | VBoxVHWATextureNP2Rect(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
|
---|
382 | VBoxVHWATextureNP2(aRect, aFormat, bytesPerLine, scaleFuncttion){}
|
---|
383 |
|
---|
384 | virtual void texCoord(int x, int y);
|
---|
385 | virtual void multiTexCoord(GLenum texUnit, int x, int y);
|
---|
386 | protected:
|
---|
387 | virtual GLenum texTarget();
|
---|
388 | };
|
---|
389 |
|
---|
390 | class VBoxVHWATextureNP2RectPBO : public VBoxVHWATextureNP2Rect
|
---|
391 | {
|
---|
392 | public:
|
---|
393 | VBoxVHWATextureNP2RectPBO() :
|
---|
394 | VBoxVHWATextureNP2Rect(),
|
---|
395 | mPBO(0)
|
---|
396 | {}
|
---|
397 | VBoxVHWATextureNP2RectPBO(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
|
---|
398 | VBoxVHWATextureNP2Rect(aRect, aFormat, bytesPerLine, scaleFuncttion),
|
---|
399 | mPBO(0)
|
---|
400 | {}
|
---|
401 |
|
---|
402 | virtual ~VBoxVHWATextureNP2RectPBO();
|
---|
403 |
|
---|
404 | virtual void init(uchar *pvMem);
|
---|
405 | protected:
|
---|
406 | virtual void load();
|
---|
407 | virtual void doUpdate(uchar * pAddress, const QRect * pRect);
|
---|
408 | GLuint mPBO;
|
---|
409 | };
|
---|
410 |
|
---|
411 | class VBoxVHWATextureNP2RectPBOMapped : public VBoxVHWATextureNP2RectPBO
|
---|
412 | {
|
---|
413 | public:
|
---|
414 | VBoxVHWATextureNP2RectPBOMapped() :
|
---|
415 | VBoxVHWATextureNP2RectPBO(),
|
---|
416 | mpMappedAllignedBuffer(NULL),
|
---|
417 | mcbAllignedBufferSize(0),
|
---|
418 | mcbOffset(0)
|
---|
419 | {}
|
---|
420 | VBoxVHWATextureNP2RectPBOMapped(const QRect & aRect, const VBoxVHWAColorFormat &aFormat, uint32_t bytesPerLine, GLint scaleFuncttion) :
|
---|
421 | VBoxVHWATextureNP2RectPBO(aRect, aFormat, bytesPerLine, scaleFuncttion),
|
---|
422 | mpMappedAllignedBuffer(NULL),
|
---|
423 | mcbOffset(0)
|
---|
424 | {
|
---|
425 | mcbAllignedBufferSize = alignSize((size_t)memSize());
|
---|
426 | mcbActualBufferSize = mcbAllignedBufferSize + 0x1fff;
|
---|
427 | }
|
---|
428 |
|
---|
429 | uchar* mapAlignedBuffer();
|
---|
430 | void unmapBuffer();
|
---|
431 | size_t alignedBufferSize() { return mcbAllignedBufferSize; }
|
---|
432 |
|
---|
433 | static size_t alignSize(size_t size)
|
---|
434 | {
|
---|
435 | size_t alSize = size & ~((size_t)0xfff);
|
---|
436 | return alSize == size ? alSize : alSize + 0x1000;
|
---|
437 | }
|
---|
438 |
|
---|
439 | static void* alignBuffer(void* pvMem) { return (void*)(((uintptr_t)pvMem) & ~((uintptr_t)0xfff)); }
|
---|
440 | static size_t calcOffset(void* pvBase, void* pvOffset) { return (size_t)(((uintptr_t)pvBase) - ((uintptr_t)pvOffset)); }
|
---|
441 | protected:
|
---|
442 | virtual void load();
|
---|
443 | virtual void doUpdate(uchar * pAddress, const QRect * pRect);
|
---|
444 | private:
|
---|
445 | uchar* mpMappedAllignedBuffer;
|
---|
446 | size_t mcbAllignedBufferSize;
|
---|
447 | size_t mcbOffset;
|
---|
448 | size_t mcbActualBufferSize;
|
---|
449 | };
|
---|
450 |
|
---|
451 | #define VBOXVHWAIMG_PBO 0x00000001U
|
---|
452 | #define VBOXVHWAIMG_PBOIMG 0x00000002U
|
---|
453 | #define VBOXVHWAIMG_FBO 0x00000004U
|
---|
454 | #define VBOXVHWAIMG_LINEAR 0x00000008U
|
---|
455 | typedef uint32_t VBOXVHWAIMG_TYPE;
|
---|
456 |
|
---|
457 | class VBoxVHWATextureImage
|
---|
458 | {
|
---|
459 | public:
|
---|
460 | VBoxVHWATextureImage(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags);
|
---|
461 |
|
---|
462 | virtual ~VBoxVHWATextureImage()
|
---|
463 | {
|
---|
464 | for(uint i = 0; i < mcTex; i++)
|
---|
465 | {
|
---|
466 | delete mpTex[i];
|
---|
467 | }
|
---|
468 | }
|
---|
469 |
|
---|
470 | virtual void init(uchar *pvMem)
|
---|
471 | {
|
---|
472 | for(uint32_t i = 0; i < mcTex; i++)
|
---|
473 | {
|
---|
474 | mpTex[i]->init(pvMem);
|
---|
475 | pvMem += mpTex[i]->memSize();
|
---|
476 | }
|
---|
477 | }
|
---|
478 |
|
---|
479 | virtual void update(const QRect * pRect)
|
---|
480 | {
|
---|
481 | mpTex[0]->update(pRect);
|
---|
482 | if(mColorFormat.fourcc() == FOURCC_YV12)
|
---|
483 | {
|
---|
484 | if(pRect)
|
---|
485 | {
|
---|
486 | QRect rect(pRect->x()/2, pRect->y()/2,
|
---|
487 | pRect->width()/2, pRect->height()/2);
|
---|
488 | mpTex[1]->update(&rect);
|
---|
489 | mpTex[2]->update(&rect);
|
---|
490 | }
|
---|
491 | else
|
---|
492 | {
|
---|
493 | mpTex[1]->update(NULL);
|
---|
494 | mpTex[2]->update(NULL);
|
---|
495 | }
|
---|
496 | }
|
---|
497 | }
|
---|
498 |
|
---|
499 | virtual void display(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect,
|
---|
500 | const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected);
|
---|
501 |
|
---|
502 |
|
---|
503 | virtual void display();
|
---|
504 |
|
---|
505 | void deleteDisplay();
|
---|
506 |
|
---|
507 | int initDisplay(VBoxVHWATextureImage *pDst,
|
---|
508 | const QRect * pDstRect, const QRect * pSrcRect,
|
---|
509 | const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected);
|
---|
510 |
|
---|
511 | bool displayInitialized() { return !!mVisibleDisplay;}
|
---|
512 |
|
---|
513 | virtual void setAddress(uchar *pvMem)
|
---|
514 | {
|
---|
515 | for(uint32_t i = 0; i < mcTex; i++)
|
---|
516 | {
|
---|
517 | mpTex[i]->setAddress(pvMem);
|
---|
518 | pvMem += mpTex[i]->memSize();
|
---|
519 | }
|
---|
520 | }
|
---|
521 |
|
---|
522 | const QRect &rect()
|
---|
523 | {
|
---|
524 | return mpTex[0]->rect();
|
---|
525 | }
|
---|
526 |
|
---|
527 | size_t memSize()
|
---|
528 | {
|
---|
529 | size_t size = 0;
|
---|
530 | for(uint32_t i = 0; i < mcTex; i++)
|
---|
531 | {
|
---|
532 | size+=mpTex[i]->memSize();
|
---|
533 | }
|
---|
534 | return size;
|
---|
535 | }
|
---|
536 |
|
---|
537 | uint32_t bytesPerLine() { return mpTex[0]->bytesPerLine(); }
|
---|
538 |
|
---|
539 | const VBoxVHWAColorFormat &pixelFormat() { return mColorFormat; }
|
---|
540 |
|
---|
541 | uint32_t numComponents() {return mcTex;}
|
---|
542 |
|
---|
543 | VBoxVHWATexture* component(uint32_t i) {return mpTex[i]; }
|
---|
544 |
|
---|
545 | const VBoxVHWATextureImage *dst() { return mpDst;}
|
---|
546 | const QRect& dstRect() { return mDstRect; }
|
---|
547 | const QRect& srcRect() { return mSrcRect; }
|
---|
548 | const VBoxVHWAColorKey* dstCKey() { return mpDstCKey; }
|
---|
549 | const VBoxVHWAColorKey* srcCKey() { return mpSrcCKey; }
|
---|
550 | bool notIntersectedMode() { return mbNotIntersected; }
|
---|
551 |
|
---|
552 | static uint32_t calcBytesPerLine(const VBoxVHWAColorFormat & format, int width);
|
---|
553 | static uint32_t calcMemSize(const VBoxVHWAColorFormat & format, int width, int height);
|
---|
554 |
|
---|
555 | #ifdef DEBUG_misha
|
---|
556 | void dbgDump();
|
---|
557 | #endif
|
---|
558 |
|
---|
559 | protected:
|
---|
560 | static int setCKey(class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst);
|
---|
561 |
|
---|
562 | static bool matchCKeys(const VBoxVHWAColorKey * pCKey1, const VBoxVHWAColorKey * pCKey2)
|
---|
563 | {
|
---|
564 | return (pCKey1 == NULL && pCKey2 == NULL)
|
---|
565 | || (*pCKey1 == *pCKey2);
|
---|
566 | }
|
---|
567 |
|
---|
568 | void runDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect)
|
---|
569 | {
|
---|
570 | bind(pDst);
|
---|
571 |
|
---|
572 | draw(pDst, pDstRect, pSrcRect);
|
---|
573 | }
|
---|
574 |
|
---|
575 | virtual void draw(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect);
|
---|
576 |
|
---|
577 | virtual uint32_t texCoord(GLenum tex, int x, int y)
|
---|
578 | {
|
---|
579 | uint32_t c = 1;
|
---|
580 | mpTex[0]->multiTexCoord(tex, x, y);
|
---|
581 | if(mColorFormat.fourcc() == FOURCC_YV12)
|
---|
582 | {
|
---|
583 | int x2 = x/2;
|
---|
584 | int y2 = y/2;
|
---|
585 | mpTex[1]->multiTexCoord(tex + 1, x2, y2);
|
---|
586 | ++c;
|
---|
587 | }
|
---|
588 | return c;
|
---|
589 | }
|
---|
590 |
|
---|
591 | virtual void bind(VBoxVHWATextureImage * pPrimary);
|
---|
592 |
|
---|
593 | virtual uint32_t calcProgramType(VBoxVHWATextureImage *pDst, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected);
|
---|
594 |
|
---|
595 | virtual class VBoxVHWAGlProgramVHWA * calcProgram(VBoxVHWATextureImage *pDst, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected);
|
---|
596 |
|
---|
597 | virtual int createDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect,
|
---|
598 | const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected,
|
---|
599 | GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram);
|
---|
600 |
|
---|
601 | int createSetDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect,
|
---|
602 | const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected);
|
---|
603 |
|
---|
604 | virtual int createDisplayList(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect,
|
---|
605 | const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected,
|
---|
606 | GLuint *pDisplay);
|
---|
607 |
|
---|
608 | virtual void deleteDisplayList();
|
---|
609 |
|
---|
610 | virtual void updateCKeys(VBoxVHWATextureImage * pDst, class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey);
|
---|
611 | virtual void updateSetCKeys(const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey);
|
---|
612 |
|
---|
613 | void internalSetDstCKey(const VBoxVHWAColorKey * pDstCKey);
|
---|
614 | void internalSetSrcCKey(const VBoxVHWAColorKey * pSrcCKey);
|
---|
615 |
|
---|
616 | VBoxVHWATexture *mpTex[3];
|
---|
617 | uint32_t mcTex;
|
---|
618 | GLuint mVisibleDisplay;
|
---|
619 | class VBoxVHWAGlProgramVHWA * mpProgram;
|
---|
620 | class VBoxVHWAGlProgramMngr * mProgramMngr;
|
---|
621 | VBoxVHWAColorFormat mColorFormat;
|
---|
622 |
|
---|
623 | /* display info */
|
---|
624 | VBoxVHWATextureImage *mpDst;
|
---|
625 | QRect mDstRect;
|
---|
626 | QRect mSrcRect;
|
---|
627 | VBoxVHWAColorKey * mpDstCKey;
|
---|
628 | VBoxVHWAColorKey * mpSrcCKey;
|
---|
629 | VBoxVHWAColorKey mDstCKey;
|
---|
630 | VBoxVHWAColorKey mSrcCKey;
|
---|
631 | bool mbNotIntersected;
|
---|
632 | };
|
---|
633 |
|
---|
634 | class VBoxVHWATextureImagePBO : public VBoxVHWATextureImage
|
---|
635 | {
|
---|
636 | public:
|
---|
637 | VBoxVHWATextureImagePBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) :
|
---|
638 | VBoxVHWATextureImage(size, format, aMgr, flags & (~VBOXVHWAIMG_PBO)),
|
---|
639 | mPBO(0)
|
---|
640 | {
|
---|
641 | }
|
---|
642 |
|
---|
643 | virtual ~VBoxVHWATextureImagePBO()
|
---|
644 | {
|
---|
645 | if(mPBO)
|
---|
646 | {
|
---|
647 | VBOXQGL_CHECKERR(
|
---|
648 | vboxglDeleteBuffers(1, &mPBO);
|
---|
649 | );
|
---|
650 | }
|
---|
651 | }
|
---|
652 |
|
---|
653 | virtual void init(uchar *pvMem)
|
---|
654 | {
|
---|
655 | VBoxVHWATextureImage::init(pvMem);
|
---|
656 |
|
---|
657 | VBOXQGL_CHECKERR(
|
---|
658 | vboxglGenBuffers(1, &mPBO);
|
---|
659 | );
|
---|
660 | mAddress = pvMem;
|
---|
661 |
|
---|
662 | VBOXQGL_CHECKERR(
|
---|
663 | vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPBO);
|
---|
664 | );
|
---|
665 |
|
---|
666 | VBOXQGL_CHECKERR(
|
---|
667 | vboxglBufferData(GL_PIXEL_UNPACK_BUFFER, memSize(), NULL, GL_STREAM_DRAW);
|
---|
668 | );
|
---|
669 |
|
---|
670 | GLvoid *buf = vboxglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
---|
671 | Assert(buf);
|
---|
672 | if(buf)
|
---|
673 | {
|
---|
674 | memcpy(buf, mAddress, memSize());
|
---|
675 |
|
---|
676 | bool unmapped = vboxglUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
---|
677 | Assert(unmapped); NOREF(unmapped);
|
---|
678 | }
|
---|
679 |
|
---|
680 | vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
---|
681 |
|
---|
682 | }
|
---|
683 |
|
---|
684 | virtual void update(const QRect * pRect)
|
---|
685 | {
|
---|
686 | VBOXQGL_CHECKERR(
|
---|
687 | vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, mPBO);
|
---|
688 | );
|
---|
689 |
|
---|
690 | GLvoid *buf;
|
---|
691 |
|
---|
692 | VBOXQGL_CHECKERR(
|
---|
693 | buf = vboxglMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
---|
694 | );
|
---|
695 | Assert(buf);
|
---|
696 | if(buf)
|
---|
697 | {
|
---|
698 | #ifdef VBOXVHWADBG_RENDERCHECK
|
---|
699 | uint32_t * pBuf32 = (uint32_t*)buf;
|
---|
700 | uchar * pBuf8 = (uchar*)buf;
|
---|
701 | for(uint32_t i = 0; i < mcTex; i++)
|
---|
702 | {
|
---|
703 | uint32_t dbgSetVal = 0x40404040 * (i+1);
|
---|
704 | for(uint32_t k = 0; k < mpTex[i]->memSize()/sizeof(pBuf32[0]); k++)
|
---|
705 | {
|
---|
706 | pBuf32[k] = dbgSetVal;
|
---|
707 | }
|
---|
708 |
|
---|
709 | pBuf8 += mpTex[i]->memSize();
|
---|
710 | pBuf32 = (uint32_t *)pBuf8;
|
---|
711 | }
|
---|
712 | #else
|
---|
713 | memcpy(buf, mAddress, memSize());
|
---|
714 | #endif
|
---|
715 |
|
---|
716 | bool unmapped;
|
---|
717 | VBOXQGL_CHECKERR(
|
---|
718 | unmapped = vboxglUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
|
---|
719 | );
|
---|
720 |
|
---|
721 | Assert(unmapped); NOREF(unmapped);
|
---|
722 |
|
---|
723 | VBoxVHWATextureImage::setAddress(0);
|
---|
724 |
|
---|
725 | VBoxVHWATextureImage::update(NULL);
|
---|
726 |
|
---|
727 | VBoxVHWATextureImage::setAddress(mAddress);
|
---|
728 |
|
---|
729 | vboxglBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
---|
730 | }
|
---|
731 | else
|
---|
732 | {
|
---|
733 | VBOXQGLLOGREL(("failed to map PBO, trying fallback to non-PBO approach\n"));
|
---|
734 |
|
---|
735 | VBoxVHWATextureImage::setAddress(mAddress);
|
---|
736 |
|
---|
737 | VBoxVHWATextureImage::update(pRect);
|
---|
738 | }
|
---|
739 | }
|
---|
740 |
|
---|
741 | virtual void setAddress(uchar *pvMem)
|
---|
742 | {
|
---|
743 | mAddress = pvMem;
|
---|
744 | }
|
---|
745 | private:
|
---|
746 | GLuint mPBO;
|
---|
747 | uchar* mAddress;
|
---|
748 | };
|
---|
749 |
|
---|
750 | class VBoxVHWAHandleTable
|
---|
751 | {
|
---|
752 | public:
|
---|
753 | VBoxVHWAHandleTable(uint32_t initialSize);
|
---|
754 | ~VBoxVHWAHandleTable();
|
---|
755 | uint32_t put(void * data);
|
---|
756 | bool mapPut(uint32_t h, void * data);
|
---|
757 | void* get(uint32_t h);
|
---|
758 | void* remove(uint32_t h);
|
---|
759 | private:
|
---|
760 | void doPut(uint32_t h, void * data);
|
---|
761 | void doRemove(uint32_t h);
|
---|
762 | void** mTable;
|
---|
763 | uint32_t mcSize;
|
---|
764 | uint32_t mcUsage;
|
---|
765 | uint32_t mCursor;
|
---|
766 | };
|
---|
767 |
|
---|
768 | /* data flow:
|
---|
769 | * I. NON-Yinverted surface:
|
---|
770 | * 1.direct memory update (paint, lock/unlock):
|
---|
771 | * mem->tex->fb
|
---|
772 | * 2.blt
|
---|
773 | * srcTex->invFB->tex->fb
|
---|
774 | * |->mem
|
---|
775 | *
|
---|
776 | * II. Yinverted surface:
|
---|
777 | * 1.direct memory update (paint, lock/unlock):
|
---|
778 | * mem->tex->fb
|
---|
779 | * 2.blt
|
---|
780 | * srcTex->fb->tex
|
---|
781 | * |->mem
|
---|
782 | *
|
---|
783 | * III. flip support:
|
---|
784 | * 1. Yinverted<->NON-YInverted conversion :
|
---|
785 | * mem->tex-(rotate model view, force LAZY complete fb update)->invFB->tex
|
---|
786 | * fb-->| |->mem
|
---|
787 | * */
|
---|
788 | class VBoxVHWASurfaceBase
|
---|
789 | {
|
---|
790 | public:
|
---|
791 | VBoxVHWASurfaceBase (class VBoxVHWAImage *pImage,
|
---|
792 | const QSize & aSize,
|
---|
793 | const QRect & aTargRect,
|
---|
794 | const QRect & aSrcRect,
|
---|
795 | const QRect & aVisTargRect,
|
---|
796 | VBoxVHWAColorFormat & aColorFormat,
|
---|
797 | VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey,
|
---|
798 | VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey,
|
---|
799 | VBOXVHWAIMG_TYPE aImgFlags);
|
---|
800 |
|
---|
801 | virtual ~VBoxVHWASurfaceBase();
|
---|
802 |
|
---|
803 | void init (VBoxVHWASurfaceBase * pPrimary, uchar *pvMem);
|
---|
804 |
|
---|
805 | void uninit();
|
---|
806 |
|
---|
807 | static void globalInit();
|
---|
808 |
|
---|
809 | int lock (const QRect * pRect, uint32_t flags);
|
---|
810 |
|
---|
811 | int unlock();
|
---|
812 |
|
---|
813 | void updatedMem (const QRect * aRect);
|
---|
814 |
|
---|
815 | bool performDisplay (VBoxVHWASurfaceBase *pPrimary, bool bForce);
|
---|
816 |
|
---|
817 | void setRects (const QRect & aTargRect, const QRect & aSrcRect);
|
---|
818 | void setTargRectPosition (const QPoint & aPoint);
|
---|
819 |
|
---|
820 | void updateVisibility (VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect, bool bNotIntersected, bool bForce);
|
---|
821 |
|
---|
822 | static ulong calcBytesPerPixel (GLenum format, GLenum type);
|
---|
823 |
|
---|
824 | static GLsizei makePowerOf2 (GLsizei val);
|
---|
825 |
|
---|
826 | bool addressAlocated() const { return mFreeAddress; }
|
---|
827 | uchar * address() { return mAddress; }
|
---|
828 |
|
---|
829 | ulong memSize();
|
---|
830 |
|
---|
831 | ulong width() const { return mRect.width(); }
|
---|
832 | ulong height() const { return mRect.height(); }
|
---|
833 | const QSize size() const {return mRect.size();}
|
---|
834 |
|
---|
835 | uint32_t fourcc() const {return mImage->pixelFormat().fourcc(); }
|
---|
836 |
|
---|
837 | ulong bitsPerPixel() const { return mImage->pixelFormat().bitsPerPixel(); }
|
---|
838 | ulong bytesPerLine() const { return mImage->bytesPerLine(); }
|
---|
839 |
|
---|
840 | const VBoxVHWAColorKey * dstBltCKey() const { return mpDstBltCKey; }
|
---|
841 | const VBoxVHWAColorKey * srcBltCKey() const { return mpSrcBltCKey; }
|
---|
842 | const VBoxVHWAColorKey * dstOverlayCKey() const { return mpDstOverlayCKey; }
|
---|
843 | const VBoxVHWAColorKey * defaultSrcOverlayCKey() const { return mpDefaultSrcOverlayCKey; }
|
---|
844 | const VBoxVHWAColorKey * defaultDstOverlayCKey() const { return mpDefaultDstOverlayCKey; }
|
---|
845 | const VBoxVHWAColorKey * srcOverlayCKey() const { return mpSrcOverlayCKey; }
|
---|
846 | void resetDefaultSrcOverlayCKey() { mpSrcOverlayCKey = mpDefaultSrcOverlayCKey; }
|
---|
847 | void resetDefaultDstOverlayCKey() { mpDstOverlayCKey = mpDefaultDstOverlayCKey; }
|
---|
848 |
|
---|
849 | void setDstBltCKey (const VBoxVHWAColorKey * ckey)
|
---|
850 | {
|
---|
851 | if(ckey)
|
---|
852 | {
|
---|
853 | mDstBltCKey = *ckey;
|
---|
854 | mpDstBltCKey = &mDstBltCKey;
|
---|
855 | }
|
---|
856 | else
|
---|
857 | {
|
---|
858 | mpDstBltCKey = NULL;
|
---|
859 | }
|
---|
860 | }
|
---|
861 |
|
---|
862 | void setSrcBltCKey (const VBoxVHWAColorKey * ckey)
|
---|
863 | {
|
---|
864 | if(ckey)
|
---|
865 | {
|
---|
866 | mSrcBltCKey = *ckey;
|
---|
867 | mpSrcBltCKey = &mSrcBltCKey;
|
---|
868 | }
|
---|
869 | else
|
---|
870 | {
|
---|
871 | mpSrcBltCKey = NULL;
|
---|
872 | }
|
---|
873 | }
|
---|
874 |
|
---|
875 | void setDefaultDstOverlayCKey (const VBoxVHWAColorKey * ckey)
|
---|
876 | {
|
---|
877 | if(ckey)
|
---|
878 | {
|
---|
879 | mDefaultDstOverlayCKey = *ckey;
|
---|
880 | mpDefaultDstOverlayCKey = &mDefaultDstOverlayCKey;
|
---|
881 | }
|
---|
882 | else
|
---|
883 | {
|
---|
884 | mpDefaultDstOverlayCKey = NULL;
|
---|
885 | }
|
---|
886 | }
|
---|
887 |
|
---|
888 | void setDefaultSrcOverlayCKey (const VBoxVHWAColorKey * ckey)
|
---|
889 | {
|
---|
890 | if(ckey)
|
---|
891 | {
|
---|
892 | mDefaultSrcOverlayCKey = *ckey;
|
---|
893 | mpDefaultSrcOverlayCKey = &mDefaultSrcOverlayCKey;
|
---|
894 | }
|
---|
895 | else
|
---|
896 | {
|
---|
897 | mpDefaultSrcOverlayCKey = NULL;
|
---|
898 | }
|
---|
899 | }
|
---|
900 |
|
---|
901 | void setOverriddenDstOverlayCKey (const VBoxVHWAColorKey * ckey)
|
---|
902 | {
|
---|
903 | if(ckey)
|
---|
904 | {
|
---|
905 | mOverriddenDstOverlayCKey = *ckey;
|
---|
906 | mpDstOverlayCKey = &mOverriddenDstOverlayCKey;
|
---|
907 | }
|
---|
908 | else
|
---|
909 | {
|
---|
910 | mpDstOverlayCKey = NULL;
|
---|
911 | }
|
---|
912 | }
|
---|
913 |
|
---|
914 | void setOverriddenSrcOverlayCKey (const VBoxVHWAColorKey * ckey)
|
---|
915 | {
|
---|
916 | if(ckey)
|
---|
917 | {
|
---|
918 | mOverriddenSrcOverlayCKey = *ckey;
|
---|
919 | mpSrcOverlayCKey = &mOverriddenSrcOverlayCKey;
|
---|
920 | }
|
---|
921 | else
|
---|
922 | {
|
---|
923 | mpSrcOverlayCKey = NULL;
|
---|
924 | }
|
---|
925 | }
|
---|
926 |
|
---|
927 | const VBoxVHWAColorKey * getActiveSrcOverlayCKey()
|
---|
928 | {
|
---|
929 | return mpSrcOverlayCKey;
|
---|
930 | }
|
---|
931 |
|
---|
932 | const VBoxVHWAColorKey * getActiveDstOverlayCKey (VBoxVHWASurfaceBase * pPrimary)
|
---|
933 | {
|
---|
934 | return mpDstOverlayCKey ? mpDefaultDstOverlayCKey : (pPrimary ? pPrimary->mpDstOverlayCKey : NULL);
|
---|
935 | }
|
---|
936 |
|
---|
937 | const VBoxVHWAColorFormat & pixelFormat() const { return mImage->pixelFormat(); }
|
---|
938 |
|
---|
939 | void setAddress(uchar * addr);
|
---|
940 |
|
---|
941 | const QRect& rect() const {return mRect;}
|
---|
942 | const QRect& srcRect() const {return mSrcRect; }
|
---|
943 | const QRect& targRect() const {return mTargRect; }
|
---|
944 | class VBoxVHWASurfList * getComplexList() {return mComplexList; }
|
---|
945 |
|
---|
946 | class VBoxVHWAGlProgramMngr * getGlProgramMngr();
|
---|
947 |
|
---|
948 | uint32_t handle() const {return mHGHandle;}
|
---|
949 | void setHandle(uint32_t h) {mHGHandle = h;}
|
---|
950 |
|
---|
951 | const VBoxVHWADirtyRect & getDirtyRect() { return mUpdateMem2TexRect; }
|
---|
952 |
|
---|
953 | VBoxVHWASurfaceBase * primary() { return mpPrimary; }
|
---|
954 | void setPrimary(VBoxVHWASurfaceBase *apPrimary) { mpPrimary = apPrimary; }
|
---|
955 | private:
|
---|
956 | void setRectValues (const QRect & aTargRect, const QRect & aSrcRect);
|
---|
957 | void setVisibleRectValues (const QRect & aVisTargRect);
|
---|
958 |
|
---|
959 | void setComplexList (VBoxVHWASurfList *aComplexList) { mComplexList = aComplexList; }
|
---|
960 | void initDisplay();
|
---|
961 |
|
---|
962 | bool synchTexMem (const QRect * aRect);
|
---|
963 |
|
---|
964 | int performBlt (const QRect * pDstRect, VBoxVHWASurfaceBase * pSrcSurface, const QRect * pSrcRect, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool blt);
|
---|
965 |
|
---|
966 | QRect mRect; /* == Inv FB size */
|
---|
967 |
|
---|
968 | QRect mSrcRect;
|
---|
969 | QRect mTargRect; /* == Vis FB size */
|
---|
970 |
|
---|
971 | QRect mVisibleTargRect;
|
---|
972 | QRect mVisibleSrcRect;
|
---|
973 |
|
---|
974 | class VBoxVHWATextureImage * mImage;
|
---|
975 |
|
---|
976 | uchar * mAddress;
|
---|
977 |
|
---|
978 | VBoxVHWAColorKey *mpSrcBltCKey;
|
---|
979 | VBoxVHWAColorKey *mpDstBltCKey;
|
---|
980 | VBoxVHWAColorKey *mpSrcOverlayCKey;
|
---|
981 | VBoxVHWAColorKey *mpDstOverlayCKey;
|
---|
982 |
|
---|
983 | VBoxVHWAColorKey *mpDefaultDstOverlayCKey;
|
---|
984 | VBoxVHWAColorKey *mpDefaultSrcOverlayCKey;
|
---|
985 |
|
---|
986 | VBoxVHWAColorKey mSrcBltCKey;
|
---|
987 | VBoxVHWAColorKey mDstBltCKey;
|
---|
988 | VBoxVHWAColorKey mOverriddenSrcOverlayCKey;
|
---|
989 | VBoxVHWAColorKey mOverriddenDstOverlayCKey;
|
---|
990 | VBoxVHWAColorKey mDefaultDstOverlayCKey;
|
---|
991 | VBoxVHWAColorKey mDefaultSrcOverlayCKey;
|
---|
992 |
|
---|
993 | int mLockCount;
|
---|
994 | /* memory buffer not reflected in fm and texture, e.g if memory buffer is replaced or in case of lock/unlock */
|
---|
995 | VBoxVHWADirtyRect mUpdateMem2TexRect;
|
---|
996 |
|
---|
997 | bool mFreeAddress;
|
---|
998 | bool mbNotIntersected;
|
---|
999 |
|
---|
1000 | class VBoxVHWASurfList *mComplexList;
|
---|
1001 |
|
---|
1002 | VBoxVHWASurfaceBase *mpPrimary;
|
---|
1003 |
|
---|
1004 | uint32_t mHGHandle;
|
---|
1005 |
|
---|
1006 | class VBoxVHWAImage *mpImage;
|
---|
1007 |
|
---|
1008 | #ifdef DEBUG
|
---|
1009 | public:
|
---|
1010 | uint64_t cFlipsCurr;
|
---|
1011 | uint64_t cFlipsTarg;
|
---|
1012 | #endif
|
---|
1013 | friend class VBoxVHWASurfList;
|
---|
1014 | };
|
---|
1015 |
|
---|
1016 | typedef std::list <VBoxVHWASurfaceBase*> SurfList;
|
---|
1017 | typedef std::list <VBoxVHWASurfList*> OverlayList;
|
---|
1018 | typedef std::list <struct VBOXVHWACMD *> VHWACommandList;
|
---|
1019 |
|
---|
1020 | class VBoxVHWASurfList
|
---|
1021 | {
|
---|
1022 | public:
|
---|
1023 |
|
---|
1024 | VBoxVHWASurfList() : mCurrent(NULL) {}
|
---|
1025 |
|
---|
1026 | void moveTo(VBoxVHWASurfList *pDst)
|
---|
1027 | {
|
---|
1028 | for (SurfList::iterator it = mSurfaces.begin();
|
---|
1029 | it != mSurfaces.end(); it = mSurfaces.begin())
|
---|
1030 | {
|
---|
1031 | pDst->add((*it));
|
---|
1032 | }
|
---|
1033 |
|
---|
1034 | Assert(empty());
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | void add(VBoxVHWASurfaceBase *pSurf)
|
---|
1038 | {
|
---|
1039 | VBoxVHWASurfList * pOld = pSurf->getComplexList();
|
---|
1040 | if(pOld)
|
---|
1041 | {
|
---|
1042 | pOld->remove(pSurf);
|
---|
1043 | }
|
---|
1044 | mSurfaces.push_back(pSurf);
|
---|
1045 | pSurf->setComplexList(this);
|
---|
1046 | }
|
---|
1047 | /*
|
---|
1048 | void clear()
|
---|
1049 | {
|
---|
1050 | for (SurfList::iterator it = mSurfaces.begin();
|
---|
1051 | it != mSurfaces.end(); ++ it)
|
---|
1052 | {
|
---|
1053 | (*it)->setComplexList(NULL);
|
---|
1054 | }
|
---|
1055 | mSurfaces.clear();
|
---|
1056 | mCurrent = NULL;
|
---|
1057 | }
|
---|
1058 | */
|
---|
1059 | size_t size() const {return mSurfaces.size(); }
|
---|
1060 |
|
---|
1061 | void remove(VBoxVHWASurfaceBase *pSurf)
|
---|
1062 | {
|
---|
1063 | mSurfaces.remove(pSurf);
|
---|
1064 | pSurf->setComplexList(NULL);
|
---|
1065 | if(mCurrent == pSurf)
|
---|
1066 | mCurrent = NULL;
|
---|
1067 | }
|
---|
1068 |
|
---|
1069 | bool empty() { return mSurfaces.empty(); }
|
---|
1070 |
|
---|
1071 | void setCurrentVisible(VBoxVHWASurfaceBase *pSurf)
|
---|
1072 | {
|
---|
1073 | mCurrent = pSurf;
|
---|
1074 | }
|
---|
1075 |
|
---|
1076 | VBoxVHWASurfaceBase * current() { return mCurrent; }
|
---|
1077 | const SurfList & surfaces() const {return mSurfaces;}
|
---|
1078 |
|
---|
1079 | private:
|
---|
1080 |
|
---|
1081 | SurfList mSurfaces;
|
---|
1082 | VBoxVHWASurfaceBase* mCurrent;
|
---|
1083 | };
|
---|
1084 |
|
---|
1085 | class VBoxVHWADisplay
|
---|
1086 | {
|
---|
1087 | public:
|
---|
1088 | VBoxVHWADisplay() :
|
---|
1089 | mSurfVGA(NULL),
|
---|
1090 | mbDisplayPrimary(true)
|
---|
1091 | // ,
|
---|
1092 | // mSurfPrimary(NULL)
|
---|
1093 | {}
|
---|
1094 |
|
---|
1095 | VBoxVHWASurfaceBase * setVGA(VBoxVHWASurfaceBase * pVga)
|
---|
1096 | {
|
---|
1097 | VBoxVHWASurfaceBase * old = mSurfVGA;
|
---|
1098 | mSurfVGA = pVga;
|
---|
1099 | if (!mPrimary.empty())
|
---|
1100 | {
|
---|
1101 | VBoxVHWASurfList *pNewList = new VBoxVHWASurfList();
|
---|
1102 | mPrimary.moveTo(pNewList);
|
---|
1103 | Assert(mPrimary.empty());
|
---|
1104 | }
|
---|
1105 | if(pVga)
|
---|
1106 | {
|
---|
1107 | Assert(!pVga->getComplexList());
|
---|
1108 | mPrimary.add(pVga);
|
---|
1109 | mPrimary.setCurrentVisible(pVga);
|
---|
1110 | }
|
---|
1111 | mOverlays.clear();
|
---|
1112 | return old;
|
---|
1113 | }
|
---|
1114 |
|
---|
1115 | VBoxVHWASurfaceBase * updateVGA(VBoxVHWASurfaceBase * pVga)
|
---|
1116 | {
|
---|
1117 | VBoxVHWASurfaceBase * old = mSurfVGA;
|
---|
1118 | Assert(old);
|
---|
1119 | mSurfVGA = pVga;
|
---|
1120 | return old;
|
---|
1121 | }
|
---|
1122 |
|
---|
1123 | VBoxVHWASurfaceBase * getVGA() const
|
---|
1124 | {
|
---|
1125 | return mSurfVGA;
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | VBoxVHWASurfaceBase * getPrimary()
|
---|
1129 | {
|
---|
1130 | return mPrimary.current();
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | void addOverlay(VBoxVHWASurfList * pSurf)
|
---|
1134 | {
|
---|
1135 | mOverlays.push_back(pSurf);
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | void checkAddOverlay(VBoxVHWASurfList * pSurf)
|
---|
1139 | {
|
---|
1140 | if(!hasOverlay(pSurf))
|
---|
1141 | addOverlay(pSurf);
|
---|
1142 | }
|
---|
1143 |
|
---|
1144 | bool hasOverlay(VBoxVHWASurfList * pSurf)
|
---|
1145 | {
|
---|
1146 | for (OverlayList::iterator it = mOverlays.begin();
|
---|
1147 | it != mOverlays.end(); ++ it)
|
---|
1148 | {
|
---|
1149 | if((*it) == pSurf)
|
---|
1150 | {
|
---|
1151 | return true;
|
---|
1152 | }
|
---|
1153 | }
|
---|
1154 | return false;
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 | void removeOverlay(VBoxVHWASurfList * pSurf)
|
---|
1158 | {
|
---|
1159 | mOverlays.remove(pSurf);
|
---|
1160 | }
|
---|
1161 |
|
---|
1162 | bool performDisplay(bool bForce)
|
---|
1163 | {
|
---|
1164 | VBoxVHWASurfaceBase * pPrimary = mPrimary.current();
|
---|
1165 |
|
---|
1166 | if(mbDisplayPrimary)
|
---|
1167 | {
|
---|
1168 | #ifdef DEBUG_misha
|
---|
1169 | /* should only display overlay now */
|
---|
1170 | AssertBreakpoint();
|
---|
1171 | #endif
|
---|
1172 | bForce |= pPrimary->performDisplay(NULL, bForce);
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 | for (OverlayList::const_iterator it = mOverlays.begin();
|
---|
1176 | it != mOverlays.end(); ++ it)
|
---|
1177 | {
|
---|
1178 | VBoxVHWASurfaceBase * pOverlay = (*it)->current();
|
---|
1179 | if(pOverlay)
|
---|
1180 | {
|
---|
1181 | bForce |= pOverlay->performDisplay(pPrimary, bForce);
|
---|
1182 | }
|
---|
1183 | }
|
---|
1184 | return bForce;
|
---|
1185 | }
|
---|
1186 |
|
---|
1187 | bool isPrimary(VBoxVHWASurfaceBase * pSurf) { return pSurf->getComplexList() == &mPrimary; }
|
---|
1188 |
|
---|
1189 | void setDisplayPrimary(bool bDisplay) { mbDisplayPrimary = bDisplay; }
|
---|
1190 |
|
---|
1191 | const OverlayList & overlays() const {return mOverlays;}
|
---|
1192 | const VBoxVHWASurfList & primaries() const { return mPrimary; }
|
---|
1193 |
|
---|
1194 | private:
|
---|
1195 | VBoxVHWASurfaceBase *mSurfVGA;
|
---|
1196 | VBoxVHWASurfList mPrimary;
|
---|
1197 |
|
---|
1198 | OverlayList mOverlays;
|
---|
1199 |
|
---|
1200 | bool mbDisplayPrimary;
|
---|
1201 | };
|
---|
1202 |
|
---|
1203 | typedef void (*PFNVBOXQGLFUNC)(void*, void*);
|
---|
1204 |
|
---|
1205 | typedef enum
|
---|
1206 | {
|
---|
1207 | VBOXVHWA_PIPECMD_PAINT = 1,
|
---|
1208 | VBOXVHWA_PIPECMD_VHWA,
|
---|
1209 | VBOXVHWA_PIPECMD_FUNC
|
---|
1210 | }VBOXVHWA_PIPECMD_TYPE;
|
---|
1211 |
|
---|
1212 | typedef struct VBOXVHWAFUNCCALLBACKINFO
|
---|
1213 | {
|
---|
1214 | PFNVBOXQGLFUNC pfnCallback;
|
---|
1215 | void * pContext1;
|
---|
1216 | void * pContext2;
|
---|
1217 | }VBOXVHWAFUNCCALLBACKINFO;
|
---|
1218 |
|
---|
1219 | class VBoxVHWACommandElement
|
---|
1220 | {
|
---|
1221 | public:
|
---|
1222 | void setVHWACmd(struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCmd, int enmCmd, bool fGuestCmd)
|
---|
1223 | {
|
---|
1224 | mType = VBOXVHWA_PIPECMD_VHWA;
|
---|
1225 | u.s.mpCmd = pCmd;
|
---|
1226 | u.s.menmCmd = enmCmd;
|
---|
1227 | u.s.mfGuestCmd = fGuestCmd;
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 | void setPaintCmd(const QRect & aRect)
|
---|
1231 | {
|
---|
1232 | mType = VBOXVHWA_PIPECMD_PAINT;
|
---|
1233 | mRect = aRect;
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 | void setFunc(const VBOXVHWAFUNCCALLBACKINFO & aOp)
|
---|
1237 | {
|
---|
1238 | mType = VBOXVHWA_PIPECMD_FUNC;
|
---|
1239 | u.mFuncCallback = aOp;
|
---|
1240 | }
|
---|
1241 |
|
---|
1242 | void setData(VBOXVHWA_PIPECMD_TYPE aType, void *pvData, int /*VBOXVHWACMD_TYPE*/ enmCmd, bool fGuestCmd = false)
|
---|
1243 | {
|
---|
1244 | switch (aType)
|
---|
1245 | {
|
---|
1246 | case VBOXVHWA_PIPECMD_PAINT:
|
---|
1247 | setPaintCmd(*((QRect *)pvData));
|
---|
1248 | break;
|
---|
1249 | case VBOXVHWA_PIPECMD_VHWA:
|
---|
1250 | setVHWACmd((struct VBOXVHWACMD *)pvData, enmCmd, fGuestCmd);
|
---|
1251 | break;
|
---|
1252 | case VBOXVHWA_PIPECMD_FUNC:
|
---|
1253 | setFunc(*((VBOXVHWAFUNCCALLBACKINFO *)pvData));
|
---|
1254 | break;
|
---|
1255 | default:
|
---|
1256 | AssertFailed();
|
---|
1257 | mType = (VBOXVHWA_PIPECMD_TYPE)0;
|
---|
1258 | break;
|
---|
1259 | }
|
---|
1260 | }
|
---|
1261 |
|
---|
1262 | VBOXVHWA_PIPECMD_TYPE type() const {return mType;}
|
---|
1263 | const QRect & rect() const {return mRect;}
|
---|
1264 | struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *vhwaCmdPtr() const { return u.s.mpCmd; }
|
---|
1265 | int /*VBOXVHWACMD_TYPE*/ vhwaCmdType() const { return u.s.menmCmd; }
|
---|
1266 | bool vhwaIsGuestCmd() const { return u.s.mfGuestCmd; }
|
---|
1267 | const VBOXVHWAFUNCCALLBACKINFO & func() const {return u.mFuncCallback; }
|
---|
1268 |
|
---|
1269 | RTLISTNODE ListNode;
|
---|
1270 | private:
|
---|
1271 | VBOXVHWA_PIPECMD_TYPE mType;
|
---|
1272 | union
|
---|
1273 | {
|
---|
1274 | struct
|
---|
1275 | {
|
---|
1276 | struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *mpCmd;
|
---|
1277 | int /*VBOXVHWACMD_TYPE*/ menmCmd;
|
---|
1278 | bool mfGuestCmd;
|
---|
1279 | } s;
|
---|
1280 | VBOXVHWAFUNCCALLBACKINFO mFuncCallback;
|
---|
1281 | } u;
|
---|
1282 | QRect mRect;
|
---|
1283 | };
|
---|
1284 |
|
---|
1285 | class VBoxVHWARefCounter
|
---|
1286 | {
|
---|
1287 | #define VBOXVHWA_INIFITE_WAITCOUNT (~0U)
|
---|
1288 | public:
|
---|
1289 | VBoxVHWARefCounter() : m_cRefs(0) {}
|
---|
1290 | VBoxVHWARefCounter(uint32_t cRefs) : m_cRefs(cRefs) {}
|
---|
1291 | void inc() { ASMAtomicIncU32(&m_cRefs); }
|
---|
1292 | uint32_t dec()
|
---|
1293 | {
|
---|
1294 | uint32_t cRefs = ASMAtomicDecU32(&m_cRefs);
|
---|
1295 | Assert(cRefs < UINT32_MAX / 2);
|
---|
1296 | return cRefs;
|
---|
1297 | }
|
---|
1298 |
|
---|
1299 | uint32_t refs() { return ASMAtomicReadU32(&m_cRefs); }
|
---|
1300 |
|
---|
1301 | int wait0(RTMSINTERVAL ms = 1000, uint32_t cWaits = VBOXVHWA_INIFITE_WAITCOUNT)
|
---|
1302 | {
|
---|
1303 | int rc = VINF_SUCCESS;
|
---|
1304 | do
|
---|
1305 | {
|
---|
1306 | if (!refs())
|
---|
1307 | break;
|
---|
1308 | if (!cWaits)
|
---|
1309 | {
|
---|
1310 | rc = VERR_TIMEOUT;
|
---|
1311 | break;
|
---|
1312 | }
|
---|
1313 | if (cWaits != VBOXVHWA_INIFITE_WAITCOUNT)
|
---|
1314 | --cWaits;
|
---|
1315 | rc = RTThreadSleep(ms);
|
---|
1316 | AssertRC(rc);
|
---|
1317 | if (!RT_SUCCESS(rc))
|
---|
1318 | break;
|
---|
1319 | } while(1);
|
---|
1320 | return rc;
|
---|
1321 | }
|
---|
1322 | private:
|
---|
1323 | volatile uint32_t m_cRefs;
|
---|
1324 | };
|
---|
1325 |
|
---|
1326 | class VBoxVHWAEntriesCache;
|
---|
1327 | class VBoxVHWACommandElementProcessor
|
---|
1328 | {
|
---|
1329 | public:
|
---|
1330 | VBoxVHWACommandElementProcessor();
|
---|
1331 | void init(QObject *pNotifyObject);
|
---|
1332 | ~VBoxVHWACommandElementProcessor();
|
---|
1333 | void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void *pvData, int /*VBOXVHWACMD_TYPE*/ enmCmdInt, bool fGuestCmd);
|
---|
1334 | VBoxVHWACommandElement *getCmd();
|
---|
1335 | void doneCmd();
|
---|
1336 | void reset(CDisplay *pDisplay);
|
---|
1337 | void setNotifyObject(QObject *pNotifyObject);
|
---|
1338 | int loadExec (struct SSMHANDLE * pSSM, uint32_t u32Version, void *pvVRAM);
|
---|
1339 | void saveExec (struct SSMHANDLE * pSSM, void *pvVRAM);
|
---|
1340 | void disable();
|
---|
1341 | void enable();
|
---|
1342 | void lock();
|
---|
1343 | void unlock();
|
---|
1344 | private:
|
---|
1345 | RTCRITSECT mCritSect;
|
---|
1346 | RTLISTNODE mCommandList;
|
---|
1347 | QObject *m_pNotifyObject;
|
---|
1348 | VBoxVHWARefCounter m_NotifyObjectRefs;
|
---|
1349 | VBoxVHWACommandElement *mpCurCmd;
|
---|
1350 | bool mbResetting;
|
---|
1351 | uint32_t mcDisabled;
|
---|
1352 | VBoxVHWAEntriesCache *m_pCmdEntryCache;
|
---|
1353 | };
|
---|
1354 |
|
---|
1355 | /* added to workaround this ** [VBox|UI] duplication */
|
---|
1356 | class VBoxFBSizeInfo
|
---|
1357 | {
|
---|
1358 | public:
|
---|
1359 |
|
---|
1360 | VBoxFBSizeInfo() {}
|
---|
1361 | template<class T> VBoxFBSizeInfo(T *pFb) :
|
---|
1362 | m_visualState(pFb->visualState()),
|
---|
1363 | mPixelFormat(pFb->pixelFormat()), mVRAM(pFb->address()), mBitsPerPixel(pFb->bitsPerPixel()),
|
---|
1364 | mBytesPerLine(pFb->bytesPerLine()), mWidth(pFb->width()), mHeight(pFb->height()),
|
---|
1365 | m_dScaleFactor(pFb->scaleFactor()), m_scaledSize(pFb->scaledSize()), m_fUseUnscaledHiDPIOutput(pFb->useUnscaledHiDPIOutput()),
|
---|
1366 | mUsesGuestVram(true) {}
|
---|
1367 |
|
---|
1368 | VBoxFBSizeInfo(UIVisualStateType visualState,
|
---|
1369 | ulong aPixelFormat, uchar *aVRAM,
|
---|
1370 | ulong aBitsPerPixel, ulong aBytesPerLine,
|
---|
1371 | ulong aWidth, ulong aHeight,
|
---|
1372 | double dScaleFactor, const QSize &scaledSize, bool fUseUnscaledHiDPIOutput,
|
---|
1373 | bool bUsesGuestVram) :
|
---|
1374 | m_visualState(visualState),
|
---|
1375 | mPixelFormat(aPixelFormat), mVRAM(aVRAM), mBitsPerPixel(aBitsPerPixel),
|
---|
1376 | mBytesPerLine(aBytesPerLine), mWidth(aWidth), mHeight(aHeight),
|
---|
1377 | m_dScaleFactor(dScaleFactor), m_scaledSize(scaledSize), m_fUseUnscaledHiDPIOutput(fUseUnscaledHiDPIOutput),
|
---|
1378 | mUsesGuestVram(bUsesGuestVram) {}
|
---|
1379 |
|
---|
1380 | UIVisualStateType visualState() const { return m_visualState; }
|
---|
1381 | ulong pixelFormat() const { return mPixelFormat; }
|
---|
1382 | uchar *VRAM() const { return mVRAM; }
|
---|
1383 | ulong bitsPerPixel() const { return mBitsPerPixel; }
|
---|
1384 | ulong bytesPerLine() const { return mBytesPerLine; }
|
---|
1385 | ulong width() const { return mWidth; }
|
---|
1386 | ulong height() const { return mHeight; }
|
---|
1387 | double scaleFactor() const { return m_dScaleFactor; }
|
---|
1388 | QSize scaledSize() const { return m_scaledSize; }
|
---|
1389 | bool useUnscaledHiDPIOutput() const { return m_fUseUnscaledHiDPIOutput; }
|
---|
1390 | bool usesGuestVram() const {return mUsesGuestVram;}
|
---|
1391 |
|
---|
1392 | private:
|
---|
1393 |
|
---|
1394 | UIVisualStateType m_visualState;
|
---|
1395 | ulong mPixelFormat;
|
---|
1396 | uchar *mVRAM;
|
---|
1397 | ulong mBitsPerPixel;
|
---|
1398 | ulong mBytesPerLine;
|
---|
1399 | ulong mWidth;
|
---|
1400 | ulong mHeight;
|
---|
1401 | double m_dScaleFactor;
|
---|
1402 | QSize m_scaledSize;
|
---|
1403 | bool m_fUseUnscaledHiDPIOutput;
|
---|
1404 | bool mUsesGuestVram;
|
---|
1405 | };
|
---|
1406 |
|
---|
1407 | class VBoxVHWAImage
|
---|
1408 | {
|
---|
1409 | public:
|
---|
1410 | VBoxVHWAImage ();
|
---|
1411 | ~VBoxVHWAImage();
|
---|
1412 |
|
---|
1413 | int init(VBoxVHWASettings *aSettings);
|
---|
1414 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
1415 | uchar *vboxVRAMAddressFromOffset(uint64_t offset);
|
---|
1416 | uint64_t vboxVRAMOffsetFromAddress(uchar* addr);
|
---|
1417 | uint64_t vboxVRAMOffset(VBoxVHWASurfaceBase * pSurf);
|
---|
1418 |
|
---|
1419 | void vhwaSaveExec(struct SSMHANDLE * pSSM);
|
---|
1420 | static void vhwaSaveExecVoid(struct SSMHANDLE * pSSM);
|
---|
1421 | static int vhwaLoadExec(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
|
---|
1422 |
|
---|
1423 | int vhwaSurfaceCanCreate(struct VBOXVHWACMD_SURF_CANCREATE RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1424 | int vhwaSurfaceCreate(struct VBOXVHWACMD_SURF_CREATE RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1425 | #ifdef VBOX_WITH_WDDM
|
---|
1426 | int vhwaSurfaceGetInfo(struct VBOXVHWACMD_SURF_GETINFO RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1427 | #endif
|
---|
1428 | int vhwaSurfaceDestroy(struct VBOXVHWACMD_SURF_DESTROY RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1429 | int vhwaSurfaceLock(struct VBOXVHWACMD_SURF_LOCK RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1430 | int vhwaSurfaceUnlock(struct VBOXVHWACMD_SURF_UNLOCK RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1431 | int vhwaSurfaceBlt(struct VBOXVHWACMD_SURF_BLT RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1432 | int vhwaSurfaceFlip(struct VBOXVHWACMD_SURF_FLIP RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1433 | int vhwaSurfaceColorFill(struct VBOXVHWACMD_SURF_COLORFILL RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1434 | int vhwaSurfaceOverlayUpdate(struct VBOXVHWACMD_SURF_OVERLAY_UPDATE RT_UNTRUSTED_VOLATILE_GUEST *pCmf);
|
---|
1435 | int vhwaSurfaceOverlaySetPosition(struct VBOXVHWACMD_SURF_OVERLAY_SETPOSITION RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1436 | int vhwaSurfaceColorkeySet(struct VBOXVHWACMD_SURF_COLORKEY_SET RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1437 | int vhwaQueryInfo1(struct VBOXVHWACMD_QUERYINFO1 RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1438 | int vhwaQueryInfo2(struct VBOXVHWACMD_QUERYINFO2 RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1439 | int vhwaConstruct(struct VBOXVHWACMD_HH_CONSTRUCT *pCmd);
|
---|
1440 |
|
---|
1441 | void *vramBase() { return mpvVRAM; }
|
---|
1442 | uint32_t vramSize() { return mcbVRAM; }
|
---|
1443 |
|
---|
1444 | bool hasSurfaces() const;
|
---|
1445 | bool hasVisibleOverlays();
|
---|
1446 | QRect overlaysRectUnion();
|
---|
1447 | QRect overlaysRectIntersection();
|
---|
1448 | #endif
|
---|
1449 |
|
---|
1450 | static const QGLFormat & vboxGLFormat();
|
---|
1451 |
|
---|
1452 | int reset(VHWACommandList * pCmdList);
|
---|
1453 |
|
---|
1454 | int vboxFbWidth() {return mDisplay.getVGA()->width(); }
|
---|
1455 | int vboxFbHeight() {return mDisplay.getVGA()->height(); }
|
---|
1456 | bool isInitialized() {return mDisplay.getVGA() != NULL; }
|
---|
1457 |
|
---|
1458 | void resize(const VBoxFBSizeInfo & size);
|
---|
1459 |
|
---|
1460 | class VBoxVHWAGlProgramMngr * vboxVHWAGetGlProgramMngr() { return mpMngr; }
|
---|
1461 |
|
---|
1462 | VBoxVHWASurfaceBase * vgaSurface() { return mDisplay.getVGA(); }
|
---|
1463 |
|
---|
1464 | #ifdef VBOXVHWA_OLD_COORD
|
---|
1465 | static void doSetupMatrix(const QSize & aSize, bool bInverted);
|
---|
1466 | #endif
|
---|
1467 |
|
---|
1468 | void vboxDoUpdateViewport(const QRect & aRect);
|
---|
1469 | void vboxDoUpdateRect(const QRect * pRect);
|
---|
1470 |
|
---|
1471 | const QRect & vboxViewport() const {return mViewport;}
|
---|
1472 |
|
---|
1473 | #ifdef VBOXVHWA_PROFILE_FPS
|
---|
1474 | void reportNewFrame() { mbNewFrame = true; }
|
---|
1475 | #endif
|
---|
1476 |
|
---|
1477 | bool performDisplay(bool bForce)
|
---|
1478 | {
|
---|
1479 | bForce = mDisplay.performDisplay(bForce | mRepaintNeeded);
|
---|
1480 |
|
---|
1481 | #ifdef VBOXVHWA_PROFILE_FPS
|
---|
1482 | if(mbNewFrame)
|
---|
1483 | {
|
---|
1484 | mFPSCounter.frame();
|
---|
1485 | double fps = mFPSCounter.fps();
|
---|
1486 | if(!(mFPSCounter.frames() % 31))
|
---|
1487 | {
|
---|
1488 | LogRel(("fps: %f\n", fps));
|
---|
1489 | }
|
---|
1490 | mbNewFrame = false;
|
---|
1491 | }
|
---|
1492 | #endif
|
---|
1493 | return bForce;
|
---|
1494 | }
|
---|
1495 |
|
---|
1496 | static void pushSettingsAndSetupViewport(const QSize &display, const QRect &viewport)
|
---|
1497 | {
|
---|
1498 | glPushAttrib(GL_ALL_ATTRIB_BITS);
|
---|
1499 | glMatrixMode(GL_PROJECTION);
|
---|
1500 | glPushMatrix();
|
---|
1501 | setupMatricies(display, false);
|
---|
1502 | adjustViewport(display, viewport);
|
---|
1503 | }
|
---|
1504 |
|
---|
1505 | static void popSettingsAfterSetupViewport()
|
---|
1506 | {
|
---|
1507 | glPopAttrib();
|
---|
1508 | glMatrixMode(GL_PROJECTION);
|
---|
1509 | glPopMatrix();
|
---|
1510 | glMatrixMode(GL_MODELVIEW);
|
---|
1511 | }
|
---|
1512 |
|
---|
1513 | private:
|
---|
1514 | static void setupMatricies(const QSize &display, bool bInvert);
|
---|
1515 | static void adjustViewport(const QSize &display, const QRect &viewport);
|
---|
1516 |
|
---|
1517 |
|
---|
1518 | #ifdef VBOXQGL_DBG_SURF
|
---|
1519 | void vboxDoTestSurfaces(void *context);
|
---|
1520 | #endif
|
---|
1521 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
1522 |
|
---|
1523 | void vboxCheckUpdateAddress(VBoxVHWASurfaceBase * pSurface, uint64_t offset)
|
---|
1524 | {
|
---|
1525 | if (pSurface->addressAlocated())
|
---|
1526 | {
|
---|
1527 | Assert(!mDisplay.isPrimary(pSurface));
|
---|
1528 | uchar * addr = vboxVRAMAddressFromOffset(offset);
|
---|
1529 | if (addr)
|
---|
1530 | {
|
---|
1531 | pSurface->setAddress(addr);
|
---|
1532 | }
|
---|
1533 | }
|
---|
1534 | }
|
---|
1535 |
|
---|
1536 | int vhwaSaveSurface(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps);
|
---|
1537 | static int vhwaLoadSurface(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t cBackBuffers, uint32_t u32Version);
|
---|
1538 | int vhwaSaveOverlayData(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, bool bVisible);
|
---|
1539 | static int vhwaLoadOverlayData(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
|
---|
1540 | static int vhwaLoadVHWAEnable(VHWACommandList * pCmdList);
|
---|
1541 |
|
---|
1542 | void vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf,
|
---|
1543 | struct VBOXVHWACMD_SURF_OVERLAY_UPDATE RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1544 | #endif
|
---|
1545 |
|
---|
1546 | VBoxVHWADisplay mDisplay;
|
---|
1547 |
|
---|
1548 | VBoxVHWASurfaceBase* handle2Surface(uint32_t h)
|
---|
1549 | {
|
---|
1550 | VBoxVHWASurfaceBase* pSurf = (VBoxVHWASurfaceBase*)mSurfHandleTable.get(h);
|
---|
1551 | Assert(pSurf);
|
---|
1552 | return pSurf;
|
---|
1553 | }
|
---|
1554 |
|
---|
1555 | VBoxVHWAHandleTable mSurfHandleTable;
|
---|
1556 |
|
---|
1557 | bool mRepaintNeeded;
|
---|
1558 |
|
---|
1559 | QRect mViewport;
|
---|
1560 |
|
---|
1561 | VBoxVHWASurfList *mConstructingList;
|
---|
1562 | int32_t mcRemaining2Contruct;
|
---|
1563 |
|
---|
1564 | class VBoxVHWAGlProgramMngr *mpMngr;
|
---|
1565 |
|
---|
1566 | VBoxVHWASettings *mSettings;
|
---|
1567 |
|
---|
1568 | void *mpvVRAM;
|
---|
1569 | uint32_t mcbVRAM;
|
---|
1570 |
|
---|
1571 | #ifdef VBOXVHWA_PROFILE_FPS
|
---|
1572 | VBoxVHWADbgTimer mFPSCounter;
|
---|
1573 | bool mbNewFrame;
|
---|
1574 | #endif
|
---|
1575 | };
|
---|
1576 |
|
---|
1577 | class VBoxGLWgt : public QGLWidget
|
---|
1578 | {
|
---|
1579 | public:
|
---|
1580 | VBoxGLWgt(VBoxVHWAImage * pImage,
|
---|
1581 | QWidget* parent, const QGLWidget* shareWidget);
|
---|
1582 |
|
---|
1583 | protected:
|
---|
1584 | void paintGL()
|
---|
1585 | {
|
---|
1586 | mpImage->performDisplay(true);
|
---|
1587 | }
|
---|
1588 | private:
|
---|
1589 | VBoxVHWAImage * mpImage;
|
---|
1590 | };
|
---|
1591 |
|
---|
1592 | class VBoxVHWAFBO
|
---|
1593 | {
|
---|
1594 | public:
|
---|
1595 | VBoxVHWAFBO() :
|
---|
1596 | mFBO(0)
|
---|
1597 | {}
|
---|
1598 |
|
---|
1599 | ~VBoxVHWAFBO()
|
---|
1600 | {
|
---|
1601 | if(mFBO)
|
---|
1602 | {
|
---|
1603 | vboxglDeleteFramebuffers(1, &mFBO);
|
---|
1604 | }
|
---|
1605 | }
|
---|
1606 |
|
---|
1607 | void init()
|
---|
1608 | {
|
---|
1609 | VBOXQGL_CHECKERR(
|
---|
1610 | vboxglGenFramebuffers(1, &mFBO);
|
---|
1611 | );
|
---|
1612 | }
|
---|
1613 |
|
---|
1614 | void bind()
|
---|
1615 | {
|
---|
1616 | VBOXQGL_CHECKERR(
|
---|
1617 | vboxglBindFramebuffer(GL_FRAMEBUFFER, mFBO);
|
---|
1618 | );
|
---|
1619 | }
|
---|
1620 |
|
---|
1621 | void unbind()
|
---|
1622 | {
|
---|
1623 | VBOXQGL_CHECKERR(
|
---|
1624 | vboxglBindFramebuffer(GL_FRAMEBUFFER, 0);
|
---|
1625 | );
|
---|
1626 | }
|
---|
1627 |
|
---|
1628 | void attachBound(VBoxVHWATexture *pTex)
|
---|
1629 | {
|
---|
1630 | VBOXQGL_CHECKERR(
|
---|
1631 | vboxglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pTex->texTarget(), pTex->texture(), 0);
|
---|
1632 | );
|
---|
1633 | }
|
---|
1634 |
|
---|
1635 | private:
|
---|
1636 | GLuint mFBO;
|
---|
1637 | };
|
---|
1638 |
|
---|
1639 | template <class T>
|
---|
1640 | class VBoxVHWATextureImageFBO : public T
|
---|
1641 | {
|
---|
1642 | public:
|
---|
1643 | VBoxVHWATextureImageFBO(const QRect &size, const VBoxVHWAColorFormat &format, class VBoxVHWAGlProgramMngr * aMgr, VBOXVHWAIMG_TYPE flags) :
|
---|
1644 | T(size, format, aMgr, flags & (~(VBOXVHWAIMG_FBO | VBOXVHWAIMG_LINEAR))),
|
---|
1645 | mFBOTex(size, VBoxVHWAColorFormat(32, 0xff0000, 0xff00, 0xff), aMgr, (flags & (~VBOXVHWAIMG_FBO))),
|
---|
1646 | mpvFBOTexMem(NULL)
|
---|
1647 | {
|
---|
1648 | }
|
---|
1649 |
|
---|
1650 | virtual ~VBoxVHWATextureImageFBO()
|
---|
1651 | {
|
---|
1652 | if(mpvFBOTexMem)
|
---|
1653 | free(mpvFBOTexMem);
|
---|
1654 | }
|
---|
1655 |
|
---|
1656 | virtual void init(uchar *pvMem)
|
---|
1657 | {
|
---|
1658 | mFBO.init();
|
---|
1659 | mpvFBOTexMem = (uchar*)malloc(mFBOTex.memSize());
|
---|
1660 | mFBOTex.init(mpvFBOTexMem);
|
---|
1661 | T::init(pvMem);
|
---|
1662 | mFBO.bind();
|
---|
1663 | mFBO.attachBound(mFBOTex.component(0));
|
---|
1664 | mFBO.unbind();
|
---|
1665 | }
|
---|
1666 |
|
---|
1667 | virtual int createDisplay(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect,
|
---|
1668 | const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected,
|
---|
1669 | GLuint *pDisplay, class VBoxVHWAGlProgramVHWA ** ppProgram)
|
---|
1670 | {
|
---|
1671 | T::createDisplay(NULL, &mFBOTex.rect(), &rect(),
|
---|
1672 | NULL, NULL, false,
|
---|
1673 | pDisplay, ppProgram);
|
---|
1674 |
|
---|
1675 | return mFBOTex.initDisplay(pDst, pDstRect, pSrcRect,
|
---|
1676 | pDstCKey, pSrcCKey, bNotIntersected);
|
---|
1677 | }
|
---|
1678 |
|
---|
1679 | virtual void update(const QRect * pRect)
|
---|
1680 | {
|
---|
1681 | T::update(pRect);
|
---|
1682 |
|
---|
1683 | VBoxVHWAImage::pushSettingsAndSetupViewport(rect().size(), rect());
|
---|
1684 | mFBO.bind();
|
---|
1685 | T::display();
|
---|
1686 | mFBO.unbind();
|
---|
1687 | VBoxVHWAImage::popSettingsAfterSetupViewport();
|
---|
1688 | }
|
---|
1689 |
|
---|
1690 | virtual void display(VBoxVHWATextureImage *pDst, const QRect * pDstRect, const QRect * pSrcRect,
|
---|
1691 | const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool bNotIntersected)
|
---|
1692 | {
|
---|
1693 | mFBOTex.display(pDst, pDstRect, pSrcRect, pDstCKey, pSrcCKey, bNotIntersected);
|
---|
1694 | }
|
---|
1695 |
|
---|
1696 | virtual void display()
|
---|
1697 | {
|
---|
1698 | mFBOTex.display();
|
---|
1699 | }
|
---|
1700 |
|
---|
1701 | const QRect &rect() { return T::rect(); }
|
---|
1702 | private:
|
---|
1703 | VBoxVHWAFBO mFBO;
|
---|
1704 | VBoxVHWATextureImage mFBOTex;
|
---|
1705 | uchar * mpvFBOTexMem;
|
---|
1706 | };
|
---|
1707 |
|
---|
1708 | class VBoxQGLOverlay
|
---|
1709 | {
|
---|
1710 | public:
|
---|
1711 | VBoxQGLOverlay();
|
---|
1712 | void init(QWidget *pViewport, QObject *pPostEventObject, CSession * aSession, uint32_t id);
|
---|
1713 | ~VBoxQGLOverlay()
|
---|
1714 | {
|
---|
1715 | if (mpShareWgt)
|
---|
1716 | delete mpShareWgt;
|
---|
1717 | }
|
---|
1718 |
|
---|
1719 | void updateAttachment(QWidget *pViewport, QObject *pPostEventObject);
|
---|
1720 |
|
---|
1721 | int onVHWACommand(struct VBOXVHWACMD RT_UNTRUSTED_VOLATILE_GUEST *pCommand,
|
---|
1722 | int /*VBOXVHWACMD_TYPE*/ enmCmdInt, bool fGuestCmd);
|
---|
1723 |
|
---|
1724 | void onVHWACommandEvent (QEvent * pEvent);
|
---|
1725 |
|
---|
1726 | /**
|
---|
1727 | * to be called on NotifyUpdate framebuffer call
|
---|
1728 | * @return true if the request was processed & should not be forwarded to the framebuffer
|
---|
1729 | * false - otherwise */
|
---|
1730 | bool onNotifyUpdate (ULONG aX, ULONG aY,
|
---|
1731 | ULONG aW, ULONG aH);
|
---|
1732 |
|
---|
1733 | void onNotifyUpdateIgnore (ULONG aX, ULONG aY,
|
---|
1734 | ULONG aW, ULONG aH)
|
---|
1735 | {
|
---|
1736 | Q_UNUSED(aX);
|
---|
1737 | Q_UNUSED(aY);
|
---|
1738 | Q_UNUSED(aW);
|
---|
1739 | Q_UNUSED(aH);
|
---|
1740 | /* @todo: we actually should not miss notify updates, since we need to update the texture on it */
|
---|
1741 | }
|
---|
1742 |
|
---|
1743 | void onResizeEventPostprocess (const VBoxFBSizeInfo &re, const QPoint & topLeft);
|
---|
1744 |
|
---|
1745 | void onViewportResized (QResizeEvent * /*re*/)
|
---|
1746 | {
|
---|
1747 | vboxDoCheckUpdateViewport();
|
---|
1748 | mGlCurrent = false;
|
---|
1749 | }
|
---|
1750 |
|
---|
1751 | void onViewportScrolled (const QPoint & newTopLeft)
|
---|
1752 | {
|
---|
1753 | mContentsTopLeft = newTopLeft;
|
---|
1754 | vboxDoCheckUpdateViewport();
|
---|
1755 | mGlCurrent = false;
|
---|
1756 | }
|
---|
1757 |
|
---|
1758 | /* not supposed to be called by clients */
|
---|
1759 | int vhwaLoadExec (struct SSMHANDLE * pSSM, uint32_t u32Version);
|
---|
1760 | void vhwaSaveExec (struct SSMHANDLE * pSSM);
|
---|
1761 | private:
|
---|
1762 | int vhwaSurfaceUnlock (struct VBOXVHWACMD_SURF_UNLOCK RT_UNTRUSTED_VOLATILE_GUEST *pCmd);
|
---|
1763 |
|
---|
1764 | void repaintMain();
|
---|
1765 | void repaintOverlay()
|
---|
1766 | {
|
---|
1767 | if(mNeedOverlayRepaint)
|
---|
1768 | {
|
---|
1769 | mNeedOverlayRepaint = false;
|
---|
1770 | performDisplayOverlay();
|
---|
1771 | }
|
---|
1772 | if(mNeedSetVisible)
|
---|
1773 | {
|
---|
1774 | mNeedSetVisible = false;
|
---|
1775 | mpOverlayWgt->setVisible (true);
|
---|
1776 | }
|
---|
1777 | }
|
---|
1778 | void repaint()
|
---|
1779 | {
|
---|
1780 | repaintOverlay();
|
---|
1781 | repaintMain();
|
---|
1782 | }
|
---|
1783 |
|
---|
1784 | void makeCurrent()
|
---|
1785 | {
|
---|
1786 | if (!mGlCurrent)
|
---|
1787 | {
|
---|
1788 | mGlCurrent = true;
|
---|
1789 | mpOverlayWgt->makeCurrent();
|
---|
1790 | }
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | void performDisplayOverlay()
|
---|
1794 | {
|
---|
1795 | if (mOverlayVisible)
|
---|
1796 | {
|
---|
1797 | makeCurrent();
|
---|
1798 | if (mOverlayImage.performDisplay(false))
|
---|
1799 | mpOverlayWgt->swapBuffers();
|
---|
1800 | }
|
---|
1801 | }
|
---|
1802 |
|
---|
1803 | void vboxSetGlOn (bool on);
|
---|
1804 | bool vboxGetGlOn() { return mGlOn; }
|
---|
1805 | bool vboxSynchGl();
|
---|
1806 | void vboxDoVHWACmdExec(void RT_UNTRUSTED_VOLATILE_GUEST *pvCmd, int /*VBOXVHWACMD_TYPE*/ enmCmdInt, bool fGuestCmd);
|
---|
1807 | void vboxShowOverlay (bool show);
|
---|
1808 | void vboxDoCheckUpdateViewport();
|
---|
1809 | void vboxDoVHWACmd(void RT_UNTRUSTED_VOLATILE_GUEST *pvCmd, int /*VBOXVHWACMD_TYPE*/ enmCmd, bool fGuestCmd);
|
---|
1810 | void addMainDirtyRect (const QRect & aRect);
|
---|
1811 | void vboxCheckUpdateOverlay (const QRect & rect);
|
---|
1812 | void processCmd (VBoxVHWACommandElement * pCmd);
|
---|
1813 |
|
---|
1814 | int vhwaConstruct (struct VBOXVHWACMD_HH_CONSTRUCT *pCmd);
|
---|
1815 |
|
---|
1816 | int reset();
|
---|
1817 |
|
---|
1818 | int resetGl();
|
---|
1819 |
|
---|
1820 | void initGl();
|
---|
1821 |
|
---|
1822 | VBoxGLWgt *mpOverlayWgt;
|
---|
1823 | VBoxVHWAImage mOverlayImage;
|
---|
1824 | QWidget *mpViewport;
|
---|
1825 | bool mGlOn;
|
---|
1826 | bool mOverlayWidgetVisible;
|
---|
1827 | bool mOverlayVisible;
|
---|
1828 | bool mGlCurrent;
|
---|
1829 | bool mProcessingCommands;
|
---|
1830 | bool mNeedOverlayRepaint;
|
---|
1831 | bool mNeedSetVisible;
|
---|
1832 | QRect mOverlayViewport;
|
---|
1833 | VBoxVHWADirtyRect mMainDirtyRect;
|
---|
1834 |
|
---|
1835 | VBoxVHWACommandElementProcessor mCmdPipe;
|
---|
1836 |
|
---|
1837 | /* this is used in saved state restore to postpone surface restoration
|
---|
1838 | * till the framebuffer size is restored */
|
---|
1839 | VHWACommandList mOnResizeCmdList;
|
---|
1840 |
|
---|
1841 | VBoxVHWASettings mSettings;
|
---|
1842 | CSession * mpSession;
|
---|
1843 |
|
---|
1844 | VBoxFBSizeInfo mSizeInfo;
|
---|
1845 | VBoxFBSizeInfo mPostponedResize;
|
---|
1846 | QPoint mContentsTopLeft;
|
---|
1847 |
|
---|
1848 | QGLWidget *mpShareWgt;
|
---|
1849 |
|
---|
1850 | uint32_t m_id;
|
---|
1851 | };
|
---|
1852 |
|
---|
1853 | #endif /* defined(VBOX_GUI_USE_QGL) || defined(VBOX_WITH_VIDEOHWACCEL) */
|
---|
1854 |
|
---|
1855 | #endif /* #ifndef __VBoxFBOverlay_h__ */
|
---|