server_muralfbo.cpp revision f64b17becdfd09ab00db844f13d1e776d7823bd5
/* $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"
{
return;
{
crServerRedirMuralFBO(mural, false);
}
return;
crServerRedirMuralFBO(mural, true);
}
{
return;
}
{
if (!RT_SUCCESS(rc))
{
return;
}
if (pMI)
}
{
if (!fInited)
{
}
return fSupported;
}
{
uint32_t i;
for (i = 0; i < mural->cUsedFBDatas; ++i)
{
if (RT_SUCCESS(rc))
{
}
else
}
mural->cUsedFBDatas = 0;
{
GLuint j;
continue;
{
}
}
}
{
int rc;
return VINF_SUCCESS;
if (VBoxRectIsZero(&FbRect))
return VINF_SUCCESS;
if (mural->bReceivedRects)
{
}
else
{
DefaultRegionsRect.xLeft = 0;
DefaultRegionsRect.yTop = 0;
cRegions = 1;
}
if (!cRegions)
return VINF_SUCCESS;
{
{
}
rc = CrFbEntryCreateForTexData(hFb, pData->apTexDatas[CR_SERVER_FBO_FB_IDX(mural)], 0, &pData->hFbEntry);
if (!RT_SUCCESS(rc))
{
}
}
else
{
}
if (!RT_SUCCESS(rc))
{
return rc;
}
if (!RT_SUCCESS(rc))
{
}
return rc;
}
{
uint32_t i;
for (i = 0; i < mural->cUsedFBDatas; ++i)
{
if (RT_SUCCESS(rc))
{
++cUsedFBs;
}
else
}
mural->cUsedFBDatas = 0;
)
goto end;
for (hFb = CrPMgrFbGetFirstEnabled();
hFb;
{
if (!RT_SUCCESS(rc))
{
continue;
}
if (!pData)
continue;
++mural->cUsedFBDatas;
}
end:
for (i = 0; i < cUsedFBs; ++i)
{
CrFbUpdateEnd(ahUsedFbs[i]);
}
}
{
uint32_t i;
for (i = 0; i < pMI->cUsedFBDatas; ++i)
{
continue;
break;
}
}
{
uint32_t i;
bool fFbWasUsed = false;
if (!pMI->fRedirected)
{
return;
}
for (i = 0; i < pMI->cUsedFBDatas; ++i)
{
continue;
fFbWasUsed = true;
break;
}
if (CrFbIsEnabled(hFb))
{
if (!RT_SUCCESS(rc))
{
}
}
if (pData)
{
if (!fFbWasUsed)
{
for (i = 0; i < pMI->cUsedFBDatas; ++i)
{
if (idCurScreen > idScreen)
break;
}
{
}
++pMI->cUsedFBDatas;
}
/* else - nothing to do */
}
else
{
if (fFbWasUsed)
{
{
}
--pMI->cUsedFBDatas;
}
/* else - nothing to do */
}
}
{
}
{
}
{
if (cr_server.fCrCmdEnabled)
{
WARN(("crVBoxServerNotifyResize for enabled CrCmd"));
return VERR_INVALID_STATE;
}
{
WARN(("invalid view index"));
return VERR_INVALID_PARAMETER;
}
if (!RT_SUCCESS(rc))
{
WARN(("err"));
return rc;
}
return VINF_SUCCESS;
}
{
{
return;
}
{
return;
}
if (fEnabled)
{
if (!crServerSupportRedirMuralFBO())
{
WARN(("FBO not supported, can't redirect window output"));
return;
}
{
}
{
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
}
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
}
}
}
else
{
{
{
}
{
}
}
}
}
{
if (!pMuralContextInfo)
{
/* happens on saved state load */
cr_server.head_spu->dispatch_table.MakeCurrent(mural->spuWindow, 0, cr_server.MainContextInfo.SpuContext);
}
{
WARN(("mural visual bits do not match with current context visual bits!"));
}
/*Color texture*/
{
}
{
}
/*Depth&Stencil*/
/*FBO*/
{
{
}
}
/*Restore gl state*/
{
}
{
}
else
{
}
}
{
{
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))
{
}
{
}
{
if (pScreenshot->fDataAllocated)
{
pScreenshot->fDataAllocated = 0;
}
}
DECLEXPORT(int) crServerVBoxScreenshotGet(uint32_t u32Screen, uint32_t width, uint32_t height, uint32_t pitch, void *pvBuffer, CR_SCREENSHOT *pScreenshot)
{
if (!hFb)
return VERR_INVALID_STATE;
if (!width)
if (!height)
if (!pitch)
if (CrFbHas3DData(hFb)
{
if (!pvBuffer)
{
{
WARN(("RTMemAlloc failed"));
return VERR_NO_MEMORY;
}
}
else
{
pScreenshot->fDataAllocated = 0;
}
if (!RT_SUCCESS(rc))
{
return rc;
}
}
else
{
if (!pvBuffer)
else
{
}
pScreenshot->fDataAllocated = 0;
}
return VINF_SUCCESS;
}
{
return CrPMgrModeWinVisible(fShow);
}
{
uint32_t i;
for (i = 0; i < mural->cUsedFBDatas; ++i)
{
if (RT_SUCCESS(rc))
{
CrFbEntryTexDataUpdate(pData->hFb, pData->hFbEntry, pData->apTexDatas[CR_SERVER_FBO_FB_IDX(mural)]);
}
else
}
}
{
#ifdef DEBUG_misha
{
}
#endif
}
{
switch (buffer)
{
case GL_FRONT:
case GL_FRONT_LEFT:
case GL_FRONT_RIGHT:
return CR_SERVER_FBO_FB_IDX(mural);
case GL_BACK:
case GL_BACK_LEFT:
case GL_BACK_RIGHT:
return CR_SERVER_FBO_BB_IDX(mural);
case GL_NONE:
case GL_AUX0:
case GL_AUX1:
case GL_AUX2:
case GL_AUX3:
case GL_LEFT:
case GL_RIGHT:
case GL_FRONT_AND_BACK:
return -1;
default:
return -2;
}
}
{
if (mural->iCurDrawBuffer >= 0)
if (mural->iCurReadBuffer >= 0)
Assert(iOldCurDrawBuffer != mural->iCurDrawBuffer || mural->cBuffers == 1 || mural->iCurDrawBuffer < 0);
Assert(iOldCurReadBuffer != mural->iCurReadBuffer || mural->cBuffers == 1 || mural->iCurReadBuffer < 0);
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
}
{
cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
}
}