server_presenter.cpp revision 7d448777d6a12a93a6a43c8f90b8429e72917c1a
/* $Id$ */
/** @file
* Presenter API
*/
/*
* Copyright (C) 2012-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 "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"
#include <cr_vreg.h>
/* DISPLAY */
//static DECLCALLBACK(int) crDpCbRegionsChanged(struct CR_PRESENTER *pPresenter)
//{
// uint32_t cRegions;
// const RTRECT *paRegions;
// int rc = CrPtGetRegions(pPresenter, &cRegions, &paRegions);
// if (!RT_SUCCESS(rc))
// {
// crWarning("CrPtGetRegions failed, rc %d", rc);
// return rc;
// }
//
// PCR_DISPLAY pDisplay = CR_DISPLAY_FROM_PRESENTER(pPresenter);
//
// cr_server.head_spu->dispatch_table.WindowVisibleRegion(pDisplay->Mural.spuWindow, cRegions, (GLint*)paRegions);
//
// if (pDisplay->Mural.pvOutputRedirectInstance)
// {
// /* @todo the code assumes that RTRECT == four GLInts. */
// cr_server.outputRedirect.CRORVisibleRegion(pDisplay->Mural.pvOutputRedirectInstance,
// cRegions, paRegions);
// }
//
// return VINF_SUCCESS;
//}
{
if (RT_SUCCESS(rc))
{
{
return VINF_SUCCESS;
// crServerMuralTerm(&pDisplay->Mural);
}
else
{
crWarning("crServerMuralInit failed!");
}
}
else
{
}
return rc;
}
{
}
{
}
int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
{
return CrVrScrCompositorEntryRegionsSet(&pDisplay->Compositor, &pEntry->CEntry, pPos, cRegions, paRegions);
}
int CrDpEntryRegionsAdd(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
{
return CrVrScrCompositorEntryRegionsAdd(&pDisplay->Compositor, &pEntry->CEntry, pPos, cRegions, paRegions);
}
{
CRContext *pCtx = cr_server.currentCtxInfo ? cr_server.currentCtxInfo->pContext : cr_server.MainContextInfo.pContext;
if (pMural)
{
}
cr_server.head_spu->dispatch_table.VBoxPresentComposition(pDisplay->Mural.spuWindow, &pDisplay->Compositor, &pEntry->CEntry);
return VINF_SUCCESS;
}
{
}
{
}
{
if (pMap->pTextureMap)
return VINF_SUCCESS;
crWarning("crAllocHashtable failed!");
return VERR_NO_MEMORY;
}
{
}
PCR_DISPLAY_ENTRY CrDemEntryGetCreate(PCR_DISPLAY_ENTRY_MAP pMap, GLuint idTexture, CRContextInfo *pCtxInfo)
{
if (pEntry)
return pEntry;
if (!pContext)
{
crWarning("pContext is null!");
return NULL;
}
if (!pTobj)
{
crWarning("pTobj is null!");
return NULL;
}
if (!hwId)
{
crWarning("hwId is null!");
return NULL;
}
if (!pEntry)
{
crWarning("crAlloc failed allocating CR_DISPLAY_ENTRY");
return NULL;
}
return pEntry;
}
{
#ifdef DEBUG
{
if (!pEntry)
{
crWarning("request to delete inexistent entry");
return;
}
}
#endif
}
#define CR_PRESENT_SCREEN_MASK 0xffff
#define CR_PRESENT_FLAGS_OFFSET 16
{
return NULL;
}
{
if (idScreen >= CR_MAX_GUEST_MONITORS)
{
return NULL;
}
/* the display (screen id == 0) can be initialized while doing crServerCheckInitDisplayBlitter,
* so re-check the bit map */
if (RT_SUCCESS(rc))
{
}
else
{
}
return NULL;
}
{
if (idPBO)
{
if (pCurCtx)
cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pCurCtx->bufferobject.packBuffer->hwid);
else
}
else
{
cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pCurCtx->bufferobject.packBuffer->hwid);
}
}
{
{
}
/*read the texture, note pixels are NULL for PBO case as it's offset in the buffer*/
cr_server.head_spu->dispatch_table.TexSubImage2D(GL_TEXTURE_2D, 0 /* level*/, 0 /*xoffset*/, 0 /*yoffset*/, pTexture->width, pTexture->height, enmFormat, GL_UNSIGNED_BYTE, pvData);
/*restore gl state*/
if (pCurCtx)
{
}
else
{
}
cr_server.head_spu->dispatch_table.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, pCurCtx->bufferobject.unpackBuffer->hwid);
}
void* CrHlpGetTexImage(CRContext *pCurCtx, PVBOXVR_TEXTURE pTexture, GLuint idPBO, GLenum enmFormat)
{
if (idPBO)
{
}
else
{
{
}
if (!pvData)
{
crWarning("Out of memory in CrHlpGetTexImage");
return NULL;
}
}
/*read the texture, note pixels are NULL for PBO case as it's offset in the buffer*/
cr_server.head_spu->dispatch_table.GetTexImage(GL_TEXTURE_2D, 0, enmFormat, GL_UNSIGNED_BYTE, pvData);
/*restore gl state*/
if (pCurCtx)
{
}
else
{
}
if (idPBO)
{
if (!pvData)
{
crWarning("Failed to MapBuffer in CrHlpGetTexImage");
return NULL;
}
}
return pvData;
}
crServerDispatchVBoxTexPresent(GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, GLint *pRects)
{
if (!pDisplay)
{
crWarning("crServerDisplayGet Failed");
return;
}
PCR_DISPLAY_ENTRY pEntry = CrDemEntryGetCreate(&cr_server.PresentTexturepMap, texture, cr_server.currentCtxInfo);
if (!pEntry)
{
crWarning("CrDemEntryGetCreate Failed");
return;
}
if (!RT_SUCCESS(rc))
{
return;
}
if (!RT_SUCCESS(rc))
{
return;
}
}