VirtualBox

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

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

2dvideo: bugfixing for overlay (widget) move/resize

File size: 37.6 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
922private:
923 RTCRITSECT mCritSect;
924 class VBoxVHWACommandProcessEvent *mpFirstEvent;
925 class VBoxVHWACommandProcessEvent *mpLastEvent;
926 class VBoxConsoleView *mView;
927 bool mbNewEvent;
928 VBoxVHWACommandElementStack mFreeElements;
929 VBoxVHWACommandElement mElementsBuffer[2048];
930};
931
932class VBoxVHWACommandsQueue
933{
934public:
935 void enqueue(PFNVBOXQGLFUNC pfn, void* pContext1, void* pContext2);
936
937 VBoxVHWACommandElement * detachList();
938
939 void freeList(VBoxVHWACommandElement * pList);
940
941private:
942 VBoxVHWACommandElementPipe mCmds;
943};
944
945class VBoxGLWidget : public QGLWidget
946{
947public:
948 VBoxGLWidget (class VBoxConsoleView *aView, QWidget *aParent);
949 ~VBoxGLWidget();
950
951 ulong vboxPixelFormat() { return mPixelFormat; }
952 bool vboxUsesGuestVRAM() { return mUsesGuestVRAM; }
953
954 uchar *vboxAddress() { return mDisplay.getVGA() ? mDisplay.getVGA()->address() : NULL; }
955
956#ifdef VBOX_WITH_VIDEOHWACCEL
957 uchar *vboxVRAMAddressFromOffset(uint64_t offset);
958 uint64_t vboxVRAMOffsetFromAddress(uchar* addr);
959 uint64_t vboxVRAMOffset(VBoxVHWASurfaceBase * pSurf);
960
961 void vhwaSaveExec(struct SSMHANDLE * pSSM);
962 int vhwaLoadExec(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
963
964 int vhwaSurfaceCanCreate(struct _VBOXVHWACMD_SURF_CANCREATE *pCmd);
965 int vhwaSurfaceCreate(struct _VBOXVHWACMD_SURF_CREATE *pCmd);
966 int vhwaSurfaceDestroy(struct _VBOXVHWACMD_SURF_DESTROY *pCmd);
967 int vhwaSurfaceLock(struct _VBOXVHWACMD_SURF_LOCK *pCmd);
968 int vhwaSurfaceUnlock(struct _VBOXVHWACMD_SURF_UNLOCK *pCmd);
969 int vhwaSurfaceBlt(struct _VBOXVHWACMD_SURF_BLT *pCmd);
970 int vhwaSurfaceFlip(struct _VBOXVHWACMD_SURF_FLIP *pCmd);
971 int vhwaSurfaceOverlayUpdate(struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmf);
972 int vhwaSurfaceOverlaySetPosition(struct _VBOXVHWACMD_SURF_OVERLAY_SETPOSITION *pCmd);
973 int vhwaSurfaceColorkeySet(struct _VBOXVHWACMD_SURF_COLORKEY_SET *pCmd);
974 int vhwaQueryInfo1(struct _VBOXVHWACMD_QUERYINFO1 *pCmd);
975 int vhwaQueryInfo2(struct _VBOXVHWACMD_QUERYINFO2 *pCmd);
976 int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd);
977
978 bool hasSurfaces() const;
979 bool hasVisibleOverlays();
980 const QRect & overlaysRectUnion();
981#endif
982
983 ulong vboxBitsPerPixel() { return mDisplay.getVGA()->bitsPerPixel(); }
984 ulong vboxBytesPerLine() { return mDisplay.getVGA() ? mDisplay.getVGA()->bytesPerLine() : 0; }
985 int vboxFbWidth() {return mDisplay.getVGA()->width(); }
986 int vboxFbHeight() {return mDisplay.getVGA()->height(); }
987 bool vboxIsInitialized() {return mDisplay.getVGA() != NULL; }
988
989 void vboxDoResize(void *re);
990
991// void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe); }
992 void vboxResizeEvent (class VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re); }
993
994 void vboxProcessVHWACommands(class VBoxVHWACommandElementProcessor * pPipe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoProcessVHWACommands, pPipe);}
995
996 class VBoxVHWAGlProgramMngr * vboxVHWAGetGlProgramMngr() { return mpMngr; }
997
998 VBoxVHWASurfaceBase * vboxGetVGASurface() { return mDisplay.getVGA(); }
999
1000 static void doSetupMatrix(const QSize & aSize, bool bInverted);
1001
1002 void vboxDoUpdateViewport(const QRect & aRect);
1003 void vboxDoUpdateRect(const QRect * pRect);
1004
1005 const QRect & vboxViewport() const {return mViewport;}
1006
1007 bool performDisplayAndSwap(bool bForce)
1008 {
1009 bForce = mDisplay.performDisplay(bForce | mRepaintNeeded);
1010 if(bForce)
1011 {
1012 swapBuffers();
1013 }
1014 return bForce;
1015 }
1016protected:
1017
1018 void paintGL()
1019 {
1020 if(mpfnOp)
1021 {
1022 (this->*mpfnOp)(mOpContext);
1023 mpfnOp = NULL;
1024 }
1025 VBOXQGLLOG(("paintGL\n"));
1026// else
1027// {
1028 mDisplay.performDisplay(true);
1029// }
1030 }
1031
1032 void initializeGL();
1033
1034private:
1035 static void setupMatricies(const QSize &display);
1036 static void adjustViewport(const QSize &display, const QRect &viewport);
1037// void vboxDoPaint(void *rec);
1038
1039
1040#ifdef VBOXQGL_DBG_SURF
1041 void vboxDoTestSurfaces(void *context);
1042#endif
1043#ifdef VBOX_WITH_VIDEOHWACCEL
1044 void vboxDoVHWACmdExec(void *cmd);
1045 void vboxDoVHWACmdAndFree(void *cmd);
1046 void vboxDoVHWACmd(void *cmd);
1047
1048 void vboxCheckUpdateAddress (VBoxVHWASurfaceBase * pSurface, uint64_t offset)
1049 {
1050 if (pSurface->addressAlocated())
1051 {
1052 uchar * addr = vboxVRAMAddressFromOffset(offset);
1053 if(addr)
1054 {
1055 pSurface->setAddress(addr);
1056 }
1057 }
1058 }
1059
1060 int vhwaSaveSurface(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps);
1061 int vhwaLoadSurface(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
1062 int vhwaSaveOverlayData(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, bool bVisible);
1063 int vhwaLoadOverlayData(VHWACommandList * pCmdList, struct SSMHANDLE * pSSM, uint32_t u32Version);
1064 void vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd);
1065#endif
1066 static const QGLFormat & vboxGLFormat();
1067
1068 VBoxVHWADisplay mDisplay;
1069
1070
1071 /* we do all opengl stuff in the paintGL context,
1072 * submit the operation to be performed
1073 * @todo: could be moved outside the updateGL */
1074 void vboxPerformGLOp(PFNVBOXQGLOP pfn, void* pContext)
1075 {
1076 mpfnOp = pfn;
1077 mOpContext = pContext;
1078 updateGL();
1079 }
1080
1081// /* posts op to UI thread */
1082// int vboxExecOpSynch(PFNVBOXQGLOP pfn, void* pContext);
1083// void vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext);
1084
1085 void vboxDoProcessVHWACommands(void *pContext);
1086
1087 class VBoxVHWACommandElement * processCmdList(class VBoxVHWACommandElement * pCmd);
1088
1089 VBoxVHWASurfaceBase* handle2Surface(uint32_t h)
1090 {
1091 VBoxVHWASurfaceBase* pSurf = (VBoxVHWASurfaceBase*)mSurfHandleTable.get(h);
1092 Assert(pSurf);
1093 return pSurf;
1094 }
1095
1096 VBoxVHWAHandleTable mSurfHandleTable;
1097
1098 PFNVBOXQGLOP mpfnOp;
1099 void *mOpContext;
1100
1101 ulong mPixelFormat;
1102 bool mUsesGuestVRAM;
1103
1104 bool mRepaintNeeded;
1105
1106// bool mbVGASurfCreated;
1107 QRect mViewport;
1108
1109 class VBoxConsoleView *mView;
1110
1111 VBoxVHWASurfList *mConstructingList;
1112 int32_t mcRemaining2Contruct;
1113
1114 /* this is used in saved state restore to postpone surface restoration
1115 * till the framebuffer size is restored */
1116 VHWACommandList mOnResizeCmdList;
1117
1118 class VBoxVHWAGlProgramMngr *mpMngr;
1119};
1120
1121
1122//typedef enum
1123//{
1124// VBOXFBOVERLAY_DONE = 1,
1125// VBOXFBOVERLAY_MODIFIED,
1126// VBOXFBOVERLAY_UNTOUCHED
1127//} VBOXFBOVERLAY_RESUT;
1128
1129class VBoxQGLOverlay
1130{
1131public:
1132 VBoxQGLOverlay (class VBoxConsoleView *aView, class VBoxFrameBuffer * aContainer);
1133
1134 int onVHWACommand(struct _VBOXVHWACMD * pCommand);
1135
1136 void onVHWACommandEvent(QEvent * pEvent);
1137
1138 /**
1139 * to be called on NotifyUpdate framebuffer call
1140 * @return true if the request was processed & should not be forwarded to the framebuffer
1141 * false - otherwise */
1142 bool onNotifyUpdate (ULONG aX, ULONG aY,
1143 ULONG aW, ULONG aH);
1144
1145 /**
1146 * to be called on RequestResize framebuffer call
1147 * @return true if the request was processed & should not be forwarded to the framebuffer
1148 * false - otherwise */
1149 bool onRequestResize (ULONG /*aScreenId*/, ULONG /*aPixelFormat*/,
1150 BYTE * /*aVRAM*/, ULONG /*aBitsPerPixel*/, ULONG /*aBytesPerLine*/,
1151 ULONG /*aWidth*/, ULONG /*aHeight*/,
1152 BOOL * /*aFinished*/)
1153 {
1154 mCmdPipe.completeCurrentEvent();
1155 return false;
1156 }
1157
1158// VBOXFBOVERLAY_RESUT onPaintEvent (const QPaintEvent *pe, QRect *pRect);
1159
1160 void onResizeEvent (const class VBoxResizeEvent *re);
1161 void onResizeEventPostprocess (const class VBoxResizeEvent *re);
1162
1163 void onViewportResized(QResizeEvent * /*re*/)
1164 {
1165 vboxDoCheckUpdateViewport();
1166 mGlCurrent = false;
1167 }
1168
1169 void onViewportScrolled(int /*dx*/, int /*dy*/)
1170 {
1171 vboxDoCheckUpdateViewport();
1172 mGlCurrent = false;
1173 }
1174
1175 static bool isAcceleration2DVideoAvailable();
1176
1177 /** additional video memory required for the best 2D support performance
1178 * total amount of VRAM required is thus calculated as requiredVideoMemory + required2DOffscreenVideoMemory */
1179 static quint64 required2DOffscreenVideoMemory();
1180
1181 /* not supposed to be called by clients */
1182 int vhwaLoadExec(struct SSMHANDLE * pSSM, uint32_t u32Version);
1183 void vhwaSaveExec(struct SSMHANDLE * pSSM);
1184private:
1185 int vhwaSurfaceUnlock(struct _VBOXVHWACMD_SURF_UNLOCK *pCmd);
1186
1187 void repaintMain();
1188 void repaintOverlay()
1189 {
1190 if(mNeedOverlayRepaint)
1191 {
1192 mNeedOverlayRepaint = false;
1193 performDisplayOverlay();
1194 }
1195 if(mNeedSetVisible)
1196 {
1197 mNeedSetVisible = false;
1198 mpOverlayWidget->setVisible(true);
1199 }
1200 }
1201 void repaint()
1202 {
1203 repaintOverlay();
1204 repaintMain();
1205 }
1206
1207 void makeCurrent()
1208 {
1209 if(!mGlCurrent)
1210 {
1211 mGlCurrent = true;
1212 mpOverlayWidget->makeCurrent();
1213 }
1214 }
1215
1216 void performDisplayOverlay()
1217 {
1218 if(mOverlayVisible)
1219 {
1220#if 0
1221 mpOverlayWidget->updateGL();
1222#else
1223 makeCurrent();
1224 mpOverlayWidget->performDisplayAndSwap(false);
1225#endif
1226 }
1227 }
1228
1229// void vboxOpExit()
1230// {
1231// performDisplayOverlay();
1232// mGlCurrent = false;
1233// }
1234
1235
1236 void vboxSetGlOn(bool on);
1237 bool vboxGetGlOn() { return mGlOn; }
1238 bool vboxSynchGl();
1239 void vboxDoVHWACmdExec(void *cmd);
1240 void vboxShowOverlay(bool show);
1241 void vboxDoCheckUpdateViewport();
1242 void vboxDoVHWACmd(void *cmd);
1243 void addMainDirtyRect(const QRect & aRect);
1244// void vboxUpdateOverlayPosition(const QPoint & pos);
1245 void vboxCheckUpdateOverlay(const QRect & rect);
1246 VBoxVHWACommandElement * processCmdList(VBoxVHWACommandElement * pCmd);
1247
1248 int vhwaConstruct(struct _VBOXVHWACMD_HH_CONSTRUCT *pCmd);
1249
1250 VBoxGLWidget *mpOverlayWidget;
1251 class VBoxConsoleView *mView;
1252 class VBoxFrameBuffer *mContainer;
1253 bool mGlOn;
1254 bool mOverlayWidgetVisible;
1255 bool mOverlayVisible;
1256 bool mGlCurrent;
1257 bool mProcessingCommands;
1258 bool mNeedOverlayRepaint;
1259 bool mNeedSetVisible;
1260 QRect mOverlayViewport;
1261 VBoxVHWADirtyRect mMainDirtyRect;
1262
1263 VBoxVHWACommandElementProcessor mCmdPipe;
1264
1265 /* this is used in saved state restore to postpone surface restoration
1266 * till the framebuffer size is restored */
1267 VHWACommandList mOnResizeCmdList;
1268};
1269
1270
1271template <class T>
1272class VBoxOverlayFrameBuffer : public T
1273{
1274public:
1275 VBoxOverlayFrameBuffer (class VBoxConsoleView *aView)
1276 : T(aView),
1277 mOverlay(aView, this)
1278 {}
1279
1280
1281 STDMETHOD(ProcessVHWACommand)(BYTE *pCommand)
1282 {
1283 return mOverlay.onVHWACommand((struct _VBOXVHWACMD*)pCommand);
1284 }
1285
1286 void doProcessVHWACommand(QEvent * pEvent)
1287 {
1288 mOverlay.onVHWACommandEvent(pEvent);
1289 }
1290
1291 STDMETHOD(RequestResize) (ULONG aScreenId, ULONG aPixelFormat,
1292 BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine,
1293 ULONG aWidth, ULONG aHeight,
1294 BOOL *aFinished)
1295 {
1296 if(mOverlay.onRequestResize (aScreenId, aPixelFormat,
1297 aVRAM, aBitsPerPixel, aBytesPerLine,
1298 aWidth, aHeight,
1299 aFinished))
1300 {
1301 return S_OK;
1302 }
1303 return T::RequestResize (aScreenId, aPixelFormat,
1304 aVRAM, aBitsPerPixel, aBytesPerLine,
1305 aWidth, aHeight,
1306 aFinished);
1307 }
1308
1309 STDMETHOD(NotifyUpdate) (ULONG aX, ULONG aY,
1310 ULONG aW, ULONG aH)
1311 {
1312 if(mOverlay.onNotifyUpdate(aX, aY, aW, aH))
1313 return S_OK;
1314 return T::NotifyUpdate(aX, aY, aW, aH);
1315 }
1316
1317// void paintEvent (QPaintEvent *pe)
1318// {
1319// QRect rect;
1320// VBOXFBOVERLAY_RESUT res = mOverlay.onPaintEvent(pe, &rect);
1321// switch(res)
1322// {
1323// case VBOXFBOVERLAY_MODIFIED:
1324// {
1325// QPaintEvent modified(rect);
1326// T::paintEvent(&modified);
1327// } break;
1328// case VBOXFBOVERLAY_UNTOUCHED:
1329// T::paintEvent(pe);
1330// break;
1331// default:
1332// break;
1333// }
1334// }
1335
1336 void resizeEvent (VBoxResizeEvent *re)
1337 {
1338 mOverlay.onResizeEvent(re);
1339 T::resizeEvent(re);
1340 mOverlay.onResizeEventPostprocess(re);
1341 }
1342
1343 void viewportResized(QResizeEvent * re)
1344 {
1345 mOverlay.onViewportResized(re);
1346 T::viewportResized(re);
1347 }
1348
1349 void viewportScrolled(int dx, int dy)
1350 {
1351 mOverlay.onViewportScrolled(dx, dy);
1352 T::viewportScrolled(dx, dy);
1353 }
1354private:
1355 VBoxQGLOverlay mOverlay;
1356};
1357
1358#endif
1359
1360#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