vboxext.c revision a11b298cea66713a07ea8105ebb4d12574477e9f
/* $Id$ */
/** @file
*
* VBox extension to Wine D3D
*
* 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 "config.h"
#include "wined3d_private.h"
#include "vboxext.h"
typedef FNVBOXEXTWORKERCB *PFNVBOXEXTWORKERCB;
/*******************************/
#ifdef VBOX_WITH_WDDM
# if defined(VBOX_WDDM_WOW64)
# define VBOXEXT_WINE_MODULE_NAME "wined3dwddm-x86.dll"
# else
# define VBOXEXT_WINE_MODULE_NAME "wined3dwddm.dll"
# endif
#else
/* both 32bit and 64bit versions of xpdm wine libs are named identically */
# define VBOXEXT_WINE_MODULE_NAME "wined3d.dll"
#endif
typedef struct VBOXEXT_WORKER
{
/* wine does not seem to guarantie the dll is not unloaded in case FreeLibrary is used
* while d3d object is not terminated, keep an extra reference to ensure we're not unloaded
* while we are active */
/*******************************/
typedef struct VBOXEXT_GLOBAL
{
static VBOXEXT_GLOBAL g_VBoxExtGlobal;
typedef struct VBOXEXT_CALLPROC
{
void *pvCb;
{
NULL /* HWND hWnd */,
WM_USER /* UINT wMsgFilterMin */,
WM_USER /* UINT wMsgFilterMax */,
do
{
0 /*HWND hWnd*/,
0 /*UINT wMsgFilterMin*/,
0 /*UINT wMsgFilterMax*/
);
if(!bResult) /* WM_QUIT was posted */
break;
break;
{
case WM_VBOXEXT_CALLPROC:
{
break;
}
case WM_VBOXEXT_INIT_QUIT:
case WM_CLOSE:
{
PostQuitMessage(0);
break;
}
default:
}
} while (1);
return 0;
}
{
{
return E_FAIL;
}
FALSE, /* BOOL bManualReset */
FALSE, /* BOOL bInitialState */
NULL /* LPCTSTR lpName */
);
{
NULL /* LPSECURITY_ATTRIBUTES lpThreadAttributes */,
0 /* SIZE_T dwStackSize */,
0 /* DWORD dwCreationFlags */,
{
if (WAIT_OBJECT_0 == dwResult)
return S_OK;
}
else
{
}
}
else
{
}
return E_FAIL;
}
{
if (!bResult)
{
return E_FAIL;
}
if (dwErr != WAIT_OBJECT_0)
{
return E_FAIL;
}
return S_OK;
}
{
/* need to serialize since vboxExtWorkerThread is using one pWorker->hEvent
* to signal job completion */
if (bResult)
{
if (fSync)
{
if (dwErr == WAIT_OBJECT_0)
{
}
else
{
}
}
else
}
else
{
return E_FAIL;
}
return hr;
}
{
}
{
}
{
PVBOXEXT_CALLPROC pCallInfo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof (VBOXEXT_CALLPROC) * 2);
if (!pCallInfo)
{
ERR("HeapAlloc failed\n");
return E_OUTOFMEMORY;
}
{
return hr;
}
return S_OK;
}
static HRESULT vboxExtInit()
{
return hr;
}
static HRESULT vboxExtWndCleanup();
static HRESULT vboxExtTerm()
{
{
return hr;
}
{
return hr;
}
return S_OK;
}
/* wine serializes all calls to us, so no need for any synchronization here */
static DWORD g_cVBoxExtInits = 0;
static DWORD vboxExtAddRef()
{
return ++g_cVBoxExtInits;
}
static DWORD vboxExtRelease()
{
return cVBoxExtInits;
}
static DWORD vboxExtGetRef()
{
return g_cVBoxExtInits;
}
{
if (!vboxExtGetRef())
{
hr = vboxExtInit();
{
return hr;
}
}
return S_OK;
}
{
if (vboxExtGetRef() == 1)
{
hr = vboxExtTerm();
{
return hr;
}
}
return S_OK;
}
{
}
{
}
#if defined(VBOX_WINE_WITH_SINGLE_CONTEXT) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT)
# ifndef VBOX_WITH_WDDM
typedef struct VBOXEXT_GETDC_CB
{
{
}
typedef struct VBOXEXT_RELEASEDC_CB
{
int ret;
{
}
{
VBOXEXT_GETDC_CB Data = {0};
{
return NULL;
}
}
{
VBOXEXT_RELEASEDC_CB Data = {0};
{
return -1;
}
}
# endif /* #ifndef VBOX_WITH_WDDM */
{
}
{
{
return;
}
}
#endif /* #if defined(VBOX_WINE_WITH_SINGLE_CONTEXT) || defined(VBOX_WINE_WITH_SINGLE_SWAPCHAIN_CONTEXT) */
/* window creation API */
)
{
switch(uMsg)
{
case WM_CLOSE:
return 0;
case WM_DESTROY:
return 0;
case WM_NCHITTEST:
return HTNOWHERE;
}
}
#define VBOXEXTWND_NAME "VboxDispD3DWineWnd"
static HRESULT vboxExtWndDoCleanup()
{
{
{
}
}
return hr;
}
{
/* Register the Window Class. */
{
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
if (!RegisterClass(&wc))
{
}
}
{
0, 0,
w, h,
NULL, //GetDesktopWindow() /* hWndParent */,
NULL /* hMenu */,
NULL /* lpParam */);
if (hWnd)
{
/* make sure we keep inited until the window is active */
}
else
{
}
}
return hr;
}
{
if (bResult)
{
/* release the reference we previously acquired on window creation */
return S_OK;
}
winErr = GetLastError();
return E_FAIL;
}
typedef struct VBOXEXTWND_CREATE_INFO
{
int hr;
typedef struct VBOXEXTWND_DESTROY_INFO
{
int hr;
typedef struct VBOXEXTWND_CLEANUP_INFO
{
int hr;
{
}
{
}
{
}
{
{
return hr;
}
{
}
return S_OK;
}
{
{
return hr;
}
{
}
return S_OK;
}
static HRESULT vboxExtWndCleanup()
{
{
return hr;
}
{
}
return S_OK;
}