server_window.c revision fbf1d226c85c1519ef3f56090014218865d34258
/* 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"
{
}
{
VBOXVR_TEXTURE Tex = {0};
if (!RT_SUCCESS(rc))
{
return -1;
}
/*
* 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);
mural->cVisibleRects = 0;
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;
}
{
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)
{
{
}
}
}
{
{
{
/* 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->fUseFBO == CR_SERVER_REDIR_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); */
/* initially set regions to all visible since this is what some guest assume
* and will not post any more visible regions command */
/* CrVrScrCompositorUnlock(&mural->Compositor); */
{
}
/* 3. (so far not needed for resize, but in case it is in the future) re-set the compositor (see above comment) */
/*
if (mural->fUseFBO != CR_SERVER_REDIR_NONE)
{
cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, &mural->CEntry);
}
*/
}
}
{
/* crDebug("CRServer: Window %d size %d x %d", window, width, height);*/
if (!mural) {
#if EXTRA_WARN
#endif
return;
}
/* Work-around Intel driver bug */
{
}
}
{
/* crDebug("CRServer: Window %d pos %d, %d", window, x, y);*/
if (!mural) {
#if EXTRA_WARN
#endif
return;
}
// 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->fUseFBO == CR_SERVER_REDIR_NONE to make sure the compositor data is always up to date */
Pos.x = x;
Pos.y = y;
/* the compositor lock is not needed actually since we have prevented renderspu from using the compositor */
/* CrVrScrCompositorLock(&mural->Compositor); */
/*CrVrScrCompositorUnlock(&mural->Compositor);*/
/* 3. re-set the compositor (see above comment) */
{
cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, &mural->CEntry);
}
}
}
{
if (!mural) {
#if EXTRA_WARN
#endif
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. 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->fUseFBO = CR_SERVER_REDIR_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); */
CrVrScrCompositorEntryRegionsSet(&mural->Compositor, &mural->CEntry, NULL, cRects, (const RTRECT *)pRects);
/*CrVrScrCompositorUnlock(&mural->Compositor);*/
if (mural->pVisibleRects)
{
}
if (cRects)
{
if (!mural->pVisibleRects)
{
crError("Out of memory in crServerDispatchWindowVisibleRegion");
}
}
{
/* @todo the code assumes that RTRECT == four GLInts. */
}
/* 3. re-set the compositor (see above comment) */
{
cr_server.head_spu->dispatch_table.VBoxPresentComposition(mural->spuWindow, &mural->Compositor, &mural->CEntry);
}
}
{
if (!mural) {
#if EXTRA_WARN
#endif
return;
}
{
}
}
{
if (!mural) {
#if EXTRA_WARN
crWarning("CRServer: invalid window %d passed to crServerSPUWindowID()",
#endif
return -1;
}
}