VirtualBox

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

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

joined 2D & 3D support test in one tool

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