VBoxDispMp.cpp revision d10b60270f0c0eeb87f45002a010cff8ba2126b1
/* $Id$ */
/** @file
* VBoxVideo Display D3D User mode dll
*/
/*
* Copyright (C) 2011 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 "VBoxDispD3DCmn.h"
#include "VBoxDispMp.h"
typedef struct VBOXVIDEOCM_ITERATOR
{
typedef struct VBOXDISPMP
{
} VBOXDISPMP, *PVBOXDISPMP;
DECLINLINE(void) vboxVideoCmIterInit(PVBOXVIDEOCM_ITERATOR pIter, PVBOXVIDEOCM_CMD_HDR pStart, uint32_t cbCmds)
{
}
{
{
return pCur;
}
return NULL;
}
{
}
{
}
static VBOXDISPMP g_VBoxDispMp;
{
g_VBoxDispMp.cbEscapeCmd = 0;
return S_OK;
}
{
if (g_VBoxDispMp.pEscapeCmd)
{
}
return S_OK;
}
#define VBOXDISPMP_BUF_INITSIZE 4000
#define VBOXDISPMP_BUF_INCREASE 4096
{
if (!pHdr)
{
if (!g_VBoxDispMp.pEscapeCmd)
{
if (g_VBoxDispMp.pEscapeCmd)
else
{
return E_OUTOFMEMORY;
}
}
do
{
{
{
pHdr = (PVBOXVIDEOCM_CMD_HDR)(((uint8_t*)g_VBoxDispMp.pEscapeCmd) + sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD));
break;
}
else
{
uint32_t newSize = RT_MAX(g_VBoxDispMp.cbEscapeCmd + VBOXDISPMP_BUF_INCREASE, g_VBoxDispMp.pEscapeCmd->Hdr.cbRemainingFirstCmd);
if (newSize < VBOXDISPMP_BUF_MAXSIZE)
newSize = RT_MAX(newSize, RT_MIN(g_VBoxDispMp.pEscapeCmd->Hdr.cbRemainingCmds, VBOXDISPMP_BUF_MAXSIZE));
if (g_VBoxDispMp.pEscapeCmd)
else
{
g_VBoxDispMp.cbEscapeCmd = 0;
hr = E_OUTOFMEMORY;
break;
}
}
}
else
break;
} while (1);
}
{
PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)(((uint8_t*)pHdr) + sizeof (VBOXVIDEOCM_CMD_HDR));
/* the miniport driver should ensure all swapchain-involved commands are completed before swapchain termination,
* so we should have it always valid here */
}
return hr;
}
{
}
VBOXDISPMP_DECL(HRESULT) VBoxDispMpGetCallbacks(uint32_t u32Version, PVBOXDISPMP_CALLBACKS pCallbacks)
{
if (u32Version != VBOXDISPMP_VERSION)
return E_INVALIDARG;
return S_OK;
}
{
return S_OK;
}
{
return S_OK;
}
HRESULT vboxDispMpInternalCancel(VBOXWDDMDISP_CONTEXT *pContext, PVBOXWDDMDISP_SWAPCHAIN pSwapchain)
{
do
{
/* the pEscapeCmd is used as an indicator to whether the events capturing is active */
if (!g_VBoxDispMp.pEscapeCmd)
break;
/* copy the iterator data to restore it back later */
/* first check if we have matching elements */
bool fHasMatch = false;
{
if (pCurContext != pContext)
continue;
if (!pSwapchain)
{
fHasMatch = true;
break;
}
PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)(((uint8_t*)pHdr) + sizeof (VBOXVIDEOCM_CMD_HDR));
if (pCurSwapchain != pSwapchain)
continue;
fHasMatch = true;
break;
}
/* restore the iterator */
if (!fHasMatch)
break;
/* there are elements to remove */
PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD pEscapeCmd = (PVBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD)RTMemAlloc(g_VBoxDispMp.cbEscapeCmd);
if (!pEscapeCmd)
{
WARN(("no memory"));
hr = E_OUTOFMEMORY;
break;
}
/* copy the header data */
/* now copy the command data filtering out the canceled commands */
pHdr = (PVBOXVIDEOCM_CMD_HDR)(((uint8_t*)pEscapeCmd) + sizeof (VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD));
{
if (pCurContext != pContext)
{
continue;
}
if (!pSwapchain)
{
/* match, just continue */
continue;
}
PVBOXVIDEOCM_CMD_RECTS_INTERNAL pCmdInternal = (PVBOXVIDEOCM_CMD_RECTS_INTERNAL)(((uint8_t*)pHdr) + sizeof (VBOXVIDEOCM_CMD_HDR));
if (pCurSwapchain != pSwapchain)
{
continue;
}
/* match, just continue */
}
} while (0);
return hr;
}