server_muralfbo.c revision 7d448777d6a12a93a6a43c8f90b8429e72917c1a
/* $Id$ */
/** @file
* VBox crOpenGL: Window to FBO redirect support.
*/
/*
* Copyright (C) 2010-2013 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 "server.h"
#include "cr_string.h"
#include "cr_mem.h"
#include "cr_vreg.h"
#include "render/renderspu.h"
{
int i;
for (i=0; i<cr_server.screenCount; ++i)
{
{
return i;
}
}
return -1;
}
{
}
/* Called when a new CRMuralInfo is created
* or when OutputRedirect status is changed.
*/
{
/* Unset the previous redirect. */
{
}
/* Setup a new redirect. */
{
/* Query supported formats. */
if (pachFormats)
{
0 /* H3DOR_PROP_FORMATS */, // @todo from a header
if (RT_SUCCESS(rc))
{
{
"H3DOR_FMT_RGBA_TOPDOWN"); // @todo from a header
}
}
}
/* If this is not NULL then there was a supported format. */
{
// @todo the code assumes that RTRECT == four of GLInts
}
}
}
{
int overlappingScreenCount, primaryS, i;
return;
{
cr_server.head_spu->dispatch_table.WindowPosition(mural->spuWindow, mural->hX - pVieport->x, mural->hY - pVieport->y);
return;
}
{
}
else
{
for (i=0; i<cr_server.screenCount; ++i)
{
|| crServerMuralCoverScreen(mural, i))
{
}
}
if (!overlappingScreenCount)
{
primaryS = 0;
}
}
{
}
{
{
}
cr_server.head_spu->dispatch_table.WindowPosition(mural->spuWindow, mural->hX - pVieport->x, mural->hY - pVieport->y);
}
else
{
GLubyte redir = overlappingScreenCount >= 2 ? CR_SERVER_REDIR_FBO_RAM : cr_server.bForceOffscreenRendering;
{
{
{
}
}
{
}
}
#ifdef DEBUG_misha
else
{
}
#endif
{
cr_server.head_spu->dispatch_table.WindowPosition(mural->spuWindow, mural->hX - pVieport->x, mural->hY - pVieport->y);
}
}
{
}
}
{
if (!fInited)
{
}
return fSupported;
}
{
{
if (redir)
return;
}
if (redir)
{
if (!crServerSupportRedirMuralFBO())
{
crWarning("FBO not supported, can't redirect window output");
return;
}
if (redir == CR_SERVER_REDIR_FBO_RAM)
else
{
}
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, mural->aidFBOs[mural->iCurDrawBuffer]);
}
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, mural->aidFBOs[mural->iCurReadBuffer]);
}
{
}
}
else
{
{
{
}
{
}
}
{
}
}
}
{
int RestoreSpuWindow = -1;
int RestoreSpuContext = -1;
if (!pMuralContextInfo)
{
/* happens on saved state load */
cr_server.head_spu->dispatch_table.MakeCurrent(mural->spuWindow, 0, cr_server.MainContextInfo.SpuContext);
RestoreSpuWindow = 0;
RestoreSpuContext = 0;
}
{
crWarning("mural visual bits do not match with current context visual bits!");
}
/*Color texture*/
{
{
}
}
/*Depth&Stencil*/
/*FBO*/
{
{
}
}
/*PBO*/
{
{
crWarning("PBO create failed");
}
}
/*Restore gl state*/
{
}
CrVrScrCompositorEntryTexNameUpdate(&mural->CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
if (RestoreSpuWindow >= 0 && RestoreSpuContext >= 0)
{
}
}
{
{
GLuint i;
{
mural->aidColorTexs[i] = 0;
}
mural->idDepthStencilRB = 0;
{
}
}
{
}
}
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
{
}
{
rect->x2 = MIN(mural->gX+(int)mural->fboWidth, cr_server.screen[sId].x+(int)cr_server.screen[sId].w);
rect->y2 = MIN(mural->gY+(int)mural->fboHeight, cr_server.screen[sId].y+(int)cr_server.screen[sId].h);
}
static void crServerCopySubImage(char *pDst, char* pSrc, CRrecti *pRect, int srcWidth, int srcHeight)
{
int i;
for (i=0; i<height; ++i)
{
pSrc -= srcrowsize;
pDst += dstrowsize;
}
}
{
}
{
int i, j;
{
return;
}
{
return;
}
return;
{
cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, &mural->CEntry);
return;
}
{
crWarning("Mural doesn't have PBO even though bUsePBOForReadback is set!");
}
if (idPBO)
{
}
if (!pixels)
{
crWarning("CrHlpGetTexImage failed in crServerPresentFBO");
return;
}
for (i=0; i<cr_server.screenCount; ++i)
{
{
/* rect in window relative coords */
if (!mural->pVisibleRects)
{
/*we don't get any rects info for guest compiz windows, so we treat windows as visible unless explicitly received 0 visible rects*/
if (!mural->bReceivedRects)
{
if (!tmppixels)
{
crWarning("Out of memory in crServerPresentFBO");
return;
}
/*Note: pfnPresentFBO would free tmppixels*/
cr_server.pfnPresentFBO(tmppixels, i, rect.x1-cr_server.screen[i].x, rect.y1-cr_server.screen[i].y, rect.x2-rect.x1, rect.y2-rect.y1);
}
}
else
{
for (j=0; j<mural->cVisibleRects; ++j)
{
{
if (!tmppixels)
{
crWarning("Out of memory in crServerPresentFBO");
return;
}
/*Note: pfnPresentFBO would free tmppixels*/
}
}
}
}
}
{
/* @todo find out why presentfbo is not called but crorframe is called. */
}
}
{
}
{
|| buffer == GL_FRONT_LEFT
|| buffer == GL_FRONT_RIGHT)
return CR_SERVER_FBO_FB_IDX(mural);
return CR_SERVER_FBO_BB_IDX(mural);
}
{
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, mural->aidFBOs[mural->iCurDrawBuffer]);
}
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, mural->aidFBOs[mural->iCurReadBuffer]);
}
CrVrScrCompositorEntryTexNameUpdate(&mural->CEntry, mural->aidColorTexs[CR_SERVER_FBO_FB_IDX(mural)]);
}