server_presenter.cpp revision 84b1d41c77fb464c688baaeed7bdbaf327f88921
/* $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>
#include <iprt/memcache.h>
#include "render/renderspu.h"
/* DISPLAY */
{
{
crWarning("crServerMuralInit failed!");
return VERR_GENERAL_FAILURE;
}
return VINF_SUCCESS;
}
{
}
{
{
}
else
}
{
}
{
{
++u32;
}
{
rc = CrVrScrCompositorEntryRegionsGet(&pDisplay->Mural.Compositor, &pDEntry->CEntry, &u32, NULL, NULL, &pRects);
if (u32)
{
}
}
return VINF_SUCCESS;
}
{
if (!u32)
return VINF_SUCCESS;
{
if (cRects)
{
}
if (pRects)
}
return VINF_SUCCESS;
}
int CrDpEntryRegionsSet(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions)
{
int rc = CrVrScrCompositorEntryRegionsSet(&pDisplay->Mural.Compositor, pEntry ? &pEntry->CEntry : NULL, pPos, cRegions, paRegions, false, NULL);
return rc;
}
{
}
{
{
crDbgDumpRect(i, &paRects[i]);
}
}
int CrDpEntryRegionsAdd(PCR_DISPLAY pDisplay, PCR_DISPLAY_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions, CR_DISPLAY_ENTRY_MAP *pMap)
{
uint32_t fChangeFlags = 0;
if (pMap)
int rc = CrVrScrCompositorEntryRegionsAdd(&pDisplay->Mural.Compositor, pEntry ? &pEntry->CEntry : NULL, pPos, cRegions, paRegions, false, &pReplacedScrEntry, &fChangeFlags);
if (RT_SUCCESS(rc))
{
{
bool fChanged = true;
{
if (!RT_SUCCESS(rc))
{
fChanged = false;
}
}
if (fChanged)
}
{
{
{
CrVrScrCompositorEntryInit(&pEntry->RootVrCEntry, CrVrScrCompositorEntryTexGet(&pEntry->CEntry), NULL);
CrVrScrCompositorEntryFlagsSet(&pEntry->RootVrCEntry, CrVrScrCompositorEntryFlagsGet(&pEntry->CEntry));
CrVrScrCompositorEntryReplace(&pDisplay->Mural.RootVrCompositor, &pReplacedDEntry->RootVrCEntry, &pEntry->RootVrCEntry);
}
}
else
{
{
bool fChanged = false;
if (RT_SUCCESS(rc))
{
if (fChanged)
}
else
}
}
}
else
{
}
}
else
if (pMap)
return rc;
}
{
bool fChanged = false;
if (fChanged)
{
}
}
#define PCR_DISPLAY_ENTRY_FROM_CENTRY(_pe) ((PCR_DISPLAY_ENTRY)((uint8_t*)(_pe) - RT_OFFSETOF(CR_DISPLAY_ENTRY, CEntry)))
static DECLCALLBACK(void) crDpEntryCEntryReleaseCB(const struct VBOXVR_SCR_COMPOSITOR *pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacingEntry)
{
}
void CrDpEntryInit(PCR_DISPLAY_ENTRY pEntry, const VBOXVR_TEXTURE *pTextureData, uint32_t fFlags, PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased)
{
pEntry->idInvertTex = 0;
}
{
{
}
if (pDEntry->idInvertTex)
{
pDEntry->idInvertTex = 0;
}
if (pDEntry->pvORInstance)
{
}
}
{
}
{
}
{
}
typedef struct CR_DEM_ENTRY_INFO
{
typedef struct CR_DEM_ENTRY
{
} CR_DEM_ENTRY;
#define PCR_DEM_ENTRY_FROM_ENTRY(_pEntry) ((CR_DEM_ENTRY*)((uint8_t*)(_pEntry) - RT_OFFSETOF(CR_DEM_ENTRY, Entry)))
static RTMEMCACHE g_VBoxCrDemLookasideList;
int CrDemGlobalInit()
{
0, /* size_t cbAlignment */
UINT32_MAX, /* uint32_t cMaxObjects */
NULL, /* PFNMEMCACHECTOR pfnCtor*/
NULL, /* PFNMEMCACHEDTOR pfnDtor*/
NULL, /* void *pvUser*/
0 /* uint32_t fFlags*/
);
if (RT_SUCCESS(rc))
{
0, /* size_t cbAlignment */
UINT32_MAX, /* uint32_t cMaxObjects */
NULL, /* PFNMEMCACHECTOR pfnCtor*/
NULL, /* PFNMEMCACHEDTOR pfnDtor*/
NULL, /* void *pvUser*/
0 /* uint32_t fFlags*/
);
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
else
}
else
return VINF_SUCCESS;
}
void CrDemTeGlobalTerm()
{
}
static CR_DEM_ENTRY* crDemEntryAlloc()
{
}
static CR_DEM_ENTRY_INFO* crDemEntryInfoAlloc()
{
}
{
}
{
}
{
{
}
{
/* on the host side, we need to delete an ogl texture object here as well, which crStateDeleteTextureCallback will do
* in addition to calling crStateDeleteTextureObject to delete a state object */
}
else
}
{
if (pMap->pTexIdToDemInfoMap)
{
return VINF_SUCCESS;
}
crWarning("crAllocHashtable failed");
return VERR_NO_MEMORY;
}
{
}
{
}
void CrDemLeave(PCR_DISPLAY_ENTRY_MAP pMap, PCR_DISPLAY_ENTRY pNewEntry, PCR_DISPLAY_ENTRY pReplacedEntry)
{
if (pNewEntry && pReplacedEntry)
{
{
}
}
{
{
}
}
}
{
}
{
return rc;
}
{
if (!pEntry)
{
crWarning("CrDemEntryAcquire failed");
return VERR_NO_MEMORY;
}
return VINF_SUCCESS;
}
{
if (!pShared)
{
crWarning("pShared is null!");
return NULL;
}
if (!pTobj)
{
crWarning("pTobj is null!");
return NULL;
}
if (!hwId)
{
crWarning("hwId is null!");
return NULL;
}
pDemEntry = crDemEntryAlloc();
if (!pDemEntry)
{
crWarning("crDemEntryAlloc failed allocating CR_DEM_ENTRY");
return NULL;
}
CR_DEM_ENTRY_INFO *pInfo = (CR_DEM_ENTRY_INFO*)crHashtableSearch(pMap->pTexIdToDemInfoMap, pTobj->id);
if (!pInfo)
{
pInfo = crDemEntryInfoAlloc();
}
/* just use main context info's context to hold the texture reference */
}
{
if (idScreen >= CR_MAX_GUEST_MONITORS)
{
return NULL;
}
{
}
return NULL;
}
{
if (idScreen >= CR_MAX_GUEST_MONITORS)
{
return NULL;
}
{
}
if (RT_SUCCESS(rc))
{
}
else
{
}
return NULL;
}
{
int rc;
int cDisplays = 0, i;
for (i = 0; i < cr_server.screenCount; ++i)
{
++cDisplays;
}
if (!cDisplays)
return VINF_SUCCESS;
for (i = 0; i < cr_server.screenCount; ++i)
{
}
for (i = 0; i < cr_server.screenCount; ++i)
{
{
}
}
return VINF_SUCCESS;
}
{
int rc;
int cDisplays, screenCount, i;
if (!cDisplays)
return VINF_SUCCESS;
for (i = 0; i < cr_server.screenCount; ++i)
{
int32_t x, y;
uint32_t w, h;
}
for (i = 0; i < cDisplays; ++i)
{
int iScreen;
if (!pDisplay)
{
crWarning("crServerDisplayGet failed");
return VERR_GENERAL_FAILURE;
}
}
return VINF_SUCCESS;
}
void crServerDisplayTermAll()
{
int i;
for (i = 0; i < cr_server.screenCount; ++i)
{
{
}
}
}
{
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);
}
}
void CrHlpPutTexImage(CRContext *pCurCtx, const VBOXVR_TEXTURE *pTexture, GLenum enmFormat, void *pvData)
{
{
}
/*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, const VBOXVR_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, const GLint *pRects)
{
if (idScreen >= CR_MAX_GUEST_MONITORS)
{
crWarning("Invalid guest screen");
return;
}
if (texture)
{
pEntry = CrDemEntryAcquire(&cr_server.PresentTexturepMap, texture, (cfg & CR_PRESENT_FLAG_TEX_NONINVERT_YCOORD) ? 0 : CRBLT_F_INVERT_SRC_YCOORDS);
if (!pEntry)
{
crWarning("CrDemEntryAcquire Failed");
return;
}
if (!pDisplay)
{
crWarning("crServerDisplayGet Failed");
return;
}
}
else
{
if (!pDisplay)
{
/* no display initialized, and nothing to present */
return;
}
}
if (!(cfg & CR_PRESENT_FLAG_CLEAR_RECTS))
{
int rc = CrDpEntryRegionsAdd(pDisplay, pEntry, &Point, (uint32_t)cRects, (const RTRECT*)pRects, &cr_server.PresentTexturepMap);
if (!RT_SUCCESS(rc))
{
// if (pEntry)
// CrDemEntryRelease(pEntry);
return;
}
}
else
{
}
}