VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h@ 24445

Last change on this file since 24445 was 24431, checked in by vboxsync, 15 years ago

2d accel: simplified coord transformations

File size: 37.8 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * VBoxFrameBuffer Overly classes declarations
5 */
6
7/*
8 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22#ifndef __VBoxFBOverlay_h__
23#define __VBoxFBOverlay_h__
24#if defined (VBOX_GUI_USE_QGL) || defined(VBOX_WITH_VIDEOHWACCEL)
25
26//#define VBOXQGL_PROF_BASE 1
27//#define VBOXQGL_DBG_SURF 1
28
29#include "COMDefs.h"
30#include <QGLWidget>
31#include <iprt/assert.h>
32#include <iprt/critsect.h>
33
34#include <VBox/VBoxGL2D.h>
35#include "VBoxFBOverlayCommon.h"
36
37#define VBOXVHWA_ALLOW_PRIMARY_AND_OVERLAY_ONLY 1
38
39class VBoxVHWADirtyRect
40{
41public:
42 VBoxVHWADirtyRect() :
43 mIsClear(true)
44 {}
45
46 VBoxVHWADirtyRect(const QRect & aRect)
47 {
48 if(aRect.isEmpty())
49 {
50 mIsClear = false;
51 mRect = aRect;
52 }
53 else
54 {
55 mIsClear = true;
56 }
57 }
58
59 bool isClear() const { return mIsClear; }
60
61 void add(const QRect & aRect)
62 {
63 if(aRect.isEmpty())
64 return;
65
66 mRect = mIsClear ? aRect : mRect.united(aRect);
67 mIsClear = false;
68 }
69
70 void add(const VBoxVHWADirtyRect & aRect)
71 {
72 if(aRect.isClear())
73 return;
74 add(aRect.rect());
75 }
76
77 void set(const QRect & aRect)
78 {
79 if(aRect.isEmpty())
80 {
81 mIsClear = true;
82 }
83 else
84 {
85 mRect = aRect;
86 mIsClear = false;
87 }
88 }
89
90 void clear() { mIsClear = true; }
91
92 const QRect & rect() const {return mRect;}
93
94 const QRect & toRect()
95 {
96 if(isClear())
97 {
98 mRect.setCoords(0, 0, -1, -1);
99 }
100 return mRect;
101 }
102
103 bool intersects(const QRect & aRect) const {return mIsClear ? false : mRect.intersects(aRect);}
104
105 bool intersects(const VBoxVHWADirtyRect & aRect) const {return mIsClear ? false : aRect.intersects(mRect);}
106
107 QRect united(const QRect & aRect) const {return mIsClear ? aRect : aRect.united(mRect);}
108
109 bool contains(const QRect & aRect) const {return mIsClear ? false : aRect.contains(mRect);}
110
111 void subst(const VBoxVHWADirtyRect & aRect) { if(!mIsClear && aRect.contains(mRect)) clear(); }
112
113private:
114 QRect mRect;
115 bool mIsClear;
116};
117
118class VBoxVHWAColorKey
119{
120public:
121 VBoxVHWAColorKey() :
122 mUpper(0),
123 mLower(0)
124 {}
125
126 VBoxVHWAColorKey(uint32_t aUpper, uint32_t aLower) :
127 mUpper(aUpper),
128 mLower(aLower)
129 {}
130
131 uint32_t upper() const {return mUpper; }
132 uint32_t lower() const {return mLower; }
133
134 bool operator==(const VBoxVHWAColorKey & other) const { return mUpper == other.mUpper && mLower == other.mLower; }
135private:
136 uint32_t mUpper;
137 uint32_t mLower;
138};
139
140class VBoxVHWAColorComponent
141{
142public:
143 VBoxVHWAColorComponent() :
144 mMask(0),
145 mRange(0),
146 mOffset(32),
147 mcBits(0)
148 {}
149
150 VBoxVHWAColorComponent(uint32_t aMask);
151
152 uint32_t mask() const { return mMask; }
153 uint32_t range() const { return mRange; }
154 uint32_t offset() const { return mOffset; }
155 uint32_t cBits() const { return mcBits; }
156 uint32_t colorVal(uint32_t col) const { return (col & mMask) >> mOffset; }
157 float colorValNorm(uint32_t col) const { return ((float)colorVal(col))/mRange; }
158private:
159 uint32_t mMask;
160 uint32_t mRange;
161 uint32_t mOffset;
162 uint32_t mcBits;
163};
164
165class VBoxVHWAColorFormat
166{
167public:
168
169// VBoxVHWAColorFormat(GLint aInternalFormat, GLenum aFormat, GLenum aType, uint32_t aDataFormat);
170 VBoxVHWAColorFormat(uint32_t bitsPerPixel, uint32_t r, uint32_t g, uint32_t b);
171 VBoxVHWAColorFormat(uint32_t fourcc);
172 VBoxVHWAColorFormat(){}
173 GLint internalFormat() const {return mInternalFormat; }
174 GLenum format() const {return mFormat; }
175 GLenum type() const {return mType; }
176 bool isValid() const {return mBitsPerPixel != 0; }
177 uint32_t fourcc() const {return mDataFormat;}
178 uint32_t bitsPerPixel() const { return mBitsPerPixel; }
179 uint32_t bitsPerPixelTex() const { return mBitsPerPixelTex; }
180// uint32_t bitsPerPixelDd() const { return mBitsPerPixelDd; }
181 void pixel2Normalized(uint32_t pix, float *r, float *g, float *b) const;
182 uint32_t widthCompression() const {return mWidthCompression;}
183 uint32_t heightCompression() const {return mHeightCompression;}
184 const VBoxVHWAColorComponent& r() const {return mR;}
185 const VBoxVHWAColorComponent& g() const {return mG;}
186 const VBoxVHWAColorComponent& b() const {return mB;}
187 const VBoxVHWAColorComponent& a() const {return mA;}
188
189 bool equals (const VBoxVHWAColorFormat & other) const;
190
191private:
192 void init(uint32_t bitsPerPixel, uint32_t r, uint32_t g, uint32_t b);
193 void init(uint32_t fourcc);
194
195 GLint mInternalFormat;
196 GLenum mFormat;
197 GLenum mType;
198 uint32_t mDataFormat;
199
200 uint32_t mBitsPerPixel;
201 uint32_t mBitsPerPixelTex;
202// uint32_t mBitsPerPixelDd;
203 uint32_t mWidthCompression;
204 uint32_t mHeightCompression;
205 VBoxVHWAColorComponent mR;
206 VBoxVHWAColorComponent mG;
207 VBoxVHWAColorComponent mB;
208 VBoxVHWAColorComponent mA;
209};
210
211class VBoxVHWATexture
212{
213public:
214 VBoxVHWATexture() {}
215 VBoxVHWATexture(const QRect & aRect, const VBoxVHWAColorFormat &aFormat);
216 virtual ~VBoxVHWATexture();
217 virtual void init(uchar *pvMem);
218 void setAddress(uchar *pvMem) {mAddress = pvMem;}
219 void update(const QRect * pRect) { doUpdate(mAddress, pRect);}
220 void bind() {glBindTexture(texTarget(), mTexture);}
221
222 virtual void texCoord(int x, int y);
223 virtual void multiTexCoord(GLenum texUnit, int x, int y);
224
225// GLuint texture() {return mTexture;}
226 const QRect & texRect() {return mTexRect;}
227 const QRect & rect() {return mRect;}
228 uchar * address(){ return mAddress; }
229 uint32_t rectSizeTex(const QRect * pRect) {return pRect->width() * pRect->height() * mBytesPerPixelTex;}
230 uchar * pointAddress(int x, int y)
231 {
232 x = toXTex(x);
233 y = toYTex(y);
234 return pointAddressTex(x, y);
235 }
236 uint32_t pointOffsetTex(int x, int y) { return y*mBytesPerLine + x*mBytesPerPixelTex; }
237 uchar * pointAddressTex(int x, int y) { return mAddress + pointOffsetTex(x, y); }
238 int toXTex(int x) {return x/mColorFormat.widthCompression();}
239 int toYTex(int y) {return y/mColorFormat.heightCompression();}
240 ulong memSize(){ return mBytesPerLine * mRect.height(); }
241 uint32_t bytesPerLine() {return mBytesPerLine; }
242
243protected:
244 virtual void doUpdate(uchar * pAddress, const QRect * pRect);
245 virtual void initParams();
246 virtual void load();
247 virtual GLenum texTarget() {return GL_TEXTURE_2D; }
248
249
250 QRect mTexRect; /* texture size */
251 QRect mRect; /* img size */
252 uchar * mAddress;
253 GLuint mTexture;
254 uint32_t mBytesPerPixel;
255 uint32_t mBytesPerPixelTex;
256 uint32_t mBytesPerLine;
257 VBoxVHWAColorFormat mColorFormat;
258private:
259 void uninit();
260};
261
262class VBoxVHWATextureNP2 : public VBoxVHWATexture
263{
264public:
265 VBoxVHWATextureNP2() : VBoxVHWATexture() {}
266 VBoxVHWATextureNP2(const QRect & aRect, const VBoxVHWAColorFormat &aFormat) :
267 VBoxVHWATexture(aRect, aFormat){
268 mTexRect = QRect(0, 0, aRect.width()/aFormat.widthCompression(), aRect.height()/aFormat.heightCompression());
269 }
270};
271
272class VBoxVHWATextureNP2Rect : public VBoxVHWATextureNP2
273{
274public:
275 VBoxVHWATextureNP2Rect() : VBoxVHWATextureNP2() {}
276 VBoxVHWATextureNP2Rect(const QRect & aRect, const VBoxVHWAColorFormat &aFormat) :
277 VBoxVHWATextureNP2(aRect, aFormat){}
278
279 virtual void texCoord(int x, int y);
280 virtual void multiTexCoord(GLenum texUnit, int x, int y);
281protected:
282 virtual GLenum texTarget();
283};
284
285class VBoxVHWATextureNP2RectPBO : public VBoxVHWATextureNP2Rect
286{
287public:
288 VBoxVHWATextureNP2RectPBO() : VBoxVHWATextureNP2Rect() {}
289 VBoxVHWATextureNP2RectPBO(const QRect & aRect, const VBoxVHWAColorFormat &aFormat) :
290 VBoxVHWATextureNP2Rect(aRect, aFormat){}
291 virtual ~VBoxVHWATextureNP2RectPBO();
292
293 virtual void init(uchar *pvMem);
294protected:
295 virtual void load();
296 virtual void doUpdate(uchar * pAddress, const QRect * pRect);
297private:
298 GLuint mPBO;
299};
300
301class VBoxVHWAHandleTable
302{
303public:
304 VBoxVHWAHandleTable(uint32_t initialSize);
305 ~VBoxVHWAHandleTable();
306 uint32_t put(void * data);
307 bool mapPut(uint32_t h, void * data);
308 void* get(uint32_t h);
309 void* remove(uint32_t h);
310private:
311 void doPut(uint32_t h, void * data);
312 void doRemove(uint32_t h);
313 void** mTable;
314 uint32_t mcSize;
315 uint32_t mcUsage;
316 uint32_t mCursor;
317};
318
319/* data flow:
320 * I. NON-Yinverted surface:
321 * 1.direct memory update (paint, lock/unlock):
322 * mem->tex->fb
323 * 2.blt
324 * srcTex->invFB->tex->fb
325 * |->mem
326 *
327 * II. Yinverted surface:
328 * 1.direct memory update (paint, lock/unlock):
329 * mem->tex->fb
330 * 2.blt
331 * srcTex->fb->tex
332 * |->mem
333 *
334 * III. flip support:
335 * 1. Yinverted<->NON-YInverted conversion :
336 * mem->tex-(rotate model view, force LAZY complete fb update)->invFB->tex
337 * fb-->| |->mem
338 * */
339class VBoxVHWASurfaceBase
340{
341public:
342 VBoxVHWASurfaceBase(
343 class VBoxGLWidget *mWidget,
344#if 0
345 class VBoxVHWAGlContextState *aState,
346 bool aIsYInverted,
347#endif
348 const QSize & aSize,
349 const QRect & aTargRect,
350 const QRect & aSrcRect,
351 const QRect & aVisTargRect,
352 VBoxVHWAColorFormat & aColorFormat,
353 VBoxVHWAColorKey * pSrcBltCKey, VBoxVHWAColorKey * pDstBltCKey,
354 VBoxVHWAColorKey * pSrcOverlayCKey, VBoxVHWAColorKey * pDstOverlayCKey,
355 bool bVGA);
356
357 virtual ~VBoxVHWASurfaceBase();
358
359 void init(VBoxVHWASurfaceBase * pPrimary, uchar *pvMem);
360
361 void uninit();
362
363 static void globalInit();
364
365// int blt(const QRect * aDstRect, VBoxVHWASurfaceBase * aSrtSurface, const QRect * aSrcRect, const VBoxVHWAColorKey * pDstCKeyOverride, const VBoxVHWAColorKey * pSrcCKeyOverride);
366
367 int lock(const QRect * pRect, uint32_t flags);
368
369 int unlock();
370
371 void updatedMem(const QRect * aRect);
372
373 bool performDisplay(VBoxVHWASurfaceBase *pPrimary, bool bForce);
374
375 void setRects (const QRect & aTargRect, const QRect & aSrcRect);
376 void setTargRectPosition (const QPoint & aPoint);
377 void setVisibilityReinitFlag() { mNeedVisibilityReinit = true; }
378 void updateVisibility (VBoxVHWASurfaceBase *pPrimary, const QRect & aVisibleTargRect, bool bForce);
379
380 static ulong calcBytesPerPixel(GLenum format, GLenum type);
381
382 static GLsizei makePowerOf2(GLsizei val);
383
384 bool addressAlocated() const { return mFreeAddress; }
385 uchar * address(){ return mAddress; }
386
387 ulong memSize();
388
389 ulong width() { return mRect.width(); }
390 ulong height() { return mRect.height(); }
391 const QSize size() {return mRect.size();}
392
393 GLenum format() {return mColorFormat.format(); }
394 GLint internalFormat() { return mColorFormat.internalFormat(); }
395 GLenum type() { return mColorFormat.type(); }
396 uint32_t fourcc() {return mColorFormat.fourcc(); }
397
398// ulong bytesPerPixel() { return mpTex[0]->bytesPerPixel(); }
399 ulong bitsPerPixel() { return mColorFormat.bitsPerPixel(); }
400// ulong bitsPerPixelDd() { return mColorFormat.bitsPerPixelDd(); }
401 ulong bytesPerLine() { return mpTex[0]->bytesPerLine(); }
402
403 const VBoxVHWAColorKey * dstBltCKey() const { return mpDstBltCKey; }
404 const VBoxVHWAColorKey * srcBltCKey() const { return mpSrcBltCKey; }
405 const VBoxVHWAColorKey * dstOverlayCKey() const { return mpDstOverlayCKey; }
406 const VBoxVHWAColorKey * defaultSrcOverlayCKey() const { return mpDefaultSrcOverlayCKey; }
407 const VBoxVHWAColorKey * defaultDstOverlayCKey() const { return mpDefaultDstOverlayCKey; }
408 const VBoxVHWAColorKey * srcOverlayCKey() const { return mpSrcOverlayCKey; }
409 void resetDefaultSrcOverlayCKey() { mpSrcOverlayCKey = mpDefaultSrcOverlayCKey; }
410 void resetDefaultDstOverlayCKey() { mpDstOverlayCKey = mpDefaultDstOverlayCKey; }
411
412 void setDstBltCKey(const VBoxVHWAColorKey * ckey)
413 {
414 if(ckey)
415 {
416 mDstBltCKey = *ckey;
417 mpDstBltCKey = &mDstBltCKey;
418 }
419 else
420 {
421 mpDstBltCKey = NULL;
422 }
423 }
424
425 void setSrcBltCKey(const VBoxVHWAColorKey * ckey)
426 {
427 if(ckey)
428 {
429 mSrcBltCKey = *ckey;
430 mpSrcBltCKey = &mSrcBltCKey;
431 }
432 else
433 {
434 mpSrcBltCKey = NULL;
435 }
436 }
437
438 void setDefaultDstOverlayCKey(const VBoxVHWAColorKey * ckey)
439 {
440 if(ckey)
441 {
442 mDefaultDstOverlayCKey = *ckey;
443 mpDefaultDstOverlayCKey = &mDefaultDstOverlayCKey;
444 }
445 else
446 {
447 mpDefaultDstOverlayCKey = NULL;
448 }
449 }
450
451 void setDefaultSrcOverlayCKey(const VBoxVHWAColorKey * ckey)
452 {
453 if(ckey)
454 {
455 mDefaultSrcOverlayCKey = *ckey;
456 mpDefaultSrcOverlayCKey = &mDefaultSrcOverlayCKey;
457 }
458 else
459 {
460 mpDefaultSrcOverlayCKey = NULL;
461 }
462 }
463
464 void setOverriddenDstOverlayCKey(const VBoxVHWAColorKey * ckey)
465 {
466 if(ckey)
467 {
468 mOverriddenDstOverlayCKey = *ckey;
469 mpDstOverlayCKey = &mOverriddenDstOverlayCKey;
470 }
471 else
472 {
473 mpDstOverlayCKey = NULL;
474 }
475 }
476
477 void setOverriddenSrcOverlayCKey(const VBoxVHWAColorKey * ckey)
478 {
479 if(ckey)
480 {
481 mOverriddenSrcOverlayCKey = *ckey;
482 mpSrcOverlayCKey = &mOverriddenSrcOverlayCKey;
483 }
484 else
485 {
486 mpSrcOverlayCKey = NULL;
487 }
488 }
489
490 const VBoxVHWAColorKey * getActiveSrcOverlayCKey()
491 {
492 return mpSrcOverlayCKey;
493 }
494
495 const VBoxVHWAColorKey * getActiveDstOverlayCKey(VBoxVHWASurfaceBase * pPrimary)
496 {
497 return mpDstOverlayCKey ? mpDefaultDstOverlayCKey : pPrimary->mpDstOverlayCKey;
498 }
499
500 const VBoxVHWAColorFormat & colorFormat() {return mColorFormat; }
501
502 void setAddress(uchar * addr);
503
504 const QRect& rect() const {return mRect;}
505 const QRect& srcRect() const {return mSrcRect; }
506 const QRect& targRect() const {return mTargRect; }
507 class VBoxVHWASurfList * getComplexList() {return mComplexList; }
508
509 class VBoxVHWAGlProgramMngr * getGlProgramMngr();
510 static int setCKey(class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst);
511
512 uint32_t handle() const {return mHGHandle;}
513 void setHandle(uint32_t h) {mHGHandle = h;}
514
515 const VBoxVHWADirtyRect & getDirtyRect() { return mUpdateMem2TexRect; }
516private:
517 void setRectValues (const QRect & aTargRect, const QRect & aSrcRect);
518 void setVisibleRectValues (const QRect & aVisTargRect);
519
520 void setComplexList(VBoxVHWASurfList *aComplexList) { mComplexList = aComplexList; }
521 void initDisplay(VBoxVHWASurfaceBase *pPrimary);
522 void deleteDisplay();
523
524 int createDisplay(VBoxVHWASurfaceBase *pPrimary, GLuint *pDisplay, class VBoxVHWAGlProgram ** ppProgram);
525 void doDisplay(VBoxVHWASurfaceBase *pPrimary, bool bProgram, bool bBindDst);
526 bool synchTexMem(const QRect * aRect);
527
528 int performBlt(const QRect * pDstRect, VBoxVHWASurfaceBase * pSrcSurface, const QRect * pSrcRect, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool blt);
529
530 void doTex2FB(const QRect * pDstRect, const QRect * pSrcRect);
531 void doMultiTex2FB(const QRect * pDstRect, VBoxVHWATexture * pDstTex, const QRect * pSrcRect, int cSrcTex);
532 void doMultiTex2FB(const QRect * pDstRect, const QRect * pSrcRect, int cSrcTex);
533
534 QRect mRect; /* == Inv FB size */
535
536 QRect mSrcRect;
537 QRect mTargRect; /* == Vis FB size */
538
539 QRect mVisibleTargRect;
540 QRect mVisibleSrcRect;
541
542 GLuint mVisibleDisplay;
543 class VBoxVHWAGlProgram * mpProgram;
544
545 bool mVisibleDisplayInitialized;
546 bool mNeedVisibilityReinit;
547
548 uchar * mAddress;
549 VBoxVHWATexture *mpTex[3];
550
551 VBoxVHWAColorFormat mColorFormat;
552
553 VBoxVHWAColorKey *mpSrcBltCKey;
554 VBoxVHWAColorKey *mpDstBltCKey;
555 VBoxVHWAColorKey *mpSrcOverlayCKey;
556 VBoxVHWAColorKey *mpDstOverlayCKey;
557
558 VBoxVHWAColorKey *mpDefaultDstOverlayCKey;
559 VBoxVHWAColorKey *mpDefaultSrcOverlayCKey;
560
561 VBoxVHWAColorKey mSrcBltCKey;
562 VBoxVHWAColorKey mDstBltCKey;
563 VBoxVHWAColorKey mOverriddenSrcOverlayCKey;
564 VBoxVHWAColorKey mOverriddenDstOverlayCKey;
565 VBoxVHWAColorKey mDefaultDstOverlayCKey;
566 VBoxVHWAColorKey mDefaultSrcOverlayCKey;
567
568 int mLockCount;
569 /* memory buffer not reflected in fm and texture, e.g if memory buffer is replaced or in case of lock/unlock */
570 VBoxVHWADirtyRect mUpdateMem2TexRect;
571
572 bool mFreeAddress;
573
574 class VBoxVHWASurfList *mComplexList;
575
576 class VBoxGLWidget *mWidget;
577
578 uint32_t mHGHandle;
579
580#ifdef DEBUG
581public:
582 uint64_t cFlipsCurr;
583 uint64_t cFlipsTarg;
584#endif
585 friend class VBoxVHWASurfList;
586};
587
588typedef std::list <VBoxVHWASurfaceBase*> SurfList;
589typedef std::list <VBoxVHWASurfList*> OverlayList;
590typedef std::list <struct _VBOXVHWACMD *> VHWACommandList;
591
592class VBoxVHWASurfList
593{
594public:
595
596 VBoxVHWASurfList() : mCurrent(NULL) {}
597 void add(VBoxVHWASurfaceBase *pSurf)
598 {
599 VBoxVHWASurfList * pOld = pSurf->getComplexList();
600 if(pOld)
601 {
602 pOld->remove(pSurf);
603 }
604 mSurfaces.push_back(pSurf);
605 pSurf->setComplexList(this);
606 }
607
608 void clear()
609 {
610 for (SurfList::iterator it = mSurfaces.begin();
611 it != mSurfaces.end(); ++ it)
612 {
613 (*it)->setComplexList(NULL);
614 }
615 mSurfaces.clear();
616 mCurrent = NULL;
617 }
618
619 size_t size() const {return mSurfaces.size(); }
620
621 void remove(VBoxVHWASurfaceBase *pSurf)
622 {
623 mSurfaces.remove(pSurf);
624 pSurf->setComplexList(NULL);
625 if(mCurrent == pSurf)
626 mCurrent = NULL;
627 }
628
629 bool empty() { return mSurfaces.empty(); }
630
631 void setCurrentVisible(VBoxVHWASurfaceBase *pSurf)
632 {
633 mCurrent = pSurf;
634 }
635
636 VBoxVHWASurfaceBase * current() { return mCurrent; }
637 const SurfList & surfaces() const {return mSurfaces;}
638
639private:
640
641 SurfList mSurfaces;
642 VBoxVHWASurfaceBase* mCurrent;
643};
644
645class VBoxVHWADisplay
646{
647public:
648 VBoxVHWADisplay() :
649 mSurfVGA(NULL)
650// ,
651// mSurfPrimary(NULL)
652 {}
653
654 VBoxVHWASurfaceBase * setVGA(VBoxVHWASurfaceBase * pVga)
655 {
656 VBoxVHWASurfaceBase * old = mSurfVGA;
657 mSurfVGA = pVga;
658 mPrimary.clear();
659 if(pVga)
660 {
661 Assert(!pVga->getComplexList());
662 mPrimary.add(pVga);
663 mPrimary.setCurrentVisible(pVga);
664 }
665// mSurfPrimary = pVga;
666 mOverlays.clear();
667 return old;
668 }
669
670 VBoxVHWASurfaceBase * updateVGA(VBoxVHWASurfaceBase * pVga)
671 {
672 VBoxVHWASurfaceBase * old = mSurfVGA;
673 Assert(old);
674 mSurfVGA = pVga;
675 return old;
676 }
677
678 VBoxVHWASurfaceBase * getVGA() const
679 {
680 return mSurfVGA;
681 }
682
683 VBoxVHWASurfaceBase * getPrimary()
684 {
685 return mPrimary.current();
686 }
687
688 void addOverlay(VBoxVHWASurfList * pSurf)
689 {
690 mOverlays.push_back(pSurf);
691 }
692
693 void checkAddOverlay(VBoxVHWASurfList * pSurf)
694 {
695 if(!hasOverlay(pSurf))
696 addOverlay(pSurf);
697 }
698
699 bool hasOverlay(VBoxVHWASurfList * pSurf)
700 {
701 for (OverlayList::iterator it = mOverlays.begin();
702 it != mOverlays.end(); ++ it)
703 {
704 if((*it) == pSurf)
705 {
706 return true;
707 }
708 }
709 return false;
710 }
711
712 void removeOverlay(VBoxVHWASurfList * pSurf)
713 {
714 mOverlays.remove(pSurf);
715 }
716
717 bool performDisplay(bool bForce)
718 {
719 VBoxVHWASurfaceBase * pPrimary = mPrimary.current();
720 bForce |= pPrimary->performDisplay(NULL, bForce);
721
722 for (OverlayList::const_iterator it = mOverlays.begin();
723 it != mOverlays.end(); ++ it)
724 {
725 VBoxVHWASurfaceBase * pOverlay = (*it)->current();
726 if(pOverlay)
727 {
728 bForce |= pOverlay->performDisplay(pPrimary, bForce);
729 }
730 }
731 return bForce;
732 }
733
734 const OverlayList & overlays() const {return mOverlays;}
735 const VBoxVHWASurfList & primaries() const { return mPrimary; }
736
737private:
738 VBoxVHWASurfaceBase *mSurfVGA;
739 VBoxVHWASurfList mPrimary;
740
741 OverlayList mOverlays;
742};
743
744typedef void (VBoxGLWidget::*PFNVBOXQGLOP)(void* );
745
746typedef void (*PFNVBOXQGLFUNC)(void*, void*);
747
748typedef enum
749{
750 VBOXVHWA_PIPECMD_PAINT = 1,
751 VBOXVHWA_PIPECMD_VHWA,
752 VBOXVHWA_PIPECMD_OP,
753 VBOXVHWA_PIPECMD_FUNC,
754}VBOXVHWA_PIPECMD_TYPE;
755
756typedef struct VBOXVHWACALLBACKINFO
757{
758 VBoxGLWidget *pThis;
759 PFNVBOXQGLOP pfnCallback;
760 void * pContext;
761}VBOXVHWACALLBACKINFO;
762
763typedef struct VBOXVHWAFUNCCALLBACKINFO
764{
765 PFNVBOXQGLFUNC pfnCallback;
766 void * pContext1;
767 void * pContext2;
768}VBOXVHWAFUNCCALLBACKINFO;
769
770class VBoxVHWACommandElement
771{
772public:
773 void setVHWACmd(struct _VBOXVHWACMD * pCmd)
774 {
775 mType = VBOXVHWA_PIPECMD_VHWA;
776 u.mpCmd = pCmd;
777 }
778
779 void setPaintCmd(const QRect & aRect)
780 {
781 mType = VBOXVHWA_PIPECMD_PAINT;
782 mRect = aRect;
783 }
784
785 void setOp(const VBOXVHWACALLBACKINFO & aOp)
786 {
787 mType = VBOXVHWA_PIPECMD_OP;
788 u.mCallback = aOp;
789 }
790
791 void setFunc(const VBOXVHWAFUNCCALLBACKINFO & aOp)
792 {
793 mType = VBOXVHWA_PIPECMD_FUNC;
794 u.mFuncCallback = aOp;
795 }
796
797 void setData(VBOXVHWA_PIPECMD_TYPE aType, void * pvData)
798 {
799 switch(aType)
800 {
801 case VBOXVHWA_PIPECMD_PAINT:
802 setPaintCmd(*((QRect*)pvData));
803 break;
804 case VBOXVHWA_PIPECMD_VHWA:
805 setVHWACmd((struct _VBOXVHWACMD *)pvData);
806 break;
807 case VBOXVHWA_PIPECMD_OP:
808 setOp(*((VBOXVHWACALLBACKINFO *)pvData));
809 break;
810 case VBOXVHWA_PIPECMD_FUNC:
811 setFunc(*((VBOXVHWAFUNCCALLBACKINFO *)pvData));
812 break;
813 default:
814 Assert(0);
815 break;
816 }
817 }
818
819 VBOXVHWA_PIPECMD_TYPE type() const {return mType;}
820 const QRect & rect() const {return mRect;}
821 struct _VBOXVHWACMD * vhwaCmd() const {return u.mpCmd;}
822 const VBOXVHWACALLBACKINFO & op() const {return u.mCallback; }
823 const VBOXVHWAFUNCCALLBACKINFO & func() const {return u.mFuncCallback; }
824
825 VBoxVHWACommandElement * mpNext;
826private:
827 VBOXVHWA_PIPECMD_TYPE mType;
828 union
829 {
830 struct _VBOXVHWACMD * mpCmd;
831 VBOXVHWACALLBACKINFO mCallback;
832 VBOXVHWAFUNCCALLBACKINFO mFuncCallback;
833 }u;
834 QRect mRect;
835};
836
837class VBoxVHWACommandElementPipe
838{
839public:
840 VBoxVHWACommandElementPipe() :
841 mpFirst(NULL),
842 mpLast(NULL)
843 {}
844
845 void put(VBoxVHWACommandElement *pCmd)
846 {
847 if(mpLast)
848 {
849 Assert(mpFirst);
850 mpLast->mpNext = pCmd;
851 mpLast = pCmd;
852 }
853 else
854 {
855 Assert(!mpFirst);
856 mpFirst = pCmd;
857 mpLast = pCmd;
858 }
859 pCmd->mpNext= NULL;
860
861 }
862
863 VBoxVHWACommandElement * detachList()
864 {
865 if(mpLast)
866 {
867 VBoxVHWACommandElement * pHead = mpFirst;
868 mpFirst = NULL;
869 mpLast = NULL;
870 return pHead;
871 }
872 return NULL;
873 }
874private:
875 VBoxVHWACommandElement *mpFirst;
876 VBoxVHWACommandElement *mpLast;
877};
878
879class VBoxVHWACommandElementStack
880{
881public:
882 VBoxVHWACommandElementStack() :
883 mpFirst(NULL) {}
884
885 void push(VBoxVHWACommandElement *pCmd)
886 {
887 pCmd->mpNext = mpFirst;
888 mpFirst = pCmd;
889 }
890
891 void pusha(VBoxVHWACommandElement *pFirst, VBoxVHWACommandElement *pLast)
892 {
893 pLast->mpNext = mpFirst;
894 mpFirst = pFirst;
895 }
896
897 VBoxVHWACommandElement * pop()
898 {
899 if(mpFirst)
900 {
901 VBoxVHWACommandElement * ret = mpFirst;
902 mpFirst = ret->mpNext;
903 return ret;
904 }
905 return NULL;
906 }
907private:
908 VBoxVHWACommandElement *mpFirst;
909};
910
911#define VBOXVHWACMDPIPEC_NEWEVENT 0x00000001
912#define VBOXVHWACMDPIPEC_COMPLETEEVENT 0x00000002
913class VBoxVHWACommandElementProcessor
914{
915public:
916 VBoxVHWACommandElementProcessor(class VBoxConsoleView *aView);
917 ~VBoxVHWACommandElementProcessor();
918 void postCmd(VBOXVHWA_PIPECMD_TYPE aType, void * pvData, uint32_t flags);
919 void completeCurrentEvent();
920 class VBoxVHWACommandElement * detachCmdList(class VBoxVHWACommandElement * pFirst2Free, VBoxVHWACommandElement * pLast2Free);
921 void reset(class VBoxVHWACommandElement ** ppHead, class VBoxVHWACommandElement ** ppTail);
922private:
923 RTCRITSECT mCritSect;
924 class VBoxVHWACommandProcessEvent *mpFirstEvent;
925 class VBoxVHWACommandProcessEvent *mpLastEvent;
926 class VBoxConsoleView *mView;
927 bool mbNewEvent;
928 bool mbProcessingList;
929 VBoxVHWACommandElementStack mFreeElements;
930 VBoxVHWACommandElement mElementsBuffer[2048];
931};
932
933class VBoxVHWACommandsQueue
934{
935public:
936 void enqueue(PFNVBOXQGLFUNC pfn, void* pContext1, void* pContext2);
937
938 VBoxVHWACommandElement * detachList();
939
940 void freeList(VBoxVHWACommandElement * pList);
941
942private:
943 VBoxVHWACommandElementPipe mCmds;
944};
945
946class VBoxGLWidget : public QGLWidget
947{
948public:
949 VBoxGLWidget (class VBoxConsoleView *aView, QWidget *aParent);
950 ~VBoxGLWidget();
951
952 ulong vboxPixelFormat() { return mPixelFormat; }
953 bool vboxUsesGuestVRAM() { return mUsesGuestVRAM; }
954
955 uchar *vboxAddress() { return mDisplay.getVGA() ? mDisplay.getVGA()->address() : NULL; }
956
957#ifdef VBOX_WITH_VIDEOHWACCEL
958 uchar *vboxVRAMAddressFromOffset(uint64_t offset);
959 uint64_t vboxVRAMOffsetFromAddress(uchar* addr);
960 uint64_t vboxVRAMOffset(VBoxVHWASurfaceBase * pSurf);
961
962 void vhwaSaveExec(struct SSMHANDLE * pSSM);
963 int vhwaLoadExec(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
964
965 int vhwaSurfaceCanCreate(struct _VBOXVHWACMD_SURF_CANCREATE *pCmd);
966 int vhwaSurfaceCreate(struct _VBOXVHWACMD_SURF_CREATE *pCmd);
967 int vhwaSurfaceDestroy(struct _VBOXVHWACMD_SURF_DESTROY *pCmd);
968 int vhwaSurfaceLock(struct _VBOXVHWACMD_SURF_LOCK *pCmd);
969 int vhwaSurfaceUnlock(struct _VBOXVHWACMD_SURF_UNLOCK *pCmd);
970 int vhwaSurfaceBlt(struct _VBOXVHWACMD_SURF_BLT *pCmd);
971 int vhwaSurfaceFlip(struct _VBOXVHWACMD_SURF_FLIP *pCmd);
972 int vhwaSurfaceOverlayUpdate(struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmf);
973 int vhwaSurfaceOverlaySetPosition(struct _VBOXVHWACMD_SURF_OVERLAY_SETPOSITION *pCmd);
974 int vhwaSurfaceColorkeySet(struct _VBOXVHWACMD_SURF_COLORKEY_SET *pCmd);
975 int vhwaQueryInfo1(struct _VBOXVHWACMD_QUERYINFO1 *pCmd);
976 int vhwaQueryInfo2(struct _VBOXVHWACMD_QUERYINFO2 *pCmd);
977 int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd);
978
979 bool hasSurfaces() const;
980 bool hasVisibleOverlays();
981 const QRect & overlaysRectUnion();
982#endif
983
984 ulong vboxBitsPerPixel() { return mDisplay.getVGA()->bitsPerPixel(); }
985 ulong vboxBytesPerLine() { return mDisplay.getVGA() ? mDisplay.getVGA()->bytesPerLine() : 0; }
986 int vboxFbWidth() {return mDisplay.getVGA()->width(); }
987 int vboxFbHeight() {return mDisplay.getVGA()->height(); }
988 bool vboxIsInitialized() {return mDisplay.getVGA() != NULL; }
989
990 void vboxDoResize(void *re);
991
992// void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe); }
993 void vboxResizeEvent (class VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re); }
994
995 void vboxProcessVHWACommands(class VBoxVHWACommandElementProcessor * pPipe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoProcessVHWACommands, pPipe);}
996
997 class VBoxVHWAGlProgramMngr * vboxVHWAGetGlProgramMngr() { return mpMngr; }
998
999 VBoxVHWASurfaceBase * vboxGetVGASurface() { return mDisplay.getVGA(); }
1000
1001#ifdef VBOXVHWA_OLD_COORD
1002 static void doSetupMatrix(const QSize & aSize, bool bInverted);
1003#endif
1004
1005 void vboxDoUpdateViewport(const QRect & aRect);
1006 void vboxDoUpdateRect(const QRect * pRect);
1007
1008 const QRect & vboxViewport() const {return mViewport;}
1009
1010 bool performDisplayAndSwap(bool bForce)
1011 {
1012 bForce = mDisplay.performDisplay(bForce | mRepaintNeeded);
1013 if(bForce)
1014 {
1015 swapBuffers();
1016 }
1017 return bForce;
1018 }
1019protected:
1020
1021 void paintGL()
1022 {
1023 if(mpfnOp)
1024 {
1025 (this->*mpfnOp)(mOpContext);
1026 mpfnOp = NULL;
1027 }
1028 VBOXQGLLOG(("paintGL\n"));
1029// else
1030// {
1031 mDisplay.performDisplay(true);
1032// }
1033 }
1034
1035 void initializeGL();
1036
1037private:
1038 static void setupMatricies(const QSize &display);
1039 static void adjustViewport(const QSize &display, const QRect &viewport);
1040// void vboxDoPaint(void *rec);
1041
1042
1043#ifdef VBOXQGL_DBG_SURF
1044 void vboxDoTestSurfaces(void *context);
1045#endif
1046#ifdef VBOX_WITH_VIDEOHWACCEL
1047 void vboxDoVHWACmdExec(void *cmd);
1048 void vboxDoVHWACmdAndFree(void *cmd);
1049 void vboxDoVHWACmd(void *cmd);
1050
1051 void vboxCheckUpdateAddress (VBoxVHWASurfaceBase * pSurface, uint64_t offset)
1052 {
1053 if (pSurface->addressAlocated())
1054 {
1055 uchar * addr = vboxVRAMAddressFromOffset(offset);
1056 if(addr)
1057 {
1058 pSurface->setAddress(addr);
1059 }
1060 }
1061 }
1062
1063 int vhwaSaveSurface(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps);
1064 int vhwaLoadSurface(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t cBackBuffers, uint32_t u32Version);
1065 int vhwaSaveOverlayData(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, bool bVisible);
1066 int vhwaLoadOverlayData(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
1067 void vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd);
1068#endif
1069 static const QGLFormat & vboxGLFormat();
1070
1071 VBoxVHWADisplay mDisplay;
1072
1073
1074 /* we do all opengl stuff in the paintGL context,
1075 * submit the operation to be performed
1076 * @todo: could be moved outside the updateGL */
1077 void vboxPerformGLOp(PFNVBOXQGLOP pfn, void* pContext)
1078 {
1079 mpfnOp = pfn;
1080 mOpContext = pContext;
1081 updateGL();
1082 }
1083
1084// /* posts op to UI thread */
1085// int vboxExecOpSynch(PFNVBOXQGLOP pfn, void* pContext);
1086// void vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext);
1087
1088 void vboxDoProcessVHWACommands(void *pContext);
1089
1090 class VBoxVHWACommandElement * processCmdList(class VBoxVHWACommandElement * pCmd);
1091
1092 VBoxVHWASurfaceBase* handle2Surface(uint32_t h)
1093 {
1094 VBoxVHWASurfaceBase* pSurf = (VBoxVHWASurfaceBase*)mSurfHandleTable.get(h);
1095 Assert(pSurf);
1096 return pSurf;
1097 }
1098
1099 VBoxVHWAHandleTable mSurfHandleTable;
1100
1101 PFNVBOXQGLOP mpfnOp;
1102 void *mOpContext;
1103
1104 ulong mPixelFormat;
1105 bool mUsesGuestVRAM;
1106
1107 bool mRepaintNeeded;
1108
1109// bool mbVGASurfCreated;
1110 QRect mViewport;
1111
1112 class VBoxConsoleView *mView;
1113
1114 VBoxVHWASurfList *mConstructingList;
1115 int32_t mcRemaining2Contruct;
1116
1117 /* this is used in saved state restore to postpone surface restoration
1118 * till the framebuffer size is restored */
1119 VHWACommandList mOnResizeCmdList;
1120
1121 class VBoxVHWAGlProgramMngr *mpMngr;
1122};
1123
1124
1125//typedef enum
1126//{
1127// VBOXFBOVERLAY_DONE = 1,
1128// VBOXFBOVERLAY_MODIFIED,
1129// VBOXFBOVERLAY_UNTOUCHED
1130//} VBOXFBOVERLAY_RESUT;
1131
1132class VBoxQGLOverlay
1133{
1134public:
1135 VBoxQGLOverlay (class VBoxConsoleView *aView, class VBoxFrameBuffer * aContainer);
1136
1137 int onVHWACommand(struct _VBOXVHWACMD * pCommand);
1138
1139 void onVHWACommandEvent(QEvent * pEvent);
1140
1141 /**
1142 * to be called on NotifyUpdate framebuffer call
1143 * @return true if the request was processed & should not be forwarded to the framebuffer
1144 * false - otherwise */
1145 bool onNotifyUpdate (ULONG aX, ULONG aY,
1146 ULONG aW, ULONG aH);
1147
1148 /**
1149 * to be called on RequestResize framebuffer call
1150 * @return true if the request was processed & should not be forwarded to the framebuffer
1151 * false - otherwise */
1152 bool onRequestResize (ULONG /*aScreenId*/, ULONG /*aPixelFormat*/,
1153 BYTE * /*aVRAM*/, ULONG /*aBitsPerPixel*/, ULONG /*aBytesPerLine*/,
1154 ULONG /*aWidth*/, ULONG /*aHeight*/,
1155 BOOL * /*aFinished*/)
1156 {
1157 mCmdPipe.completeCurrentEvent();
1158 return false;
1159 }
1160
1161// VBOXFBOVERLAY_RESUT onPaintEvent (const QPaintEvent *pe, QRect *pRect);
1162
1163 void onResizeEvent (const class VBoxResizeEvent *re);
1164 void onResizeEventPostprocess (const class VBoxResizeEvent *re);
1165
1166 void onViewportResized(QResizeEvent * /*re*/)
1167 {
1168 vboxDoCheckUpdateViewport();
1169 mGlCurrent = false;
1170 }
1171
1172 void onViewportScrolled(int /*dx*/, int /*dy*/)
1173 {
1174 vboxDoCheckUpdateViewport();
1175 mGlCurrent = false;
1176 }
1177
1178 static bool isAcceleration2DVideoAvailable();
1179
1180 /** additional video memory required for the best 2D support performance
1181 * total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */
1182 static quint64 required2DOffscreenVideoMemory();
1183
1184 /* not supposed to be called by clients */
1185 int vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version);
1186 void vhwaSaveExec(struct SSMHANDLE * pSSM);
1187private:
1188 int vhwaSurfaceUnlock(struct _VBOXVHWACMD_SURF_UNLOCK *pCmd);
1189
1190 void repaintMain();
1191 void repaintOverlay()
1192 {
1193 if(mNeedOverlayRepaint)
1194 {
1195 mNeedOverlayRepaint = false;
1196 performDisplayOverlay();
1197 }
1198 if(mNeedSetVisible)
1199 {
1200 mNeedSetVisible = false;
1201 mpOverlayWidget->setVisible(true);
1202 }
1203 }
1204 void repaint()
1205 {
1206 repaintOverlay();
1207 repaintMain();
1208 }
1209
1210 void makeCurrent()
1211 {
1212 if(!mGlCurrent)
1213 {
1214 mGlCurrent = true;
1215 mpOverlayWidget->makeCurrent();
1216 }
1217 }
1218
1219 void performDisplayOverlay()
1220 {
1221 if(mOverlayVisible)
1222 {
1223#if 0
1224 mpOverlayWidget->updateGL();
1225#else
1226 makeCurrent();
1227 mpOverlayWidget->performDisplayAndSwap(false);
1228#endif
1229 }
1230 }
1231
1232// void vboxOpExit()
1233// {
1234// performDisplayOverlay();
1235// mGlCurrent = false;
1236// }
1237
1238
1239 void vboxSetGlOn(bool on);
1240 bool vboxGetGlOn() { return mGlOn; }
1241 bool vboxSynchGl();
1242 void vboxDoVHWACmdExec(void *cmd);
1243 void vboxShowOverlay(bool show);
1244 void vboxDoCheckUpdateViewport();
1245 void vboxDoVHWACmd(void *cmd);
1246 void addMainDirtyRect(const QRect & aRect);
1247// void vboxUpdateOverlayPosition(const QPoint & pos);
1248 void vboxCheckUpdateOverlay(const QRect & rect);
1249 VBoxVHWACommandElement * processCmdList(VBoxVHWACommandElement * pCmd);
1250
1251 int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd);
1252
1253 int reset();
1254
1255 VBoxGLWidget *mpOverlayWidget;
1256 class VBoxConsoleView *mView;
1257 class VBoxFrameBuffer *mContainer;
1258 bool mGlOn;
1259 bool mOverlayWidgetVisible;
1260 bool mOverlayVisible;
1261 bool mGlCurrent;
1262 bool mProcessingCommands;
1263 bool mNeedOverlayRepaint;
1264 bool mNeedSetVisible;
1265 QRect mOverlayViewport;
1266 VBoxVHWADirtyRect mMainDirtyRect;
1267
1268 VBoxVHWACommandElementProcessor mCmdPipe;
1269
1270 /* this is used in saved state restore to postpone surface restoration
1271 * till the framebuffer size is restored */
1272 VHWACommandList mOnResizeCmdList;
1273};
1274
1275
1276template <class T>
1277class VBoxOverlayFrameBuffer : public T
1278{
1279public:
1280 VBoxOverlayFrameBuffer (class VBoxConsoleView *aView)
1281 : T(aView),
1282 mOverlay(aView, this)
1283 {}
1284
1285
1286 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand)
1287 {
1288 return mOverlay.onVHWACommand((struct _VBOXVHWACMD*)pCommand);
1289 }
1290
1291 void doProcessVHWACommand(QEvent * pEvent)
1292 {
1293 mOverlay.onVHWACommandEvent(pEvent);
1294 }
1295
1296 STDMETHOD(RequestResize) (ULONG aScreenId, ULONG aPixelFormat,
1297 BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine,
1298 ULONG aWidth, ULONG aHeight,
1299 BOOL *aFinished)
1300 {
1301 if(mOverlay.onRequestResize (aScreenId, aPixelFormat,
1302 aVRAM, aBitsPerPixel, aBytesPerLine,
1303 aWidth, aHeight,
1304 aFinished))
1305 {
1306 return S_OK;
1307 }
1308 return T::RequestResize (aScreenId, aPixelFormat,
1309 aVRAM, aBitsPerPixel, aBytesPerLine,
1310 aWidth, aHeight,
1311 aFinished);
1312 }
1313
1314 STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
1315 ULONG aW, ULONG aH)
1316 {
1317 if(mOverlay.onNotifyUpdate(aX, aY, aW, aH))
1318 return S_OK;
1319 return T::NotifyUpdate(aX, aY, aW, aH);
1320 }
1321
1322// void paintEvent (QPaintEvent *pe)
1323// {
1324// QRect rect;
1325// VBOXFBOVERLAY_RESUT res = mOverlay.onPaintEvent(pe, &rect);
1326// switch(res)
1327// {
1328// case VBOXFBOVERLAY_MODIFIED:
1329// {
1330// QPaintEvent modified(rect);
1331// T::paintEvent(&modified);
1332// } break;
1333// case VBOXFBOVERLAY_UNTOUCHED:
1334// T::paintEvent(pe);
1335// break;
1336// default:
1337// break;
1338// }
1339// }
1340
1341 void resizeEvent (VBoxResizeEvent *re)
1342 {
1343 mOverlay.onResizeEvent(re);
1344 T::resizeEvent(re);
1345 mOverlay.onResizeEventPostprocess(re);
1346 }
1347
1348 void viewportResized(QResizeEvent * re)
1349 {
1350 mOverlay.onViewportResized(re);
1351 T::viewportResized(re);
1352 }
1353
1354 void viewportScrolled(int dx, int dy)
1355 {
1356 mOverlay.onViewportScrolled(dx, dy);
1357 T::viewportScrolled(dx, dy);
1358 }
1359private:
1360 VBoxQGLOverlay mOverlay;
1361};
1362
1363#endif
1364
1365#endif /* #ifndef __VBoxFBOverlay_h__ */
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