VBoxFBQGL.cpp revision 64082f4699f276693cf5b1ec5886ac12234af115
/* $Id$ */
/** @file
* VBoxFBQGL Opengl-based FrameBuffer implementation
*/
/*
* Copyright (C) 2009 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.
*/
#if defined (VBOX_GUI_USE_QGL)
#define LOG_GROUP LOG_GROUP_GUI
#include "VBoxFrameBuffer.h"
#include "VBoxConsoleView.h"
#include "VBoxProblemReporter.h"
#include "VBoxGlobal.h"
/* Qt includes */
#include <QGLWidget>
#ifdef VBOX_WITH_VIDEOHWACCEL
#include <VBox/VBoxVideo.h>
#endif
#include <iprt/semaphore.h>
#include <QFile>
#include <QTextStream>
#ifdef VBOXQGL_PROF_BASE
# ifdef VBOXQGL_DBG_SURF
# define VBOXQGL_PROF_WIDTH 1400
# define VBOXQGL_PROF_HEIGHT 1050
# else
# define VBOXQGL_PROF_WIDTH 1400
# define VBOXQGL_PROF_HEIGHT 1050
//#define VBOXQGL_PROF_WIDTH 720
//#define VBOXQGL_PROF_HEIGHT 480
# endif
#endif
#define VBOXQGL_STATE_NAMEBASE "QGLVHWAData"
#define VBOXQGL_STATE_VERSION 1
#ifdef DEBUG_misha
# define VBOXQGL_STATE_DEBUG
#endif
#ifdef VBOXQGL_STATE_DEBUG
#define VBOXQGL_STATE_START_MAGIC 0x12345678
#define VBOXQGL_STATE_STOP_MAGIC 0x87654321
#define VBOXQGL_STATE_SURFSTART_MAGIC 0x9abcdef1
#define VBOXQGL_STATE_SURFSTOP_MAGIC 0x1fedcba9
#define VBOXQGL_STATE_OVERLAYSTART_MAGIC 0x13579bdf
#define VBOXQGL_STATE_OVERLAYSTOP_MAGIC 0xfdb97531
#define VBOXQGL_SAVE_START(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_START_MAGIC); AssertRC(rc);}while(0)
#define VBOXQGL_SAVE_STOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_STOP_MAGIC); AssertRC(rc);}while(0)
#define VBOXQGL_SAVE_SURFSTART(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_SURFSTART_MAGIC); AssertRC(rc);}while(0)
#define VBOXQGL_SAVE_SURFSTOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_SURFSTOP_MAGIC); AssertRC(rc);}while(0)
#define VBOXQGL_SAVE_OVERLAYSTART(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_OVERLAYSTART_MAGIC); AssertRC(rc);}while(0)
#define VBOXQGL_SAVE_OVERLAYSTOP(_pSSM) do{ int rc = SSMR3PutU32(_pSSM, VBOXQGL_STATE_OVERLAYSTOP_MAGIC); AssertRC(rc);}while(0)
do{ \
{ \
}\
}while(0)
#define VBOXQGL_LOAD_OVERLAYSTART(_pSSM) VBOXQGL_LOAD_CHECK(_pSSM, VBOXQGL_STATE_OVERLAYSTART_MAGIC)
#else
#define VBOXQGL_SAVE_START(_pSSM) do{}while(0)
#define VBOXQGL_SAVE_STOP(_pSSM) do{}while(0)
#define VBOXQGL_SAVE_SURFSTART(_pSSM) do{}while(0)
#define VBOXQGL_SAVE_SURFSTOP(_pSSM) do{}while(0)
#define VBOXQGL_SAVE_OVERLAYSTART(_pSSM) do{}while(0)
#define VBOXQGL_SAVE_OVERLAYSTOP(_pSSM) do{}while(0)
#define VBOXQGL_LOAD_START(_pSSM) do{}while(0)
#define VBOXQGL_LOAD_STOP(_pSSM) do{}while(0)
#define VBOXQGL_LOAD_SURFSTART(_pSSM) do{}while(0)
#define VBOXQGL_LOAD_SURFSTOP(_pSSM) do{}while(0)
#define VBOXQGL_LOAD_OVERLAYSTART(_pSSM) do{}while(0)
#define VBOXQGL_LOAD_OVERLAYSTOP(_pSSM) do{}while(0)
#endif
#define VBOXVHWA_NUMFOURCC 4
typedef char GLchar;
#ifndef GL_COMPILE_STATUS
# define GL_COMPILE_STATUS 0x8b81
#endif
#ifndef GL_LINK_STATUS
# define GL_LINK_STATUS 0x8b82
#endif
#ifndef GL_FRAGMENT_SHADER
# define GL_FRAGMENT_SHADER 0x8b30
#endif
#ifndef GL_VERTEX_SHADER
# define GL_VERTEX_SHADER 0x8b31
#endif
/* GL_ARB_multitexture */
#ifndef GL_TEXTURE0
# define GL_TEXTURE0 0x84c0
#endif
#ifndef GL_TEXTURE1
# define GL_TEXTURE1 0x84c1
#endif
#ifndef GL_MAX_TEXTURE_COORDS
# define GL_MAX_TEXTURE_COORDS 0x8871
#endif
#ifndef GL_MAX_TEXTURE_IMAGE_UNITS
# define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
#endif
#ifndef APIENTRY
# define APIENTRY
#endif
typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2D) (GLenum texture, GLdouble v0, GLdouble v1);
/* GL_ARB_texture_rectangle */
#ifndef GL_TEXTURE_RECTANGLE
# define GL_TEXTURE_RECTANGLE 0x84F5
#endif
/* GL_ARB_shader_objects */
/* GL_ARB_fragment_shader */
typedef GLvoid (APIENTRY *PFNVBOXVHWA_SHADER_SOURCE) (GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_ATTACHED_SHADERS) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADER_INFO_LOG) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAM_INFO_LOG) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4I)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
/* GL_ARB_pixel_buffer_object*/
#ifndef Q_WS_MAC
/* apears to be defined on mac */
typedef ptrdiff_t GLsizeiptr;
#endif
#ifndef GL_READ_ONLY
# define GL_READ_ONLY 0x88B8
#endif
#ifndef GL_WRITE_ONLY
# define GL_WRITE_ONLY 0x88B9
#endif
#ifndef GL_READ_WRITE
# define GL_READ_WRITE 0x88BA
#endif
#ifndef GL_STREAM_DRAW
# define GL_STREAM_DRAW 0x88E0
#endif
#ifndef GL_STREAM_READ
# define GL_STREAM_READ 0x88E1
#endif
#ifndef GL_STREAM_COPY
# define GL_STREAM_COPY 0x88E2
#endif
#ifndef GL_PIXEL_PACK_BUFFER
# define GL_PIXEL_PACK_BUFFER 0x88EB
#endif
#ifndef GL_PIXEL_UNPACK_BUFFER
# define GL_PIXEL_UNPACK_BUFFER 0x88EC
#endif
#ifndef GL_PIXEL_PACK_BUFFER_BINDING
# define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
#endif
#ifndef GL_PIXEL_UNPACK_BUFFER_BINDING
# define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
#endif
typedef GLvoid (APIENTRY *PFNVBOXVHWA_BUFFER_DATA)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
/*****************/
/* functions */
#if 0
#if defined Q_WS_WIN
#else
#error "Port me!!!"
#endif
#endif
do { \
{ \
AssertBreakpoint(); \
{ \
AssertBreakpoint(); \
{ \
AssertBreakpoint(); \
(_rc)++; \
} \
} \
} \
}while(0)
do { \
{ \
AssertBreakpoint(); \
(_rc)++; \
} \
}while(0)
//#define VBOXVHWA_PFNINIT_OBJECT_ARB(_t, _v, _rc) VBOXVHWA_PFNINIT(_t, _v, #_v"ObjectARB" ,_rc)
do { \
{ \
AssertBreakpoint(); \
(_rc)++; \
} \
}while(0)
//#define VBOXVHWA_PFNINIT_ARB(_t, _v, _rc) VBOXVHWA_PFNINIT(_t, _v, #_v"ARB" ,_rc)
do { \
{ \
AssertBreakpoint(); \
(_rc)++; \
} \
}while(0)
static bool g_vboxVHWAGlSupportInitialized = false;
/* vbox version in the format 0x00mjmnbl
* in case of a failure contains -1 (0xffffffff) */
static int g_vboxVHWAGlVersion = 0;
static bool g_GL_ARB_multitexture = false;
static bool g_GL_ARB_shader_objects = false;
static bool g_GL_ARB_fragment_shader = false;
static bool g_GL_ARB_pixel_buffer_object = false;
static bool g_GL_ARB_texture_rectangle = false;
static bool g_GL_EXT_texture_rectangle = false;
static bool g_GL_NV_texture_rectangle = false;
static bool g_GL_ARB_texture_non_power_of_two = false;
/* gl features supported */
static bool g_vboxVHWAGlShaderSupported = false;
static bool g_vboxVHWAGlTextureRectangleSupported = false;
static bool g_vboxVHWAGlTextureNP2Supported = false;
static bool g_vboxVHWAGlPBOSupported = false;
/* vhwa features supported */
static uint32_t g_vboxVHWAFourccSupportedCount = 0;
static int vboxVHWAGlParseSubver(const GLubyte * ver, const GLubyte ** pNext, bool bSpacePrefixAllowed)
{
int val = 0;
for(;;++ver)
{
{
if(!val)
{
if(*ver == '0')
continue;
}
else
{
val *= 10;
}
}
else if(*ver == '.')
{
break;
}
else if(*ver == '\0')
{
break;
}
{
{
if(!val)
{
continue;
}
}
/* treat this as the end ov version string */
break;
}
else
{
Assert(0);
val = -1;
break;
}
}
return val;
}
{
if(iVer)
{
iVer <<= 16;
if(ver)
{
if(tmp >= 0)
{
if(ver)
{
if(tmp >= 0)
{
}
else
{
Assert(0);
iVer = -1;
}
}
}
else
{
Assert(0);
iVer = -1;
}
}
}
return iVer;
}
{
int rc = 0;
do
{
rc = 0;
{
}
else if(g_GL_ARB_multitexture)
{
}
else
{
break;
}
if(RT_FAILURE(rc))
break;
/* take the minimum of those */
if(maxUnits < 2)
{
VBOXQGLLOGREL(("Max Tex Coord or Img Units < 2 disabling MultiTex support\n"));
break;
}
}while(0);
do
{
rc = 0;
g_vboxVHWAGlPBOSupported = false;
{
}
else
{
break;
}
if(RT_FAILURE(rc))
break;
g_vboxVHWAGlPBOSupported = true;
} while(0);
do
{
rc = 0;
g_vboxVHWAGlShaderSupported = false;
{
}
else if(g_GL_ARB_shader_objects && g_GL_ARB_fragment_shader)
{
//TODO: VBOXVHWA_PFNINIT(PFNVBOXVHWA_IS_SHADER, IsShader, rc);
//TODO: VBOXVHWA_PFNINIT(PFNVBOXVHWA_IS_PROGRAM, IsProgram, rc);
VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_GET_ATTACHED_SHADERS, GetAttachedShaders, GetAttachedObjectsARB, rc);
}
else
{
break;
}
if(RT_FAILURE(rc))
break;
g_vboxVHWAGlShaderSupported = true;
} while(0);
{
}
else
{
}
}
static void vboxVHWAGlInitFeatureSupport()
{
{
if(g_vboxVHWAGlMultiTexNumSupported >= 4)
{
/* YV12 currently requires 3 units (for each color component)
* + 1 unit for dst texture for color-keying + 3 units for each color component
* TODO: we could store YV12 data in one texture to eliminate this requirement*/
}
}
else
{
}
}
{
return;
if(!pContext)
{
if(!pTmpContextHolder)
{
pWidget->makeCurrent();
}
// QGLContext * pTmpContext = new QGLContext(QGLFormat::defaultFormat());
// bool bCreated = pTmpContext->create();
// Assert(pTmpContext);
// Assert(pTmpContext->isValid());
//
// pTmpContext->makeCurrent();
// pTmpContextHolder = pTmpContext;
}
);
Assert(g_vboxVHWAGlVersion > 0);
if(g_vboxVHWAGlVersion < 0)
{
g_vboxVHWAGlVersion = 0;
}
else
{
);
}
if(!bHasGlContext)
{
}
g_vboxVHWAGlSupportInitialized = true;
}
static bool vboxVHWASupportedInternal()
{
if(g_vboxVHWAGlVersion <= 0)
{
/* error occurred while gl info initialization */
return false;
}
#ifndef DEBUG
/* in case we do not support shaders & multitexturing we can not supprt dst colorkey,
* no sense to report Video Acceleration supported */
return false;
#endif
if(g_vboxVHWAGlMultiTexNumSupported < 2)
return false;
/* color conversion now supported only GL_TEXTURE_RECTANGLE
* in this case only stretching is accelerated
* report as unsupported, TODO: probably should report as supported for stretch acceleration */
return false;
return true;
}
class VBoxVHWACommandProcessEvent : public QEvent
{
public:
{
}
private:
friend class VBoxGLWidget;
};
{
mTable = new void*[initialSize];
mcUsage = 0;
}
{
delete[] mTable;
}
{
if(!data)
return VBOXVHWA_SURFHANDLE_INVALID;
{
/* @todo: resize */
Assert(0);
}
return VBOXVHWA_SURFHANDLE_INVALID;
for(int k = 0; k < 2; ++k)
{
{
if(!mTable[i])
{
mCursor = i+1;
return i;
}
}
}
Assert(0);
return VBOXVHWA_SURFHANDLE_INVALID;
}
{
if(mcSize <= h)
return false;
if(h == 0)
return false;
if(mTable[h])
return false;
return true;
}
{
Assert(h > 0);
return mTable[h];
}
{
if(val)
{
doRemove(h);
}
return val;
}
{
++mcUsage;
}
{
mTable[h] = 0;
--mcUsage;
}
static VBoxVHWATexture* vboxVHWATextureCreate(const QRect & aRect, const VBoxVHWAColorFormat & aFormat, bool bVGA)
{
if(!bVGA && g_GL_ARB_pixel_buffer_object)
{
VBOXQGLLOG(("VBoxVHWATextureNP2RectPBO\n"));
}
{
VBOXQGLLOG(("VBoxVHWATextureNP2Rect\n"));
}
else if(g_GL_ARB_texture_non_power_of_two)
{
VBOXQGLLOG(("VBoxVHWATextureNP2\n"));
}
VBOXQGLLOG(("VBoxVHWATexture\n"));
}
class VBoxVHWAGlShader
{
public:
mShader(0),
{}
// virtual ~VBoxVHWAGlShader();
int init();
// virtual int initUniforms(class VBoxVHWAGlProgram * pProgram){}
void uninit();
bool isInitialized() { return mShader; }
private:
const char *mRcName;
};
int VBoxVHWAGlShader::init()
{
// Assert(!isInitialized());
if(isInitialized())
return VINF_ALREADY_INITIALIZED;
{
Assert(0);
return VERR_GENERAL_FAILURE;
}
if(!mShader)
return VERR_GENERAL_FAILURE;
// int length = program.length();
);
);
);
#ifdef DEBUG
delete pBuf;
#endif
if(compiled)
{
return VINF_SUCCESS;
}
);
mShader = 0;
return VERR_GENERAL_FAILURE;
}
void VBoxVHWAGlShader::uninit()
{
if(!isInitialized())
return;
);
mShader = 0;
}
class VBoxVHWAGlProgram
{
public:
virtual int init();
virtual void uninit();
virtual int start();
virtual int stop();
bool isInitialized() { return mProgram; }
private:
int mcShaders;
};
mProgram(0),
mcShaders(0)
{
if(acShaders)
{
}
}
{
uninit();
if(mpShaders)
{
}
}
int VBoxVHWAGlProgram::init()
{
Assert(!isInitialized());
if(isInitialized())
return VINF_ALREADY_INITIALIZED;
if(!mcShaders)
return VERR_GENERAL_FAILURE;
int rc = VINF_SUCCESS;
for(int i = 0; i < mcShaders; i++)
{
if(RT_FAILURE(rc))
{
break;
}
}
if(RT_FAILURE(rc))
{
return rc;
}
if(mProgram)
{
for(int i = 0; i < mcShaders; i++)
{
);
}
);
#ifdef DEBUG
delete pBuf;
#endif
if(linked)
{
return VINF_SUCCESS;
}
);
mProgram = 0;
}
return VERR_GENERAL_FAILURE;
}
void VBoxVHWAGlProgram::uninit()
{
if(!isInitialized())
return;
);
mProgram = 0;
}
int VBoxVHWAGlProgram::start()
{
);
return VINF_SUCCESS;
}
int VBoxVHWAGlProgram::stop()
{
vboxglUseProgram(0);
);
return VINF_SUCCESS;
}
#define VBOXVHWA_PROGRAM_DSTCOLORKEY 0x00000001
#define VBOXVHWA_PROGRAM_SRCCOLORKEY 0x00000002
#define VBOXVHWA_PROGRAM_COLORCONV 0x00000004
class VBoxVHWAGlProgramVHWA : public VBoxVHWAGlProgram
{
public:
VBoxVHWAGlProgramVHWA(/*class VBoxVHWAGlProgramMngr *aMngr, */uint32_t type, uint32_t fourcc, VBoxVHWAGlShader ** apShaders, int acShaders);
virtual int init();
{
}
{
}
private:
// VBoxVHWAGlProgram *mpProgram;
//
// class VBoxVHWAGlProgramMngr *mpMngr;
};
VBoxVHWAGlProgramVHWA::VBoxVHWAGlProgramVHWA(/*VBoxVHWAGlProgramMngr *aMngr, */uint32_t type, uint32_t fourcc, VBoxVHWAGlShader ** apShaders, int acShaders) :
mUniDstUpperColor(-1),
mUniDstLowerColor(-1),
mUniSrcUpperColor(-1),
mUniSrcLowerColor(-1),
// mpMngr(aMngr),
mDstTex(-1),
mUniDstTex(-1),
mSrcTex(-1),
mUniSrcTex(-1),
mVTex(-1),
mUniVTex(-1),
mUTex(-1),
mUniUTex(-1)
{}
int VBoxVHWAGlProgramVHWA::init()
{
if(RT_FAILURE(rc))
return rc;
if(rc == VINF_ALREADY_INITIALIZED)
return rc;
start();
do
{
if(mUniSrcTex == -1)
break;
if(type() & VBOXVHWA_PROGRAM_DSTCOLORKEY)
{
);
mSrcTex = 1;
if(mUniDstTex == -1)
break;
);
mDstTex = 0;
if(mUniDstLowerColor == -1)
break;
);
}
else
{
);
mSrcTex = 0;
}
if(type() & VBOXVHWA_PROGRAM_SRCCOLORKEY)
{
if(mUniSrcLowerColor == -1)
break;
);
}
if(type() & VBOXVHWA_PROGRAM_COLORCONV)
{
switch(fourcc())
{
case FOURCC_YV12:
{
if(mUniVTex == -1)
break;
);
tex++;
if(mUniUTex == -1)
break;
);
break;
}
case FOURCC_UYVY:
case FOURCC_YUY2:
case FOURCC_AYUV:
break;
default:
Assert(0);
break;
}
}
rc = VINF_SUCCESS;
} while(0);
stop();
if(rc == VINF_SUCCESS)
return VINF_SUCCESS;
Assert(0);
return VERR_GENERAL_FAILURE;
}
{
Assert(isInitialized());
if(!isInitialized())
return VERR_GENERAL_FAILURE;
return VINF_ALREADY_INITIALIZED;
mDstUpperR = r;
mDstUpperG = g;
mDstUpperB = b;
return VINF_SUCCESS;
}
{
Assert(isInitialized());
if(!isInitialized())
return VERR_GENERAL_FAILURE;
return VINF_ALREADY_INITIALIZED;
// VBOXQGLLOG(("setDstCKeyLowerRange: r(%f), g(%f), b(%f)\n", r, g, b));
);
mDstLowerR = r;
mDstLowerG = g;
mDstLowerB = b;
return VINF_SUCCESS;
}
{
Assert(isInitialized());
if(!isInitialized())
return VERR_GENERAL_FAILURE;
return VINF_ALREADY_INITIALIZED;
mSrcUpperR = r;
mSrcUpperG = g;
mSrcUpperB = b;
return VINF_SUCCESS;
}
{
Assert(isInitialized());
if(!isInitialized())
return VERR_GENERAL_FAILURE;
return VINF_ALREADY_INITIALIZED;
);
mSrcLowerR = r;
mSrcLowerG = g;
mSrcLowerB = b;
return VINF_SUCCESS;
}
class VBoxVHWAGlProgramMngr
{
public:
// mShaderCConvAYUVVoid(":/cconvAYUV_void.c", GL_FRAGMENT_SHADER),
// mShaderCConvBGRVoid(":/cconvBGR_void.c", GL_FRAGMENT_SHADER),
// mShaderCConvUYVYVoid(":/cconvUYVY_void.c", GL_FRAGMENT_SHADER),
// mShaderCConvYUY2Void(":/cconvYUY2_void.c", GL_FRAGMENT_SHADER),
// mShaderCConvYV12Void(":/cconvYV12_void.c", GL_FRAGMENT_SHADER),
// mShaderCKeyDstVoid(":/ckeyDst_void.c", GL_FRAGMENT_SHADER),
// mShaderCKeySrc;
// mShaderCKeySrcVoid;
{}
VBoxVHWAGlProgramVHWA * getProgram(bool bDstCKey, bool bSrcCKey, const VBoxVHWAColorFormat * pFrom, const VBoxVHWAColorFormat * pTo);
void stopCurrentProgram()
{
vboxglUseProgram(0);
);
}
private:
// int startProgram(VBoxVHWAGlProgramVHWA * pProgram) {mCurrentProgram = pProgram; return pProgram->start();}
// VBoxVHWAGlProgramVHWA * mCurrentProgram;
// VBoxVHWAGlShader mShaderCConvAYUVVoid;
// VBoxVHWAGlShader mShaderCConvBGRVoid;
// VBoxVHWAGlShader mShaderCConvUYVYVoid;
// VBoxVHWAGlShader mShaderCConvYUY2Void;
// VBoxVHWAGlShader mShaderCConvYV12Void;
// VBoxVHWAGlShader mShaderCKeyDstVoid;
// VBoxVHWAGlShader mShaderCKeySrc;
// VBoxVHWAGlShader mShaderCKeySrcVoid;
friend class VBoxVHWAGlProgramVHWA;
};
{
/* workaround for NVIDIA driver bug: ensure we attach the shader before those it is used in */
/* reserve a slot for the mShaderCConvApplyAYUV,
* in case it is not used the slot will be occupied by mShaderCConvBGR , which is ok */
cShaders++;
{
}
// ensure we don't have empty functions /* paranoya for for ATI on linux */
// else
// {
// apShaders[cShaders++] = &mShaderCKeyDstVoid;
// }
{
Assert(0);
/* disabled for now, not really necessary for video overlaying */
}
bool bFound = false;
// if(type & VBOXVHWA_PROGRAM_COLORCONV)
{
if(fourcc == FOURCC_UYVY)
{
bFound = true;
}
else if(fourcc == FOURCC_YUY2)
{
bFound = true;
}
else if(fourcc == FOURCC_YV12)
{
bFound = true;
}
else if(fourcc == FOURCC_AYUV)
{
bFound = true;
}
}
if(bFound)
{
apShaders[0] = &mShaderCConvApplyAYUV;
}
else
{
type &= (~VBOXVHWA_PROGRAM_COLORCONV);
apShaders[0] = &mShaderCConvBGR;
}
{
}
else
{
// ensure we don't have empty functions /* paranoya for for ATI on linux */
}
VBoxVHWAGlProgramVHWA *pProgram = new VBoxVHWAGlProgramVHWA(/*this, */type, fourcc, apShaders, cShaders);
return pProgram;
}
VBoxVHWAGlProgramVHWA * VBoxVHWAGlProgramMngr::getProgram(bool bDstCKey, bool bSrcCKey, const VBoxVHWAColorFormat * pFrom, const VBoxVHWAColorFormat * pTo)
{
if(bDstCKey)
{
}
if(bSrcCKey)
{
}
{
}
if(type)
return NULL;
}
VBoxVHWAGlProgramVHWA * VBoxVHWAGlProgramMngr::searchProgram(uint32_t type, uint32_t fourcc, bool bCreate)
{
// if(mCurrentProgram && mCurrentProgram->matches(type))
// return mCurrentProgram;
{
{
continue;
}
return *it;
}
if(bCreate)
{
if(pProgram)
{
return pProgram;
}
}
return NULL;
}
int VBoxVHWASurfaceBase::setCKey(VBoxVHWAGlProgramVHWA * pProgram, const VBoxVHWAColorFormat * pFormat, const VBoxVHWAColorKey * pCKey, bool bDst)
{
float r,g,b;
// pProgram->start();
// pFormat->pixel2Normalized(pCKey->upper(), &r, &g, &b);
// int rcU = pProgram->setCKeyUpperRange(r, g, b);
// Assert(RT_SUCCESS(rcU));
// pProgram->stop();
}
{
if(!addr) return;
if(mFreeAddress)
{
}
mFreeAddress = false;
if(fourcc() == FOURCC_YV12)
{
}
// makeCurrent();
// updateTexture(&mRect);
// mUpdateTex2FBRect.clear();
// Assert(mUpdateTex2FBRect.isClear());
}
void VBoxVHWASurfaceBase::globalInit()
{
VBOXQGLLOG(("globalInit\n"));
// glEnable(GL_TEXTURE_2D);
);
);
//
// VBOXQGL_CHECKERR(
// vboxglActiveTexture(GL_TEXTURE1);
// );
// VBOXQGL_CHECKERR(
// glEnable(GL_TEXTURE_2D);
// );
// VBOXQGL_CHECKERR(
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// );
// VBOXQGL_CHECKERR(
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// );
// VBOXQGL_CHECKERR(
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
// );
// VBOXQGL_CHECKERR(
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
// );
//
// VBOXQGL_CHECKERR(
// vboxglActiveTexture(GL_TEXTURE0);
// );
// VBOXQGL_CHECKERR(
// glEnable(GL_TEXTURE_2D);
// );
// VBOXQGL_CHECKERR(
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// );
// VBOXQGL_CHECKERR(
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// );
// VBOXQGL_CHECKERR(
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
// );
// VBOXQGL_CHECKERR(
// glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
// );
}
VBoxVHWASurfaceBase::VBoxVHWASurfaceBase(class VBoxGLWidget *aWidget, const QSize * aSize, const QSize * aTargSize,
bool bVGA) :
mVisibleDisplayInitialized(false),
mLockCount(0),
mFreeAddress(false),
#ifdef DEBUG
,
cFlipsCurr(0),
cFlipsTarg(0)
#endif
{
{
}
// mBytesPerPixel = calcBytesPerPixel(mColorFormat.format(), mColorFormat.type());
// mBytesPerLine = mRect.width() * mBytesPerPixel;
}
{
uninit();
}
{
if(last>1)
{
last--;
{
}
}
return val;
}
{
/* we now support only common byte-aligned data */
int numComponents = 0;
switch(format)
{
case GL_COLOR_INDEX:
case GL_RED:
case GL_GREEN:
case GL_BLUE:
case GL_ALPHA:
case GL_LUMINANCE:
numComponents = 1;
break;
case GL_RGB:
case GL_BGR_EXT:
numComponents = 3;
break;
case GL_RGBA:
case GL_BGRA_EXT:
numComponents = 4;
break;
case GL_LUMINANCE_ALPHA:
numComponents = 2;
break;
default:
Assert(0);
break;
}
int componentSize = 0;
switch(type)
{
case GL_UNSIGNED_BYTE:
case GL_BYTE:
componentSize = 1;
break;
//case GL_BITMAP:
case GL_UNSIGNED_SHORT:
case GL_SHORT:
componentSize = 2;
break;
case GL_UNSIGNED_INT:
case GL_INT:
case GL_FLOAT:
componentSize = 4;
break;
default:
Assert(0);
break;
}
return numComponents * componentSize;
}
void VBoxVHWASurfaceBase::uninit()
{
// mState->makeCurrent(this);
delete mpTex[0];
if(fourcc() == FOURCC_YV12)
{
delete mpTex[1];
delete mpTex[2];
}
if(mAddress && mFreeAddress)
{
}
}
{
if(fourcc() == FOURCC_YV12)
{
}
return size;
}
{
if(pPrimary)
{
);
}
#ifdef DEBUG_misha
if(pPrimary)
{
{
}
}
else
{
{
}
}
#else
#endif
if(fourcc() == FOURCC_YV12)
{
}
if(pvMem)
{
mFreeAddress = false;
}
else
{
mFreeAddress = true;
}
if(fourcc() == FOURCC_YV12)
{
}
if(pPrimary)
{
VBOXQGLLOG(("restoring to tex 0"));
);
}
}
#ifdef DEBUG_misha
bool g_DbgTest = false;
#endif
{
#ifdef DEBUG_misha
if(g_DbgTest)
{
{
val+=64;
}
}
#endif
if(pRect)
{
}
else
{
}
);
);
0,
mColorFormat.type(),
address);
);
#ifdef DEBUG_misha
if(g_DbgTest)
{
}
#endif
}
void VBoxVHWATexture::texCoord(int x, int y)
{
glTexCoord2f(((float)x)/mTexRect.width()/mColorFormat.widthCompression(), ((float)y)/mTexRect.height()/mColorFormat.heightCompression());
}
{
vboxglMultiTexCoord2f(texUnit, ((float)x)/mTexRect.width()/mColorFormat.widthCompression(), ((float)y)/mTexRect.height()/mColorFormat.heightCompression());
}
void VBoxVHWATexture::uninit()
{
if(mTexture)
{
}
}
: mAddress(0),
mTexture(0)
{
}
void VBoxVHWATexture::initParams()
{
}
void VBoxVHWATexture::load()
{
);
0,
0,
mColorFormat.type(),
);
}
{
// GLsizei wdt = mTexRect.width();
// GLsizei hgt = mTexRect.height();
);
bind();
initParams();
load();
}
{
uninit();
}
void VBoxVHWATextureNP2Rect::texCoord(int x, int y)
{
glTexCoord2f(((float)x)/mColorFormat.widthCompression(), ((float)y)/mColorFormat.heightCompression());
}
{
vboxglMultiTexCoord2f(texUnit, x/mColorFormat.widthCompression(), y/mColorFormat.heightCompression());
}
{
if(pRect)
{
}
if(mUpdateMem2TexRect.isClear())
return;
return;
if(fourcc() == FOURCC_YV12)
{
}
#if 0
#endif
//#ifdef DEBUG
// VBOXPRINTDIF(dbgTime, ("texMem:"));
//#endif
}
{
);
}
{
// updateBuffer((uchar*)buf, pRect);
}
{
);
}
void VBoxVHWATextureNP2RectPBO::load()
{
// updateBuffer((uchar*)buf, &mRect);
}
#if 0
{
}
{
Assert(isYInverted());
if(pRect)
{
}
if(mUpdateTex2FBRect.isClear())
return;
return;
mState->makeCurrent(this);
);
}
{
if(pRect)
{
}
if(mUpdateFB2MemRect.isClear())
return;
return;
mState->makeYInvertedCurrent(this);
// mState->makeCurrent(this);
);
mUpdateFB2MemRect.rect().x(),
mUpdateFB2MemRect.rect().y(),
mColorFormat.type(),
address);
);
}
int VBoxVHWASurfaceBase::performBlt(const QRect * pDstRect, VBoxVHWASurfaceBase * pSrcSurface, const QRect * pSrcRect, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey, bool blt)
{
// pDstCKey = NULL;
// pSrcCKey = NULL;
if(pDstCKey)
{
}
VBoxVHWAGlProgramVHWA * pProgram = pMngr->getProgram(pSrcCKey != NULL, &pSrcSurface->colorFormat(), &colorFormat());
if(pProgram)
{
{
}
}
else
{
}
// if(blt)
{
);
//TODO: setup strething params
);
glPushMatrix();
);
);
);
glPopMatrix();
);
);
}
// else
// {
//
// }
/* if dst color key */
/* setup ckey shader */
if(pDstCKey)
{
);
/* setup ckey values*/
}
return VINF_SUCCESS;
}
{
VBOXQGLLOG_METHODTIME("time:");
if(pOverlaySurface->isHidden())
{
VBOXQGLLOG(("!!!hidden!!!\n"));
return VINF_SUCCESS;
}
/* we use src (overlay) surface to maintain overridden dst ckey info
* to allow multiple overlays have different overridden dst keys for one primary surface */
/* non-null dstOverlayCKey for overlay would mean the overlay surface contains the overridden
* dst ckey value in defaultDstOverlayCKey
* this allows the NULL to be a valid overridden value as well */
const VBoxVHWAColorKey * pDstCKey = pOverlaySurface->dstOverlayCKey() ? pOverlaySurface->defaultDstOverlayCKey() : dstOverlayCKey();
}
int VBoxVHWASurfaceBase::blt(const QRect * pDstRect, VBoxVHWASurfaceBase * pSrcSurface, const QRect * pSrcRect, const VBoxVHWAColorKey * pDstCKey, const VBoxVHWAColorKey * pSrcCKey)
{
if(pDstRect)
{
}
else
{
}
if(pSrcRect)
{
}
else
{
}
if(!pSrcCKey)
if(!pDstCKey)
pDstCKey = dstBltCKey();
VBOXQGLLOG_METHODTIME("time:");
// synchTexture(pDstRect);
return rc;
}
#endif
{
#if 1
// VBOXQGL_CHECKERR(
// glTexCoord2d(((double)tx1)/mpTex[0]->texRect().width(), ((double)ty1)/mpTex[0]->texRect().height());
// glVertex2i(bx1, by1);
// glTexCoord2d(((double)tx1)/mpTex[0]->texRect().width(), ((double)ty2)/mpTex[0]->texRect().height());
// glVertex2i(bx1, by2);
// glTexCoord2d(((double)tx2)/mpTex[0]->texRect().width(), ((double)ty2)/mpTex[0]->texRect().height());
// glVertex2i(bx2, by2);
// glTexCoord2d(((double)tx2)/mpTex[0]->texRect().width(), ((double)ty1)/mpTex[0]->texRect().height());
// glVertex2i(bx2, by1);
glEnd();
// );
#else
glVertex2i(0, 0);
glEnd();
#endif
}
void VBoxVHWASurfaceBase::doMultiTex2FB(const QRect * pDstRect, const QRect * pSrcRect, int cSrcTex)
{
// VBOXQGL_CHECKERR(
for(int i = 0; i < cSrcTex; i++)
{
// vboxglMultiTexCoord2d(GL_TEXTURE0 + i, ((double)tx1)/mpTex[i]->texRect().width()/(width()/mpTex[i]->rect().width()),
// ((double)ty1)/mpTex[i]->texRect().height()/(height()/mpTex[i]->rect().height()));
mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx1/(t0width/mpTex[i]->texRect().width()), ty1/(t0height/mpTex[i]->rect().height()));
}
for(int i = 0; i < cSrcTex; i++)
{
// vboxglMultiTexCoord2d(GL_TEXTURE0 + i, ((double)tx1)/mpTex[i]->texRect().width()/(width()/mpTex[i]->rect().width()),
// ((double)ty2)/mpTex[i]->texRect().height()/(height()/mpTex[i]->rect().height()));
mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx1/(t0width/mpTex[i]->texRect().width()), ty2/(t0height/mpTex[i]->rect().height()));
}
for(int i = 0; i < cSrcTex; i++)
{
// vboxglMultiTexCoord2d(GL_TEXTURE0 + i, ((double)tx2)/mpTex[i]->texRect().width()/(width()/mpTex[i]->rect().width()),
// ((double)ty2)/mpTex[i]->texRect().height()/(height()/mpTex[i]->rect().height()));
mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx2/(t0width/mpTex[i]->texRect().width()), ty2/(t0height/mpTex[i]->rect().height()));
}
for(int i = 0; i < cSrcTex; i++)
{
// vboxglMultiTexCoord2d(GL_TEXTURE0 + i, ((double)tx2)/mpTex[i]->texRect().width()/(width()/mpTex[i]->rect().width()),
// ((double)ty1)/mpTex[i]->texRect().height()/(height()/mpTex[i]->rect().height()));
mpTex[i]->multiTexCoord(GL_TEXTURE0 + i, tx2/(t0width/mpTex[i]->texRect().width()), ty1/(t0height/mpTex[i]->rect().height()));
}
glEnd();
// );
}
void VBoxVHWASurfaceBase::doMultiTex2FB(const QRect * pDstRect, VBoxVHWATexture * pDstTex, const QRect * pSrcRect, int cSrcTex)
{
// VBOXQGL_CHECKERR(
for(int i = 0; i < cSrcTex; i++)
{
// vboxglMultiTexCoord2d(GL_TEXTURE1 + i, ((double)tx1)/mpTex[i]->texRect().width()/(width()/mpTex[i]->rect().width()),
// ((double)ty1)/mpTex[i]->texRect().height()/(height()/mpTex[i]->rect().height()));
mpTex[i]->multiTexCoord(GL_TEXTURE1 + i, tx1/(t0width/mpTex[i]->rect().width()), ty1/(t0height/mpTex[i]->rect().height()));
}
for(int i = 0; i < cSrcTex; i++)
{
// vboxglMultiTexCoord2d(GL_TEXTURE1 + i, ((double)tx1)/mpTex[i]->texRect().width()/(width()/mpTex[i]->rect().width()),
// ((double)ty2)/mpTex[i]->texRect().height()/(height()/mpTex[i]->rect().height()));
mpTex[i]->multiTexCoord(GL_TEXTURE1 + i, tx1/(t0width/mpTex[i]->rect().width()), ty2/(t0height/mpTex[i]->rect().height()));
}
for(int i = 0; i < cSrcTex; i++)
{
// vboxglMultiTexCoord2d(GL_TEXTURE1 + i, ((double)tx2)/mpTex[i]->texRect().width()/(width()/mpTex[i]->rect().width()),
// ((double)ty2)/mpTex[i]->texRect().height()/(height()/mpTex[i]->rect().height()));
mpTex[i]->multiTexCoord(GL_TEXTURE1 + i, tx2/(t0width/mpTex[i]->rect().width()), ty2/(t0height/mpTex[i]->rect().height()));
}
for(int i = 0; i < cSrcTex; i++)
{
// vboxglMultiTexCoord2d(GL_TEXTURE1 + i, ((double)tx2)/mpTex[i]->texRect().width()/(width()/mpTex[i]->rect().width()),
// ((double)ty1)/mpTex[i]->texRect().height()/(height()/mpTex[i]->rect().height()));
mpTex[i]->multiTexCoord(GL_TEXTURE1 + i, tx2/(t0width/mpTex[i]->rect().width()), ty1/(t0height/mpTex[i]->rect().height()));
}
glEnd();
// );
}
{
if(pRect)
{
}
Assert(mLockCount >= 0);
return VERR_GENERAL_FAILURE;
if(mLockCount < 0)
return VERR_GENERAL_FAILURE;
VBOXQGLLOG(("lock (0x%x)", this));
VBOXQGLLOG_METHODTIME("time ");
// if(!(flags & VBOXVHWA_LOCK_DISCARDCONTENTS))
// {
// synchMem(pRect);
// }
return VINF_SUCCESS;
}
int VBoxVHWASurfaceBase::unlock()
{
VBOXQGLLOG(("unlock (0x%x)\n", this));
mLockCount = 0;
return VINF_SUCCESS;
}
void VBoxVHWASurfaceBase::setRects(VBoxVHWASurfaceBase *pPrimary, const QRect * aTargRect, const QRect * aSrcRect)
{
return;
}
void VBoxVHWASurfaceBase::setTargetRectPosition(VBoxVHWASurfaceBase *pPrimary, const QPoint * aPoint)
{
return;
// false
);
}
void VBoxVHWASurfaceBase::deleteDisplay(
// bool bInverted
)
{
{
{
mVisibleDisplayInitialized = false;
}
}
}
void VBoxVHWASurfaceBase::doDisplay(VBoxVHWASurfaceBase *pPrimary, VBoxVHWAGlProgramVHWA * pProgram, bool bBindDst)
{
bool bInvokeMultiTex2 = false;
if(pProgram)
{
// if(pSrcCKey != NULL)
// {
// pProgram->start();
// setCKey(pProgram, &pSrcSurface->colorFormat(), pSrcCKey);
// vboxglActiveTexture(GL_TEXTURE0);
// }
if(bBindDst)
{
if(fourcc() == FOURCC_YV12)
{
}
bInvokeMultiTex2 = true;
}
else
{
if(fourcc() == FOURCC_YV12)
{
}
}
}
else
{
// vboxglActiveTexture(GL_TEXTURE0);
// VBOXQGLLOG(("binding (primary??) texture: %d\n", mpTex[0]->texture()));
}
if(bInvokeMultiTex2)
{
}
else
{
if(fourcc() == FOURCC_YV12)
{
}
else
{
}
}
if(pProgram)
{
}
}
{
if(pPrimary)
{
/* we use src (overlay) surface to maintain overridden dst ckey info
* to allow multiple overlays have different overridden dst keys for one primary surface */
/* non-null dstOverlayCKey for overlay would mean the overlay surface contains the overridden
* dst ckey value in defaultDstOverlayCKey
* this allows the NULL to be a valid overridden value as well */
// pSrcCKey = NULL;
// pDstCKey = NULL;
pProgram = mWidget->vboxVHWAGetGlProgramMngr()->getProgram(pDstCKey != NULL, pSrcCKey != NULL, &colorFormat(), &pPrimary->colorFormat());
}
glEndList();
return display;
}
{
{
mVisibleDisplayInitialized = true;
}
}
{
if(rec)
{
}
}
{
{
}
#ifdef DEBUG_misha
if(0)
{
if(pPrimary)
{
/* we use src (overlay) surface to maintain overridden dst ckey info
* to allow multiple overlays have different overridden dst keys for one primary surface */
/* non-null dstOverlayCKey for overlay would mean the overlay surface contains the overridden
* dst ckey value in defaultDstOverlayCKey
* this allows the NULL to be a valid overridden value as well */
// pSrcCKey = NULL;
// pDstCKey = NULL;
pProgram = mWidget->vboxVHWAGetGlProgramMngr()->getProgram(pDstCKey != NULL, pSrcCKey != NULL, &colorFormat(), &pPrimary->colorFormat());
}
// doDisplay(pPrimary, NULL, false);
}
else
#endif
{
);
}
}
/** @class VBoxQGLFrameBuffer
*
* The VBoxQImageFrameBuffer class is a class that implements the IFrameBuffer
* interface and uses QImage as the direct storage for VM display data. QImage
* is then converted to QPixmap and blitted to the console view widget.
*/
{
// mWidget = new GLWidget(aView->viewport());
#ifndef VBOXQGL_PROF_BASE
#else
#endif
}
/** @note This method is called on EMT from under this object's lock */
{
// /* We're not on the GUI thread and update() isn't thread safe in
// * Qt 4.3.x on the Win, Qt 3.3.x on the Mac (4.2.x is),
// * on Linux (didn't check Qt 4.x there) and probably on other
// * non-DOS platforms, so post the event instead. */
#ifdef VBOXQGL_PROF_BASE
#else
#endif
return S_OK;
}
#ifdef VBOXQGL_PROF_BASE
{
// if(aVRAM)
{
for(;;)
{
RTThreadSleep(40);
}
}
return S_OK;
}
#endif
{
}
{
}
{
}
/* processing the VHWA command, called from the GUI thread */
{
}
mPixelFormat(0),
mUsesGuestVRAM(false),
mbVGASurfCreated(false),
{
cmdPipeInit();
mpMngr = new VBoxVHWAGlProgramMngr();
// /* No need for background drawing */
// setAttribute (Qt::WA_OpaquePaintEvent);
}
{
vboxFormat.setAlpha(true);
vboxFormat.setAccum(false);
vboxFormat.setDepth(false);
return vboxFormat;
}
{
delete mpMngr;
}
void VBoxGLWidget::cmdPipeInit()
{
mpFirstEvent = NULL;
mpLastEvent = NULL;
mbNewEvent = false;
{
}
}
void VBoxGLWidget::cmdPipeDelete()
{
}
{
);
if(bInverted)
{
);
}
else
{
/* make display coordinates be scaled to pixel coordinates */
);
);
);
}
}
{
/* viewport: (viewport.x;viewport.y) (viewport.width;viewport.height)*/
}
{
// doSetupMatrix(bInverted ? &mRect.size() : &mTargSize.size(), bInverted);
doSetupMatrix(display, false);
}
{
/* 1. lock*/
if(!pCmd)
{
VBOXQGLLOG(("!!!no more free elements!!!\n"));
#ifdef VBOXQGL_PROF_BASE
return;
#else
//TODO:
#endif
}
/* 2. if can add to current*/
if(!mbNewEvent)
{
/* 3. if event is being processed (event != 0) */
if(mpLastEvent)
{
/* 3.a add cmd to event */
/* 3.b unlock and return */
return;
}
}
/* we're here because the cmd was NOT be added to the current event queue */
/* 4. unlock*/
/* 5. create & initialize new Event */
/* 6. lock */
/* 7. if no current event set event as current */
if(!mpLastEvent)
{
}
else
{
}
/* 8. reset blocking events counter */
mbNewEvent = false;
/* 9. unlock */
/* 10. post event */
}
VBoxVHWACommandElement * VBoxGLWidget::detachCmdList(VBoxVHWACommandElement * pFirst2Free, VBoxVHWACommandElement * pLast2Free)
{
if(pFirst2Free)
{
}
if(mpFirstEvent)
{
if(!pList)
{
if(pNext)
{
}
else
{
mpFirstEvent = NULL;
mpLastEvent = NULL;
}
}
}
return pList;
}
{
do
{
{
case VBOXVHWA_PIPECMD_PAINT:
break;
#ifdef VBOX_WITH_VIDEOHWACCEL
case VBOXVHWA_PIPECMD_VHWA:
break;
case VBOXVHWA_PIPECMD_OP:
{
break;
}
#endif
default:
Assert(0);
}
} while(pCmd);
return pCur;
}
{
do
{
} while(pFirst);
}
#ifdef VBOX_WITH_VIDEOHWACCEL
/* static */
{
return vboxVHWASupportedInternal();
}
{
// Assert(0);
/* indicate that we process and complete the command asynchronously */
/* post the command to the GUI thread for processing */
// QApplication::postEvent (mView,
// new VBoxVHWACommandProcessEvent (pCmd));
return S_OK;
}
{
}
{
}
{
{
{
} break;
{
} break;
{
} break;
{
} break;
{
} break;
{
} break;
{
} break;
{
} break;
{
VBOXVHWACMD_SURF_OVERLAY_SETPOSITION * pBody = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_OVERLAY_SETPOSITION);
} break;
{
} break;
{
} break;
{
} break;
case VBOXVHWACMD_TYPE_ENABLE:
case VBOXVHWACMD_TYPE_DISABLE:
break;
{
} break;
default:
Assert(0);
break;
}
}
{
VBOXQGLLOG_ENTER(("\n"));
{
Assert(0);
return VINF_SUCCESS;
}
{
return VINF_SUCCESS;
}
{
return VINF_SUCCESS;
}
{
{
Assert(0);
return VINF_SUCCESS;
}
{
{
Assert(0);
return VINF_SUCCESS;
}
}
{
/* detect whether we support this format */
bool bFound = false;
for(uint32_t i = 0; i < g_vboxVHWAFourccSupportedCount; i++)
{
{
bFound = true;
break;
}
}
if(!bFound)
{
Assert(0);
return VINF_SUCCESS;
}
}
else
{
Assert(0);
return VINF_SUCCESS;
}
}
return VINF_SUCCESS;
}
{
VBOXQGLLOG_ENTER(("\n"));
{
{
// do
// {
// if(!mcVGASurfCreated)
// {
// /* check if it is a primary surface that needs handle adjusting*/
// if((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_PRIMARYSURFACE)
// && handle2Surface(handle) == mDisplay.getVGA())
// {
// /* remove, the primary surface will be assigned to a new handle assumed by the guest */
// mSurfHandleTable.remove(handle);
// break;
// }
// }
Assert(0);
return VERR_GENERAL_FAILURE;
// }while(0);
}
}
// VBoxVHWAColorFormat *pFormat = NULL, Format;
bool bPrimary = false;
{
}
{
}
{
DstOverlayCKey = VBoxVHWAColorKey(pCmd->SurfInfo.DstOverlayCK.high, pCmd->SurfInfo.DstOverlayCK.low);
}
{
SrcOverlayCKey = VBoxVHWAColorKey(pCmd->SurfInfo.SrcOverlayCK.high, pCmd->SurfInfo.SrcOverlayCK.low);
}
{
bPrimary = true;
if(!mbVGASurfCreated)
{
{
{
{
mbVGASurfCreated = true;
}
}
}
}
}
if(!surf)
{
{
// ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &surfSize),
bPrimary);
}
{
// ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &QSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height)),
bPrimary);
}
else
{
Assert(0);
return VERR_GENERAL_FAILURE;
}
{
if(!mConstructingList)
{
mConstructingList = new VBoxVHWASurfList();
}
if(!mcRemaining2Contruct)
{
}
}
else if(bPrimary)
{
{
}
}
{
//TODO: impl fullscreen mode support
Assert(0);
}
else
{
Assert(0);
}
}
/* tell the guest how we think the memory is organized */
{
if(!bSuccess)
{
/* @todo: this is very bad, should not be here */
return VERR_GENERAL_FAILURE;
}
}
else
{
/* tell the guest our handle */
}
return VINF_SUCCESS;
}
{
{
if(pList)
{
{
// Assert(mConstructingList != pList);
if(pList == mConstructingList)
{
mcRemaining2Contruct = 0;
}
delete pList;
}
{
{
}
}
}
delete(pSurf);
}
else
{
mbVGASurfCreated = false;
}
return VINF_SUCCESS;
}
#define VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_RB(_pr) \
#define VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL_WH(_pr) \
{
{
}
}
{
{
pSurf->updatedMem(&r);
}
}
{
/**/
return VERR_NOT_IMPLEMENTED;
// VBoxVHWASurfaceBase *pDstSurf = (VBoxVHWASurfaceBase*)pCmd->u.in.hDstSurf;
// VBoxVHWASurfaceBase *pSrcSurf = (VBoxVHWASurfaceBase*)pCmd->u.in.hSrcSurf;
// VBOXQGLLOG_ENTER(("pDstSurf (0x%x), pSrcSurf (0x%x)\n",pDstSurf,pSrcSurf));
// QRect dstRect = VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL(&pCmd->u.in.dstRect);
// QRect srcRect = VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL(&pCmd->u.in.srcRect);
// vboxCheckUpdateAddress (pSrcSurf, pCmd->u.in.offSrcSurface);
// vboxCheckUpdateAddress (pDstSurf, pCmd->u.in.offDstSurface);
//// pDstSurf->makeCurrent();
//// const VBoxVHWAColorKey DstCKey, *pDstCKey = NULL;
//// const VBoxVHWAColorKey SrcCKey, *pSrcCKey = NULL;
//// if(pCmd->u.in.flags & VBOXVHWA_BLT_KEYSRCOVERRIDE)
//// {
//// pSrcCKey = &
//// }
//// if(pCmd->u.in.flags & VBOXVHWA_BLT_KEYDESTOVERRIDE)
//// {
////
//// }
// if(pCmd->u.in.xUpdatedSrcMemValid)
// {
// QRect r = VBOXVHWA_CONSTRUCT_QRECT_FROM_RECTL(&pCmd->u.in.xUpdatedSrcMemRect);
// pSrcSurf->updatedMem(&r);
// }
//
// return pDstSurf->blt(&dstRect, pSrcSurf, &srcRect,
// pCmd->u.in.flags & VBOXVHWA_BLT_KEYSRCOVERRIDE ? &VBoxVHWAColorKey(pCmd->u.in.desc.SrcCK.high, pCmd->u.in.desc.SrcCK.low) : NULL,
// pCmd->u.in.flags & VBOXVHWA_BLT_KEYDESTOVERRIDE ? &VBoxVHWAColorKey(pCmd->u.in.desc.DstCK.high, pCmd->u.in.desc.DstCK.low) : NULL);
}
{
// Assert(pTargSurf->isYInverted());
// Assert(!pCurrSurf->isYInverted());
{
pTargSurf->updatedMem(&r);
}
#ifdef DEBUG
pCurrSurf->cFlipsCurr++;
pTargSurf->cFlipsTarg++;
#endif
// mDisplay.flip(pTargSurf, pCurrSurf);
// Assert(!pTargSurf->isYInverted());
// Assert(pCurrSurf->isYInverted());
return VINF_SUCCESS;
}
void VBoxGLWidget::vhwaDoSurfaceOverlayUpdate(VBoxVHWASurfaceBase *pDstSurf, VBoxVHWASurfaceBase *pSrcSurf, struct _VBOXVHWACMD_SURF_OVERLAY_UPDATE *pCmd)
{
{
VBOXQGLLOG((", KEYDEST"));
/* we use src (overlay) surface to maintain overridden dst ckey info
* to allow multiple overlays have different overridden dst keys for one primary surface */
/* non-null dstOverlayCKey for overlay would mean the overlay surface contains the overridden
* dst ckey value in defaultDstOverlayCKey
* this allows the NULL to be a valid overridden value as well
* i.e.
* 1. indicate the value is NUL overridden, just set NULL*/
}
{
VBOXQGLLOG((", KEYDESTOVERRIDE"));
/* we use src (overlay) surface to maintain overridden dst ckey info
* to allow multiple overlays have different overridden dst keys for one primary surface */
/* non-null dstOverlayCKey for overlay would mean the overlay surface contains the overridden
* dst ckey value in defaultDstOverlayCKey
* this allows the NULL to be a valid overridden value as well
* i.e.
* 1. indicate the value is overridden (no matter what we write here, bu it should be not NULL)*/
/* tell the ckey is enabled */
}
else
{
VBOXQGLLOG((", no KEYDEST"));
/* we use src (overlay) surface to maintain overridden dst ckey info
* to allow multiple overlays have different overridden dst keys for one primary surface */
/* non-null dstOverlayCKey for overlay would mean the overlay surface contains the overridden
* dst ckey value in defaultDstOverlayCKey
* this allows the NULL to be a valid overridden value as well
* i.e.
* 1. indicate the value is overridden (no matter what we write here, bu it should be not NULL)*/
VBoxVHWAColorKey dummyCKey(0, 0);
/* tell the ckey is disabled */
}
{
VBOXQGLLOG((", KEYSRC"));
}
{
VBOXQGLLOG((", KEYSRCOVERRIDE"));
}
else
{
VBOXQGLLOG((", no KEYSRC"));
}
VBOXQGLLOG(("\n"));
if(pDstSurf)
{
VBOXQGLLOG(("*******overlay update*******\n"));
VBoxVHWAGlProgramVHWA *pProgram = vboxVHWAGetGlProgramMngr()->getProgram(pResDstCKey != NULL, pResSrcCKey != NULL, &pSrcSurf->colorFormat(), &pDstSurf->colorFormat());
if(pProgram)
{
if(pResSrcCKey || pResDstCKey)
{
if(pResSrcCKey)
{
}
if(pResDstCKey)
{
}
}
{
case 0:
case FOURCC_AYUV:
case FOURCC_YV12:
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
break;
default:
Assert(0);
break;
}
}
}
}
{
{
}
{
}
{
VBOXQGLLOG(("hide"));
}
{
VBOXQGLLOG(("show"));
}
return VINF_SUCCESS;
}
{
{
}
return VINF_SUCCESS;
}
{
// VBOXVHWA_CKEY_COLORSPACE
{
}
{
}
{
}
{
}
return VINF_SUCCESS;
}
{
VBOXQGLLOG_ENTER(("\n"));
bool bEnabled = false;
{
{
{
{
{
bEnabled = true;
}
}
}
}
}
if(bEnabled)
{
// VBOXVHWA_CAPS_BLT | VBOXVHWA_CAPS_BLTSTRETCH | VBOXVHWA_CAPS_BLTQUEUE
// // | VBOXVHWA_CAPS_BLTCOLORFILL not supported, although adding it is trivial
// // | VBOXVHWA_CAPS_BLTFOURCC set below if shader support is available
// | VBOXVHWA_CAPS_OVERLAYFOURCC set below if shader support is available
;
//TODO: setup stretchCaps
/* TODO: set curOverlays properly */
// | VBOXVHWA_SCAPS_OFFSCREENPLAIN
// | VBOXVHWA_SCAPS_VIDEOMEMORY
// | VBOXVHWA_SCAPS_COMPLEX
// | VBOXVHWA_SCAPS_VISIBLE
;
{
;
// VBOXVHWA_CKEYCAPS_DESTBLT | VBOXVHWA_CKEYCAPS_DESTBLTCLRSPACE | VBOXVHWA_CKEYCAPS_SRCBLT| VBOXVHWA_CKEYCAPS_SRCBLTCLRSPACE |
// VBOXVHWA_CKEYCAPS_SRCOVERLAY | VBOXVHWA_CKEYCAPS_SRCOVERLAYONEACTIVE |
;
{
// | VBOXVHWA_CAPS_BLTFOURCC
;
// VBOXVHWA_CKEYCAPS_SRCOVERLAYYUV |
;
// pCmd->u.out.caps2 |= VBOXVHWA_CAPS2_COPYFOURCC;
}
}
}
return VINF_SUCCESS;
}
{
VBOXQGLLOG_ENTER(("\n"));
return VERR_GENERAL_FAILURE;
for(uint32_t i = 0; i < g_vboxVHWAFourccSupportedCount; i++)
{
}
return VINF_SUCCESS;
}
{
}
static DECLCALLBACK(int) vboxQGLLoadExec(PSSMHANDLE pSSM, void *pvUser, uint32_t u32Version, uint32_t uPhase)
{
}
int VBoxGLWidget::vhwaSaveSurface(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, uint32_t surfCaps)
{
int rc;
if(pDstBltCKey)
{
}
if(pSrcBltCKey)
{
}
if(pDstOverlayCKey)
{
}
if(pSrcOverlayCKey)
{
}
if(pDstBltCKey)
{
}
if(pSrcBltCKey)
{
}
if(pDstOverlayCKey)
{
}
if(pSrcOverlayCKey)
{
}
flags = 0;
{
}
else
{
flags |= VBOXVHWA_PF_RGB;
}
return rc;
}
{
int rc;
if(RT_SUCCESS(rc))
{
{
}
{
}
{
}
{
}
{
}
{
}
else
{
Assert(0);
}
// if(RT_SUCCESS(rc))
// {
// rc = pCmd->rc;
// AssertRC(rc);
// }
}
return rc;
}
int VBoxGLWidget::vhwaSaveOverlayData(struct SSMHANDLE * pSSM, VBoxVHWASurfaceBase *pSurf, bool bVisible)
{
bool bSaveDstCKey = false;
bool bSaveSrcCKey = false;
if(bVisible)
{
}
else
{
}
if(!dstCKey)
{
}
else if(defaultDstCKey)
{
bSaveDstCKey = true;
}
if(srcCKey == defaultSrcCKey)
{
}
else if(srcCKey)
{
bSaveSrcCKey = true;
}
if(bSaveDstCKey)
{
}
if(bSaveSrcCKey)
{
}
return rc;
}
{
// char buf[VBOXVHWACMD_SIZE(VBOXVHWACMD_SURF_OVERLAY_UPDATE)];
VBOXVHWACMD_SURF_OVERLAY_UPDATE * pUpdateOverlay = VBOXVHWACMD_BODY(pCmd, VBOXVHWACMD_SURF_OVERLAY_UPDATE);
int rc;
// Assert(hDst == mDisplay.getVGA()->handle());
// VBoxVHWASurfaceBase *pDstSurf = handle2Surface(hDst);
// VBoxVHWASurfaceBase *pSrcSurf = handle2Surface(hSrc);
// Assert(pSrcSurf);
// Assert(pDstSurf);
// if(pSrcSurf && pDstSurf)
{
// vboxVRAMOffset(pDstSurf);
// vboxVRAMOffset(pSrcSurf);
{
}
{
}
// if(RT_SUCCESS(rc))
// {
// rc = pCmd->rc;
// AssertRC(rc);
// }
}
// else
// {
// rc = VERR_GENERAL_FAILURE;
// }
return rc;
}
{
/* the mechanism of restoring data is based on generating VHWA commands that restore the surfaces state
* the following commands are generated:
* I. CreateSurface
* II. UpdateOverlay
*
* Data format is the following:
* I. u32 - Num primary surfaces - (the current frontbuffer is detected in the stored surf flags which are posted to the generated CreateSurface cmd)
* II. for each primary surf
* II.1 generate & execute CreateSurface cmd (see below on the generation logic)
* III. u32 - Num overlays
* IV. for each overlay
* IV.1 u32 - Num surfaces in overlay (the current frontbuffer is detected in the stored surf flags which are posted to the generated CreateSurface cmd)
* IV.2 for each surface in overlay
* IV.2.a generate & execute CreateSurface cmd (see below on the generation logic)
* IV.2.b generate & execute UpdateOverlay cmd (see below on the generation logic)
*
*/
if(!mbVGASurfCreated)
{
cPrimary -= 1;
}
{
if(bVisible)
if(mbVGASurfCreated || !bVga)
{
#ifdef DEBUG
--cPrimary;
#endif
}
}
#ifdef DEBUG
#endif
{
if(cSurfs > 1)
{
}
bool bVisible = true;
if(!pOverlayData)
{
bVisible = false;
}
}
}
{
int rc;
if(RT_SUCCESS(rc))
{
{
if(RT_FAILURE(rc))
break;
}
if(RT_SUCCESS(rc))
{
if(RT_SUCCESS(rc))
{
{
{
if(RT_FAILURE(rc))
break;
}
if(RT_SUCCESS(rc))
{
}
if(RT_FAILURE(rc))
{
break;
}
}
}
}
}
return rc;
}
{
int rc = SSMR3RegisterExternal(
pVM, /* The VM handle*/
pszName, /* Data unit name. */
intsId, /* The instance identifier of the data unit.
* This must together with the name be unique. */
VBOXQGL_STATE_VERSION, /* Data layout version number. */
128, /* The approximate amount of data in the unit.
* Only for progress indicators. */
NULL, /* Prepare save callback, optional. */
vboxQGLSaveExec, /* Execute save callback, optional. */
NULL, /* Done save callback, optional. */
NULL, /* Prepare load callback, optional. */
vboxQGLLoadExec, /* Execute load callback, optional. */
NULL, /* Done load callback, optional. */
this /* User argument. */
);
return rc;
}
{
}
{
}
{
return pSurf->addressAlocated() ? VBOXVHWA_OFFSET64_VOID : vboxVRAMOffsetFromAddress(pSurf->address());
}
#endif
void VBoxGLWidget::initializeGL()
{
}
#ifdef VBOXQGL_DBG_SURF
int g_iCur = 0;
{
// uint32_t width = 103;
// uint32_t height = 47;
// uint32_t rgbBitCount = 32;
// uint32_t r = 0xff, g = 0xff00, b = 0xff0000;
// QRect dstRect(10, 50, width, height);
// QRect srcRect(0, 0, width, height);
//// Assert(0);
// if(!pSurf1)
// {
//
//// pSurf1 = new VBoxVHWASurfaceBase(this, width, height,
//// VBoxVHWAColorFormat(rgbBitCount,
//// r,
//// g,
//// b),
//// NULL, NULL, NULL, NULL);
// pSurf1 = new VBoxVHWASurfaceBase(this, &QSize(width, height),
//// ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &QSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height)),
// &mDisplay.getPrimary()->rect().size(),
// VBoxVHWAColorFormat(rgbBitCount,
// r,
// g,
// b),
//// pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey);
// NULL, NULL, NULL, NULL);
//
// pSurf1->init(mDisplay.getVGA(), NULL);
//
// VBoxVHWASurfList *pConstructingList = new VBoxVHWASurfList();
// mDisplay.addOverlay(pConstructingList);
// pConstructingList->add(pSurf1);
// pConstructingList->setCurrentVisible(pSurf1);
//// pSurf1->performDisplay();
// }
//
//// pDisplay->blt(&dstRect, pSurf1, &srcRect, NULL, NULL);
//// pDisplay->performDisplay();
g_iCur = 0;
if(pSurf1)
{
}
}
#endif
{
#ifdef VBOXQGL_DBG_SURF
#endif
{
}
//#ifdef VBOXQGL_PROF_BASE
// vboxDoUpdateRect(&((QPaintEvent*)pe)->rect());
//#endif
}
{
}
{
// Assert(!format().accum());
// Assert(format().alpha());
// Assert(format().alphaBufferSize() == 8);
// Assert(!format().depth());
VBOXQGLLOG(("hasOpenGLOverlays(%d), hasOverlay(%d)\n", format().hasOpenGLOverlays(), format().hasOverlay()));
// Assert(format().hasOpenGLOverlays());
// Assert(format().hasOverlay());
// Assert(!format().stencil());
// Assert(format().swapInterval() == 0);
);
bool remind = false;
bool fallback = false;
VBOXQGLLOG(("resizing: fmt=%d, vram=%p, bpp=%d, bpl=%d, width=%d, height=%d\n",
/* clean the old values first */
/* check if we support the pixel format and can use the guest VRAM directly */
{
switch (bitsPerPixel)
{
case 32:
// format = VBoxVHWAColorFormat(bitsPerPixel, 0xff, 0xff00, 0xff0000);
break;
case 24:
#ifdef DEBUG_misha
Assert(0);
#endif
// format = VBoxVHWAColorFormat(bitsPerPixel, 0xff, 0xff00, 0xff0000);
// remind = true;
break;
// case 16:
// Assert(0);
//// r = 0xf800;
//// g = 0x7e0;
//// b = 0x1f;
// break;
case 8:
#ifdef DEBUG_misha
Assert(0);
#endif
g = b = 0;
remind = true;
break;
case 1:
#ifdef DEBUG_misha
Assert(0);
#endif
r = 1;
g = b = 0;
remind = true;
break;
default:
#ifdef DEBUG_misha
Assert(0);
#endif
remind = true;
fallback = true;
break;
}
if (!fallback)
{
/* QImage only supports 32-bit aligned scan lines... */
}
if (!fallback)
{
/* ...and the scan lines ought to be a whole number of pixels. */
}
if (!fallback)
{
// ulong virtWdt = bitsPerLine / re->bitsPerPixel();
mUsesGuestVRAM = true;
}
}
else
{
fallback = true;
}
if (fallback)
{
/* we don't support either the pixel format or the color depth,
* fallback to a self-provided 32bpp RGB buffer */
bitsPerPixel = 32;
b = 0xff;
g = 0xff00;
r = 0xff0000;
// internalformat = 3;//GL_RGB;
// format = GL_BGRA_EXT;//GL_RGBA;
// type = GL_UNSIGNED_BYTE;
mUsesGuestVRAM = false;
}
#ifdef VBOXQGL_DBG_SURF
for(int i = 0; i < RT_ELEMENTS(g_apSurf); i++)
{
if(pSurf1)
{
delete pSurf1;
delete pConstructingList;
//
// mDisplay.addOverlay(pConstructingList);
// // pConstructingList->add(pSurf1);
// // pConstructingList->setCurrentVisible(pSurf1);
// //// pConstructingList->setCurrentVisible(NULL);
}
}
#endif
if(pDisplay)
delete pDisplay;
(VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, (VBoxVHWAColorKey*)NULL, true);
// VBOXQGLLOG(("\n\n*******\n\n viewport size is: (%d):(%d)\n\n*******\n\n", size().width(), size().height()));
#ifdef VBOXQGL_DBG_SURF
{
// uint32_t rgbBitCount = 32;
// uint32_t r = 0xff, g = 0xff00, b = 0xff0000;
// QRect dstRect(150, 200, width, height);
// QRect srcRect(0, 0, 720, 480);
// Assert(0);
for(int i = 0; i < RT_ELEMENTS(g_apSurf); i++)
{
// pSurf1 = new VBoxVHWASurfaceBase(this, width, height,
// VBoxVHWAColorFormat(rgbBitCount,
// r,
// g,
// b),
// NULL, NULL, NULL, NULL);
// ((pCmd->SurfInfo.surfCaps & VBOXVHWA_SCAPS_OVERLAY) ? mDisplay.getPrimary()->rect().size() : &QSize(pCmd->SurfInfo.width, pCmd->SurfInfo.height)),
// VBoxVHWAColorFormat(rgbBitCount,
// r,
// g,
// b),
// pSrcBltCKey, pDstBltCKey, pSrcOverlayCKey, pDstOverlayCKey);
{
cur+=64;
}
// VBOXQGL_CHECKERR(
// vboxglActiveTexture(GL_TEXTURE0);
// );
// pConstructingList->setCurrentVisible(pSurf1);
// pConstructingList->setCurrentVisible(NULL);
// VBoxVHWAGlProgramVHWA * pProgram = vboxVHWAGetGlProgramMngr()->getProgram(true, false, &pSurf1->colorFormat(), &pDisplay->colorFormat());
// pProgram->start();
// pProgram->setSrcTexImgWidth(pSurf1->texRect().width());
// pProgram->stop();
}
// else
// {
// VBoxVHWASurfList *pConstructingList = pSurf1->getComplexList();
// mDisplay.addOverlay(pConstructingList);
// pConstructingList->add(pSurf1);
// pConstructingList->setCurrentVisible(pSurf1);
//// pConstructingList->setCurrentVisible(NULL);
// }
updateCmd.u.in.offDstSurface = 0xffffffffffffffffL; /* just a magic to avoid surf mem buffer change */
updateCmd.u.in.offSrcSurface = 0xffffffffffffffffL; /* just a magic to avoid surf mem buffer change */
}
#endif
if(pPpCmd)
{
while(pPpCmd)
{
delete pCur;
}
}
if (remind)
{
class RemindEvent : public VBoxAsyncEvent
{
public:
void handle()
{
}
};
}
}
//typedef struct VBOXQGLDEFFEREDOPCONTEXT
//{
// PFNVBOXQGLOP pfn;
// void *pContext;
// VBoxVHWACommandElement * pEl;
//}VBOXQGLDEFFEREDOPCONTEXT;
//
//void VBoxGLWidget::vboxDefferedOpCallback(void * pContext)
//{
// VBOXQGLDEFFEREDOPCONTEXT * pData = (VBOXQGLDEFFEREDOPCONTEXT*)pContext;
// this->*(pData->pfn)(pData->pContext);
// delete pEl;
//}
{
}
//int VBoxGLWidget::vboxExecOpSynch(PFNVBOXQGLOP pfn, void* pContext)
//{
// VBOXQGLOPCALLBACKCONTEXT data;
// data.pThis = this;
// data.pfn = pfn;
// data.pContext = pContext;
// int rc = RTSemEventCreate(&data.hEvent);
// AssertRC(rc);
// if(RT_SUCCESS(rc))
// {
// VBOXVHWACALLBACKINFO info;
// info.pContext = &data;
// info.pfnCallback = vboxQGLOpCallback;
// postCmd(VBOXVHWA_PIPECMD_OP, &info);
// rc = RTSemEventWaitNoResume(data.hEvent, RT_INDEFINITE_WAIT);
// AssertRC(rc);
// if(RT_SUCCESS(rc))
// {
// RTSemEventDestroy(data.hEvent);
// }
// }
// return rc;
//}
VBoxVHWAColorFormat::VBoxVHWAColorFormat(uint32_t bitsPerPixel, uint32_t r, uint32_t g, uint32_t b) :
{
init(bitsPerPixel, r, g, b);
}
{
}
{
mBitsPerPixelTex = 32;
switch(fourcc)
{
case FOURCC_AYUV:
mBitsPerPixel = 32;
mWidthCompression = 1;
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
mBitsPerPixel = 16;
mWidthCompression = 2;
break;
case FOURCC_YV12:
mBitsPerPixel = 8;
mWidthCompression = 4;
break;
default:
Assert(0);
mBitsPerPixel = 0;
mBitsPerPixelTex = 0;
mWidthCompression = 0;
break;
}
}
{
mDataFormat = 0;
switch (bitsPerPixel)
{
case 32:
mR = VBoxVHWAColorComponent(r);
mG = VBoxVHWAColorComponent(g);
mB = VBoxVHWAColorComponent(b);
break;
case 24:
#ifdef DEBUG_misha
Assert(0);
#endif
mR = VBoxVHWAColorComponent(r);
mG = VBoxVHWAColorComponent(g);
mB = VBoxVHWAColorComponent(b);
break;
case 16:
#ifdef DEBUG_misha
Assert(0);
#endif
mR = VBoxVHWAColorComponent(r);
mG = VBoxVHWAColorComponent(g);
mB = VBoxVHWAColorComponent(b);
break;
case 8:
#ifdef DEBUG_misha
Assert(0);
#endif
break;
case 1:
#ifdef DEBUG_misha
Assert(0);
#endif
mInternalFormat = 1;
break;
default:
#ifdef DEBUG_misha
Assert(0);
#endif
mBitsPerPixel = 0;
mBitsPerPixelTex = 0;
break;
}
}
{
if(fourcc())
return false;
}
{
unsigned f = ASMBitFirstSetU32(aMask);
if(f)
{
mOffset = f - 1;
if(f)
{
mcBits = f - 1;
}
else
{
}
}
else
{
mMask = 0;
mRange = 0;
mOffset = 32;
mcBits = 0;
}
}
{
}
#endif