server_blitter.cpp revision 96a93b5e6bd7da64f6be955c9fd7569b80c8ae2e
/* $Id$ */
/** @file
* Blitter API
*/
/*
* Copyright (C) 2012 Oracle Corporation
*
* 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.
*/
#include "cr_spu.h"
#include "chromium.h"
#include "cr_error.h"
#include "cr_net.h"
#include "cr_rand.h"
#include "server_dispatch.h"
#include "server.h"
#include "cr_mem.h"
#include "cr_string.h"
typedef struct CR_BLITTER_STATE
{
typedef struct CR_BLITTER_BUFFER
{
typedef struct CR_BLITTER_TEXTURE
{
typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, CR_BLITTER_TEXTURE *pSrc, RECT *paSrcRect, PRTRECTSIZE pDstSize, RECT *paDstRect, uint32_t cRects, uint32_t fFlags);
typedef FNCRBLT_BLITTER *PFNCRBLT_BLITTER;
typedef union CR_BLITTER_FLAGS
{
struct
{
};
typedef struct CR_BLITTER
{
} CR_BLITTER, *PCR_BLITTER;
{
{
crWarning("Default share context not initialized!");
return VERR_INVALID_STATE;
}
pBlitter->CtxInfo.SpuContext = cr_server.head_spu->dispatch_table.CreateContext(pBlitter->CtxInfo.CreateInfo.pszDpyName,
{
crWarning("CreateContext failed!");
return VERR_GENERAL_FAILURE;
}
return VINF_SUCCESS;
}
{
}
{
}
{
return !!pBlitter->pRestoreCtxInfo;
}
{
return;
if (!crBltIsEntered(pBlitter))
return;
if (pMural)
else
}
#define CRBLT_F_LINEAR 0x00000001
static DECLCALLBACK(int) crBltBlitTexBufImplFbo(PCR_BLITTER pBlitter, CR_BLITTER_TEXTURE *pSrc, RECT *paSrcRect, PRTRECTSIZE pDstSize, RECT *paDstRect, uint32_t cRects, uint32_t fFlags)
{
cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pSrc->target, pSrc->hwid, 0);
{
}
return VINF_SUCCESS;
}
/* GL_TRIANGLE_FAN */
static DECLINLINE(GLfloat*) crBltVtRectTFNormalized(RECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff)
{
/* left top */
/* left bottom */
/* right bottom */
/* right top */
return &pBuff[8];
}
static DECLINLINE(GLint*) crBltVtRectTF(RECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff)
{
/* left top */
/* left bottom */
/* right bottom */
/* right top */
return &pBuff[8];
}
{
/* triangle 1 */
/* triangle 2 */
return pIndex + 6;
}
/* Indexed GL_TRIANGLES */
static DECLINLINE(GLfloat*) crBltVtRectITNormalized(RECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, GLubyte **ppIndex, GLubyte *piBase)
{
if (ppIndex)
return ret;
}
static DECLINLINE(GLint*) crBltVtRectIT(RECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff, GLubyte **ppIndex, GLubyte *piBase)
{
if (ppIndex)
return ret;
}
{
return cRects * 4;
}
{
return 6 * cRects;
}
static GLfloat* crBltVtRectsITNormalized(RECT *paRects, uint32_t cRects, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, GLubyte **ppIndex, GLubyte *piBase)
{
{
}
return pBuff;
}
{
{
{
}
cbBuffer += 16;
else
{
}
}
}
static DECLCALLBACK(int) crBltBlitTexBufImplDraw2D(PCR_BLITTER pBlitter, CR_BLITTER_TEXTURE *pSrc, RECT *paSrcRect, PRTRECTSIZE pDstSize, RECT *paDstRect, uint32_t cRects, uint32_t fFlags)
{
{
const GLdouble aProjection[] =
{
0.0, 0.0, 2.0, 0.0,
-1.0, -1.0, -1.0, 1.0
};
}
{
case GL_TEXTURE_2D:
{
break;
}
case GL_TEXTURE_RECTANGLE_ARB:
{
normalX = 1;
normalY = 1;
break;
}
default:
{
return;
}
}
if (cRects == 1)
{
/* just optimizatino to draw a single rect with GL_TRIANGLE_FAN */
if (bUseSameVerticies)
{
}
else
{
}
}
else
{
if (bUseSameVerticies)
{
}
else
{
pTexCoords = crBltVtRectsITNormalized(paDstRect, cRects, normalX, normalY, pVerticies, &pIndicies, &iIdxBase);
}
cr_server.head_spu->dispatch_table.DrawElements(GL_TRIANGLES, cIndicies, GL_UNSIGNED_BYTE, pIndicies);
}
}
{
{
}
else
crWarning("GL_EXT_framebuffer_object not supported, blitter can only blit to window");
{
}
else
{
crWarning("GL_EXT_framebuffer_blit not supported, will use Draw functions for blitting, which might be less efficient");
}
return VINF_SUCCESS;
}
{
cr_server.head_spu->dispatch_table.MakeCurrent(pBlitter->pRestoreMural->spuWindow, 0, pBlitter->pRestoreCtxInfo->SpuContext);
else
}
{
if (!pBlitter->pCurrentMural)
{
crWarning("current mural not initialized!");
return VERR_INVALID_STATE;
}
if (crBltIsEntered(pBlitter))
{
crWarning("blitter is entered already!");
return VERR_INVALID_STATE;
}
cr_server.head_spu->dispatch_table.MakeCurrent(pBlitter->pCurrentMural->spuWindow, 0, pBlitter->CtxInfo.SpuContext);
return VINF_SUCCESS;
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
return rc;
}
static void crBltBlitTexBuf(PCR_BLITTER pBlitter, CR_BLITTER_TEXTURE *pSrc, RECT *paSrcRects, GLenum enmDstBuff, PRTRECTSIZE pDstSize, RECT *paDstRects, uint32_t cRects, uint32_t fFlags)
{
}
void crBltBlitTexMural(PCR_BLITTER pBlitter, CR_BLITTER_TEXTURE *pSrc, RECT *paSrcRects, RECT *paDstRects, uint32_t cRects, uint32_t fFlags)
{
}
void crBltBlitTexTex(PCR_BLITTER pBlitter, CR_BLITTER_TEXTURE *pSrc, RECT *pSrcRect, CR_BLITTER_TEXTURE *pDst, RECT *pDstRect, uint32_t cRects, uint32_t fFlags)
{
cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pDst->target, pDst->hwid, 0);
// cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
// cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
}