server_window.c revision 0611af71829ed7030bbd0115a9842a6e8ad14626
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "server.h"
#include "server_dispatch.h"
#include "cr_mem.h"
#include "cr_rand.h"
#include "cr_string.h"
{
int rc;
return GL_FALSE;
return GL_FALSE;
rc = CrVrScrCompositorRegionsGet(pMural->fRootVrOn ? &pMural->RootVrCompositor : &pMural->Compositor, &cRegions, NULL, NULL, NULL);
if (RT_FAILURE(rc))
{
return GL_FALSE;
}
if (!cRegions)
return GL_FALSE;
return GL_TRUE;
}
{
return;
if (fIsVisible)
{
}
else
{
}
}
{
}
{
}
{
}
{
int rc = CrVrScrCompositorRegionsGet(pMural->fRootVrOn ? &pMural->RootVrCompositor : &pMural->Compositor, &cRects, NULL, &pRects, NULL);
if (RT_SUCCESS(rc))
{
cr_server.head_spu->dispatch_table.WindowVisibleRegion(pMural->spuWindow, cRects, (const GLint*)pRects);
}
else
}
{
}
GLint crServerMuralInit(CRMuralInfo *mural, const char *dpyName, GLint visBits, GLint preloadWinID, GLboolean fUseDefaultDEntry)
{
int rc;
{
}
/*
* Have first SPU make a new window.
*/
if (spuWindow < 0) {
return spuWindow;
}
/* get initial window size */
cr_server.head_spu->dispatch_table.GetChromiumParametervCR(GL_WINDOW_SIZE_CR, spuWindow, GL_INT, 2, dims);
if (fUseDefaultDEntry)
{
VBOXVR_TEXTURE Tex = {0};
{
}
}
mural->cVisibleRects = 0;
else
if (fUseDefaultDEntry)
{
rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->DefaultDEntry.CEntry, NULL, 1, &Rect, false, NULL);
if (!RT_SUCCESS(rc))
{
return -1;
}
}
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
if (cRects != 1
{
/* do visible rects only if they differ from the default */
}
}
else
{
}
}
}
return windowID;
}
{
dpyName = "";
if (cr_server.sharedWindows) {
int pos, j;
/* find empty position in my (curclient) windowList */
break;
}
}
if (pos == CR_MAX_WINDOWS) {
crWarning("Too many windows in crserver!");
return -1;
}
/* Look if any other client has a window for this slot */
for (j = 0; j < cr_server.numClients; j++) {
/* use that client's window */
crDebug("CRServer: client %p sharing window %d",
return windowID;
}
}
}
/*
* Create a new mural for the new window.
*/
if (!mural)
{
crWarning("crCalloc failed!");
return -1;
}
if (windowID < 0)
{
crWarning("crServerMuralInit failed!");
return windowID;
}
crDebug("CRServer: client %p created new window %d (SPU window %d)",
int pos;
break;
}
}
}
/* ensure we have a dummy mural created right away to avoid potential deadlocks on VM shutdown */
return windowID;
}
static bool crServerVBoxTranslateIntersectRect(CRMuralInfo *mural, const RTRECT *pSrcRect, PRTRECT pDstRect)
{
{
return true;
}
return false;
}
{
}
{
int pos;
{
{
return true;
}
}
return false;
}
{
{
}
{
/* reset the current context to some dummy values to ensure render spu does not switch to a default "0" context,
* which might lead to muralFBO (offscreen rendering) gl entities being created in a scope of that context */
cr_server.head_spu->dispatch_table.MakeCurrent(dummyMural->spuWindow, 0, cr_server.MainContextInfo.SpuContext);
}
else
{
}
if (mural->pVisibleRects)
{
}
}
{
}
{
int found=false;
if (!window)
{
crWarning("Unexpected attempt to delete default mural, ignored!");
return;
}
if (!mural) {
return;
}
{
{
}
/*Same as with contexts, some apps destroy it not in a thread where it was created*/
if (!found)
{
{
continue;
if (found) break;
}
}
if (!found)
{
{
}
}
}
/*Make sure this window isn't active in other clients*/
{
{
}
}
while (pNode)
{
{
}
}
}
#define CR_DENTRY_FROM_CENTRY(_pCentry) ((CR_DISPLAY_ENTRY*)((uint8_t*)(_pCentry) - RT_OFFSETOF(CR_DISPLAY_ENTRY, CEntry)))
static DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) crServerMuralGetRootVrCEntry(VBOXVR_SCR_COMPOSITOR_ENTRY*pEntry, void *pvContext)
{
return &pDEntry->RootVrCEntry;
}
{
int rc;
/* ensure the rootvr compositor does not hold any data,
* i.e. cleanup all rootvr entries data */
rc = CrVrScrCompositorIntersectedList(&mural->Compositor, &cr_server.RootVr, &mural->RootVrCompositor, crServerMuralGetRootVrCEntry, NULL, NULL);
if (!RT_SUCCESS(rc))
{
return rc;
}
return VINF_SUCCESS;
}
{
int rc = VINF_SUCCESS;
return;
/* since we're going to change the current compositor & the window we need to avoid
* renderspu fron dealing with inconsistent data, i.e. modified compositor and
* still unmodified window.
* So what we do is:
* 1. tell renderspu to stop using the current compositor -> renderspu would do necessary synchronization with its redraw thread to ensure compositor is no longer used
* 2. do necessary modifications
* 3. (so far not needed for resize, but in case it is in the future) re-set the compositor */
/* 1. tell renderspu to stop using the current compositor (see above comment) */
/* 2. do necessary modifications (see above comment) */
/* NOTE: we can do it even if mural->fPresentMode == CR_SERVER_REDIR_F_NONE to make sure the compositor data is always up to date */
/* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
/* CrVrScrCompositorLock(&mural->Compositor); */
if (mural->fUseDefaultDEntry)
{
if (!mural->bReceivedRects)
{
if (!RT_SUCCESS(rc))
{
goto end;
}
/* initially set regions to all visible since this is what some guest assume
* and will not post any more visible regions command */
rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->DefaultDEntry.CEntry, NULL, 1, &Rect, false, NULL);
if (!RT_SUCCESS(rc))
{
goto end;
}
}
else
{
if (!RT_SUCCESS(rc))
{
goto end;
}
}
}
else
{
}
/* CrVrScrCompositorUnlock(&mural->Compositor); */
{
}
{
if (!RT_SUCCESS(rc))
{
goto end;
}
}
{
/* always get non-stretched rects for output redirect */
// if (mural->fRootVrOn)
{
if (!RT_SUCCESS(rc))
{
goto end;
}
}
/* @todo the code assumes that RTRECT == four GLInts. */
}
end:
/* 3. (so far not needed for resize, but in case it is in the future) re-set the compositor (see above comment) */
/* uncomment when needed */
/* NOTE: !!! we have mural->fHasPresentationData set to GL_FALSE above, so crServerVBoxCompositionReenable will have no effect in any way
*/
}
{
/* crDebug("CRServer: Window %d size %d x %d", window, width, height);*/
if (!mural) {
#if EXTRA_WARN
#endif
return;
}
{
}
}
{
/* crDebug("CRServer: Window %d pos %d, %d", window, x, y);*/
// if (mural->gX != x || mural->gY != y)
{
/* since we're going to change the current compositor & the window we need to avoid
* renderspu fron dealing with inconsistent data, i.e. modified compositor and
* still unmodified window.
* So what we do is:
* 1. tell renderspu to stop using the current compositor -> renderspu would do necessary synchronization with its redraw thread to ensure compositor is no longer used
* 2. do necessary modifications
* 3. re-set the compositor */
/* 1. tell renderspu to stop using the current compositor (see above comment) */
/* 2. do necessary modifications (see above comment) */
/* NOTE: we can do it even if !(mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY) to make sure the compositor data is always up to date */
{
{
}
/* no need to set position because the position is relative to window */
/*CrVrScrCompositorEntryPosSet(&mural->Compositor, &mural->CEntry, &Pos);*/
{
if (RT_SUCCESS(rc))
{
}
else
{
}
}
}
/* 3. re-set the compositor (see above comment) */
}
}
{
if (!mural) {
#if EXTRA_WARN
#endif
return;
}
crServerMutalPosition(mural, x, y);
}
{
bool fRegionsChanged = false;
int rc = VINF_SUCCESS;
/* since we're going to change the current compositor & the window we need to avoid
* renderspu fron dealing with inconsistent data, i.e. modified compositor and
* still unmodified window.
* So what we do is:
* 1. tell renderspu to stop using the current compositor -> renderspu would do necessary synchronization with its redraw thread to ensure compositor is no longer used
* 2. do necessary modifications
* 3. re-set the compositor */
/* 1. tell renderspu to stop using the current compositor (see above comment) */
/* 2. do necessary modifications (see above comment) */
if (mural->pVisibleRects)
{
}
if (cRects)
{
if (!mural->pVisibleRects)
{
crError("Out of memory in crServerDispatchWindowVisibleRegion");
}
}
if (mural->fUseDefaultDEntry)
{
/* NOTE: we can do it even if !(mural->fPresentMode & CR_SERVER_REDIR_F_DISPLAY) to make sure the compositor data is always up to date */
/* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
/* CrVrScrCompositorLock(&mural->Compositor); */
rc = CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->DefaultDEntry.CEntry, NULL, cRects, (const RTRECT *)pRects, false, &fRegionsChanged);
/*CrVrScrCompositorUnlock(&mural->Compositor);*/
if (!RT_SUCCESS(rc))
{
goto end;
}
}
else
{
fRegionsChanged = true;
}
if (fRegionsChanged)
{
{
if (!RT_SUCCESS(rc))
{
goto end;
}
}
{
const RTRECT * pRealRects;
/* always get unstretched regions here */
if (!RT_SUCCESS(rc))
{
goto end;
}
/* @todo the code assumes that RTRECT == four GLInts. */
cr_server.outputRedirect.CRORVisibleRegion(mural->pvOutputRedirectInstance, cRealRects, pRealRects);
}
}
end:
/* 3. re-set the compositor (see above comment) */
}
{
if (!mural) {
#if EXTRA_WARN
#endif
return;
}
}
{
}
{
if (!mural) {
#if EXTRA_WARN
#endif
return;
}
}
{
if (!mural) {
#if EXTRA_WARN
crWarning("CRServer: invalid window %d passed to crServerSPUWindowID()",
#endif
return -1;
}
}