VBoxFBOverlay.h revision 89edcb4f68deee74e393c7af9c759bb9d2a92076
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* VBoxFrameBuffer Overly classes declarations
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef __VBoxFBOverlay_h__
#define __VBoxFBOverlay_h__
#if defined (VBOX_GUI_USE_QGL)
#include <QGLWidget>
#include <iprt/critsect.h>
#ifdef DEBUG
#else
#define VBOXQGLLOG(_m)
#endif
#define VBOXQGLLOG_ENTER(_m)
//do{VBOXQGLLOG(("==>[%s]:", __FUNCTION__)); VBOXQGLLOG(_m);}while(0)
#define VBOXQGLLOG_EXIT(_m)
//do{VBOXQGLLOG(("<==[%s]:", __FUNCTION__)); VBOXQGLLOG(_m);}while(0)
#ifdef DEBUG
#define VBOXQGL_ASSERTNOERR() \
}while(0)
#define VBOXQGL_CHECKERR(_op) \
do { \
glGetError(); \
_op \
VBOXQGL_ASSERTNOERR(); \
}while(0)
#else
#define VBOXQGL_ASSERTNOERR() \
do {}while(0)
#define VBOXQGL_CHECKERR(_op) \
do { \
_op \
}while(0)
#endif
#ifdef DEBUG
#define VBOXGETTIME() RTTimeNanoTS()
VBOXQGLLOG(_m); \
}while(0)
{
const char* mMsg;
};
#else
#define VBOXQGLLOG_METHODTIME(_m)
#endif
VBOXQGLLOG((_p " x(%d), y(%d), w(%d), h(%d)" _s, (_pr)->x(), (_pr)->y(), (_pr)->width(), (_pr)->height()));\
}while(0)
}while(0)
{
mIsClear(true)
{}
{
{
mIsClear = false;
}
else
{
mIsClear = true;
}
}
{
return;
mIsClear = false;
}
{
return;
}
{
{
mIsClear = true;
}
else
{
mIsClear = false;
}
}
{
if(isClear())
{
}
return mRect;
}
bool intersects(const VBoxVHWADirtyRect & aRect) const {return mIsClear ? false : aRect.intersects(mRect);}
bool mIsClear;
};
{
VBoxVHWAColorKey() :
mUpper(0),
mLower(0)
{}
{}
bool operator==(const VBoxVHWAColorKey & other) const { return mUpper == other.mUpper && mLower == other.mLower; }
};
{
mMask(0),
mRange(0),
mOffset(32),
mcBits(0)
{}
};
{
// VBoxVHWAColorFormat(GLint aInternalFormat, GLenum aFormat, GLenum aType, uint32_t aDataFormat);
bool isValid() const {return mBitsPerPixel != 0; }
// uint32_t bitsPerPixelDd() const { return mBitsPerPixelDd; }
const VBoxVHWAColorComponent& r() const {return mR;}
const VBoxVHWAColorComponent& g() const {return mG;}
const VBoxVHWAColorComponent& b() const {return mB;}
const VBoxVHWAColorComponent& a() const {return mA;}
// uint32_t mBitsPerPixelDd;
};
{
VBoxVHWATexture() {}
// GLuint texture() {return mTexture;}
uint32_t rectSizeTex(const QRect * pRect) {return pRect->width() * pRect->height() * mBytesPerPixelTex;}
uchar * pointAddress(int x, int y)
{
x = toXTex(x);
y = toYTex(y);
return pointAddressTex(x, y);
}
virtual void initParams();
void uninit();
};
{
VBoxVHWATextureNP2() : VBoxVHWATexture() {}
mTexRect = QRect(0, 0, aRect.width()/aFormat.widthCompression(), aRect.height()/aFormat.heightCompression());
}
};
{
VBoxVHWATextureNP2Rect() : VBoxVHWATextureNP2() {}
};
{
};
{
void** mTable;
};
/* data flow:
* I. NON-Yinverted surface:
* mem->tex->fb
* 2.blt
* srcTex->invFB->tex->fb
* |->mem
*
* II. Yinverted surface:
* mem->tex->fb
* 2.blt
* srcTex->fb->tex
* |->mem
*
* III. flip support:
* 1. Yinverted<->NON-YInverted conversion :
* mem->tex-(rotate model view, force LAZY complete fb update)->invFB->tex
* fb-->| |->mem
* */
{
#if 0
bool aIsYInverted,
#endif
const QRect & aVisTargRect,
bool bVGA);
void uninit();
static void globalInit();
// int blt(const QRect * aDstRect, VBoxVHWASurfaceBase * aSrtSurface, const QRect * aSrcRect, const VBoxVHWAColorKey * pDstCKeyOverride, const VBoxVHWAColorKey * pSrcCKeyOverride);
int unlock();
void setRects(VBoxVHWASurfaceBase *pPrimary, const QRect & aTargRect, const QRect & aSrcRect, const QRect & aVisibleTargRect, bool bForceReinit);
void setTargRectPosition(VBoxVHWASurfaceBase *pPrimary, const QPoint & aPoint, const QRect & aVisibleTargRect);
bool addressAlocated() const { return mFreeAddress; }
// ulong bytesPerPixel() { return mpTex[0]->bytesPerPixel(); }
// ulong bitsPerPixelDd() { return mColorFormat.bitsPerPixelDd(); }
{
if(ckey)
{
mDstBltCKey = *ckey;
}
else
{
mpDstBltCKey = NULL;
}
}
{
if(ckey)
{
mSrcBltCKey = *ckey;
}
else
{
mpSrcBltCKey = NULL;
}
}
{
if(ckey)
{
}
else
{
}
}
{
if(ckey)
{
}
else
{
}
}
{
if(ckey)
{
}
else
{
}
}
{
if(ckey)
{
}
else
{
}
}
const VBoxVHWAColorKey * getActiveSrcOverlayCKey()
{
return mpSrcOverlayCKey;
}
{
}
static int setCKey(class VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst);
void doSetRectValuesInternal(const QRect & aTargRect, const QRect & aSrcRect, const QRect & aVisTargRect);
void deleteDisplay();
int performBlt(const QRect * pDstRect, VBoxVHWASurfaceBase * pSrcSurface, const QRect * pSrcRect, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool blt);
void doMultiTex2FB(const QRect * pDstRect, VBoxVHWATexture * pDstTex, const QRect * pSrcRect, int cSrcTex);
int mLockCount;
/* memory buffer not reflected in fm and texture, e.g if memory buffer is replaced or in case of lock/unlock */
bool mFreeAddress;
#ifdef DEBUG
#endif
};
{
{
if(pOld)
{
}
}
void clear()
{
{
}
}
{
}
{
}
};
{
VBoxVHWADisplay() :
// ,
// mSurfPrimary(NULL)
{}
{
if(pVga)
{
}
// mSurfPrimary = pVga;
return old;
}
{
return old;
}
VBoxVHWASurfaceBase * getVGA() const
{
return mSurfVGA;
}
{
}
{
}
{
if(!hasOverlay(pSurf))
}
{
{
{
return true;
}
}
return false;
}
{
}
void performDisplay()
{
{
if(pOverlay)
{
}
}
}
};
typedef void (VBoxGLWidget::*PFNVBOXQGLOP)(void* );
typedef void (*PFNVBOXQGLFUNC)(void*, void*);
typedef enum
{
typedef struct VBOXVHWACALLBACKINFO
{
void * pContext;
typedef struct VBOXVHWAFUNCCALLBACKINFO
{
void * pContext1;
void * pContext2;
{
{
}
{
}
{
}
{
u.mFuncCallback = aOp;
}
{
switch(aType)
{
case VBOXVHWA_PIPECMD_PAINT:
break;
case VBOXVHWA_PIPECMD_VHWA:
break;
case VBOXVHWA_PIPECMD_OP:
break;
case VBOXVHWA_PIPECMD_FUNC:
break;
default:
Assert(0);
break;
}
}
union
{
struct _VBOXVHWACMD * mpCmd;
}u;
};
{
{}
{
if(mpLast)
{
}
else
{
}
}
{
if(mpLast)
{
return pHead;
}
return NULL;
}
};
{
{
}
{
}
{
if(mpFirst)
{
return ret;
}
return NULL;
}
};
{
class VBoxVHWACommandElement * detachCmdList(class VBoxVHWACommandElement * pFirst2Free, VBoxVHWACommandElement * pLast2Free);
bool mbNewEvent;
};
{
};
{
~VBoxGLWidget();
bool vboxUsesGuestVRAM() { return mUsesGuestVRAM; }
#ifdef VBOX_WITH_VIDEOHWACCEL
bool hasSurfaces() const;
bool hasVisibleOverlays();
const QRect & overlaysRectUnion();
#endif
// void vboxPaintEvent (QPaintEvent *pe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoPaint, pe); }
void vboxResizeEvent (class VBoxResizeEvent *re) {vboxPerformGLOp(&VBoxGLWidget::vboxDoResize, re); }
void vboxProcessVHWACommands(class VBoxVHWACommandElementProcessor * pPipe) {vboxPerformGLOp(&VBoxGLWidget::vboxDoProcessVHWACommands, pPipe);}
#ifdef VBOX_WITH_VIDEOHWACCEL
void vboxVHWACmd (struct _VBOXVHWACMD * pCmd) {vboxPerformGLOp(&VBoxGLWidget::vboxDoVHWACmd, pCmd);}
#endif
void paintGL()
{
if(mpfnOp)
{
}
// else
// {
// }
}
void initializeGL();
void vboxDoResize(void *re);
// void vboxDoPaint(void *rec);
#ifdef VBOXQGL_DBG_SURF
void vboxDoTestSurfaces(void *context);
#endif
#ifdef VBOX_WITH_VIDEOHWACCEL
void vboxDoVHWACmdExec(void *cmd);
void vboxDoVHWACmdAndFree(void *cmd);
void vboxDoVHWACmd(void *cmd);
{
if (pSurface->addressAlocated())
{
if(addr)
{
}
}
}
void vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd);
#endif
static const QGLFormat & vboxGLFormat();
/* we do all opengl stuff in the paintGL context,
* submit the operation to be performed
* @todo: could be moved outside the updateGL */
{
updateGL();
}
// /* posts op to UI thread */
// int vboxExecOpSynch(PFNVBOXQGLOP pfn, void* pContext);
// void vboxExecOnResize(PFNVBOXQGLOP pfn, void* pContext);
void vboxDoProcessVHWACommands(void *pContext);
{
return pSurf;
}
void *mOpContext;
bool mUsesGuestVRAM;
// bool mbVGASurfCreated;
/* this is used in saved state restore to postpone surface restoration
* till the framebuffer size is restored */
};
typedef enum
{
VBOXFBOVERLAY_DONE = 1,
{
/**
* to be called on NotifyUpdate framebuffer call
* @return true if the request was processed & should not be forwarded to the framebuffer
* false - otherwise */
static bool isAcceleration2DVideoAvailable();
/* not supposed to be called by clients */
void makeCurrent()
{
if(!mGlCurrent)
{
mGlCurrent = true;
}
}
void performDisplayOverlay()
{
if(mOverlayVisible)
{
#if 0
#else
makeCurrent();
#endif
}
}
void vboxOpExit()
{
mGlCurrent = false;
}
void vboxSetGlOn(bool on);
bool vboxGetGlOn() { return mGlOn; }
void vboxSynchGl();
void vboxDoVHWACmdExec(void *cmd);
void vboxShowOverlay(bool show);
void vboxDoCheckUpdateViewport();
void vboxDoVHWACmd(void *cmd);
// void vboxUpdateOverlayPosition(const QPoint & pos);
bool mGlOn;
bool mOverlayWidgetVisible;
bool mOverlayVisible;
bool mGlCurrent;
bool mProcessingCommands;
/* this is used in saved state restore to postpone surface restoration
* till the framebuffer size is restored */
};
#endif
#endif /* #ifndef __VBoxFBOverlay_h__ */