mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-19 21:18:15 +00:00
d3d9: Add a separate function for surface initialization.
This commit is contained in:
parent
57b196b2e4
commit
52e45865bd
|
@ -280,11 +280,6 @@ typedef struct IDirect3DSwapChain9Impl
|
||||||
/* IDirect3DSurface9 */
|
/* IDirect3DSurface9 */
|
||||||
/* ----------------- */
|
/* ----------------- */
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* Predeclare the interface implementation structures
|
|
||||||
*/
|
|
||||||
extern const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl;
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* IDirect3DSurface9 implementation structure
|
* IDirect3DSurface9 implementation structure
|
||||||
*/
|
*/
|
||||||
|
@ -312,6 +307,10 @@ typedef struct IDirect3DSurface9Impl
|
||||||
BOOL getdc_supported;
|
BOOL getdc_supported;
|
||||||
} IDirect3DSurface9Impl;
|
} IDirect3DSurface9Impl;
|
||||||
|
|
||||||
|
HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *device,
|
||||||
|
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level,
|
||||||
|
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality);
|
||||||
|
|
||||||
/* ---------------------- */
|
/* ---------------------- */
|
||||||
/* IDirect3DVertexBuffer9 */
|
/* IDirect3DVertexBuffer9 */
|
||||||
/* ---------------------- */
|
/* ---------------------- */
|
||||||
|
|
|
@ -644,69 +644,36 @@ static void WINAPI IDirect3DDevice9Impl_GetGammaRamp(LPDIRECT3DDEVICE9EX iface,
|
||||||
wined3d_mutex_unlock();
|
wined3d_mutex_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
|
static HRESULT IDirect3DDevice9Impl_CreateSurface(LPDIRECT3DDEVICE9EX iface, UINT Width, UINT Height,
|
||||||
D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,
|
D3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IDirect3DSurface9 **ppSurface,
|
||||||
UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
|
UINT Usage, D3DPOOL Pool, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality)
|
||||||
{
|
{
|
||||||
HRESULT hrc;
|
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
||||||
IDirect3DSurface9Impl *object;
|
IDirect3DSurface9Impl *object;
|
||||||
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
|
HRESULT hr;
|
||||||
TRACE("(%p) Relay\n", This);
|
|
||||||
|
|
||||||
if (MultisampleQuality > 0)
|
|
||||||
{
|
|
||||||
FIXME("MultisampleQuality set to %d, bstituting 0\n", MultisampleQuality);
|
|
||||||
MultisampleQuality = 0;
|
|
||||||
}
|
|
||||||
/*FIXME: Check MAX bounds of MultisampleQuality*/
|
|
||||||
|
|
||||||
/* Allocate the storage for the device */
|
|
||||||
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
|
|
||||||
if (NULL == object) {
|
|
||||||
FIXME("Allocation of memory failed\n");
|
|
||||||
return D3DERR_OUTOFVIDEOMEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
object->lpVtbl = &Direct3DSurface9_Vtbl;
|
|
||||||
object->ref = 1;
|
|
||||||
|
|
||||||
switch(Format)
|
|
||||||
{
|
|
||||||
case D3DFMT_A8R8G8B8:
|
|
||||||
case D3DFMT_X8R8G8B8:
|
|
||||||
case D3DFMT_R5G6B5:
|
|
||||||
case D3DFMT_X1R5G5B5:
|
|
||||||
case D3DFMT_A1R5G5B5:
|
|
||||||
case D3DFMT_R8G8B8:
|
|
||||||
object->getdc_supported = TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
object->getdc_supported = FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
|
TRACE("(%p) : w(%d) h(%d) fmt(%d) surf@%p\n", This, Width, Height, Format, *ppSurface);
|
||||||
|
|
||||||
wined3d_mutex_lock();
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
|
||||||
hrc = IWineD3DDevice_CreateSurface(This->WineD3DDevice, Width, Height, wined3dformat_from_d3dformat(Format),
|
if (!object)
|
||||||
Lockable, Discard, Level, &object->wineD3DSurface, Usage & WINED3DUSAGE_MASK, (WINED3DPOOL)Pool,
|
{
|
||||||
MultiSample, MultisampleQuality, SURFACE_OPENGL, (IUnknown *)object);
|
FIXME("Failed to allocate surface memory.\n");
|
||||||
wined3d_mutex_unlock();
|
return D3DERR_OUTOFVIDEOMEMORY;
|
||||||
|
|
||||||
if (hrc != D3D_OK || NULL == object->wineD3DSurface) {
|
|
||||||
|
|
||||||
/* free up object */
|
|
||||||
FIXME("(%p) call to IWineD3DDevice_CreateSurface failed\n", This);
|
|
||||||
HeapFree(GetProcessHeap(), 0, object);
|
|
||||||
} else {
|
|
||||||
IDirect3DDevice9Ex_AddRef(iface);
|
|
||||||
object->parentDevice = iface;
|
|
||||||
TRACE("(%p) : Created surface %p\n", This, object);
|
|
||||||
*ppSurface = (LPDIRECT3DSURFACE9) object;
|
|
||||||
}
|
}
|
||||||
return hrc;
|
|
||||||
|
hr = surface_init(object, This, Width, Height, Format, Lockable, Discard,
|
||||||
|
Level, Usage, Pool, MultiSample, MultisampleQuality);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
WARN("Failed to initialize surface, hr %#x.\n", hr);
|
||||||
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("Created surface %p.\n", object);
|
||||||
|
*ppSurface = (IDirect3DSurface9 *)object;
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(IDirect3DDevice9Ex *iface, UINT Width, UINT Height,
|
static HRESULT WINAPI IDirect3DDevice9Impl_CreateRenderTarget(IDirect3DDevice9Ex *iface, UINT Width, UINT Height,
|
||||||
|
|
|
@ -298,8 +298,7 @@ static HRESULT WINAPI IDirect3DSurface9Impl_ReleaseDC(LPDIRECT3DSURFACE9 iface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
|
||||||
const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
|
|
||||||
{
|
{
|
||||||
/* IUnknown */
|
/* IUnknown */
|
||||||
IDirect3DSurface9Impl_QueryInterface,
|
IDirect3DSurface9Impl_QueryInterface,
|
||||||
|
@ -322,3 +321,52 @@ const IDirect3DSurface9Vtbl Direct3DSurface9_Vtbl =
|
||||||
IDirect3DSurface9Impl_GetDC,
|
IDirect3DSurface9Impl_GetDC,
|
||||||
IDirect3DSurface9Impl_ReleaseDC
|
IDirect3DSurface9Impl_ReleaseDC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *device,
|
||||||
|
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level,
|
||||||
|
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
surface->lpVtbl = &Direct3DSurface9_Vtbl;
|
||||||
|
surface->ref = 1;
|
||||||
|
|
||||||
|
switch (format)
|
||||||
|
{
|
||||||
|
case D3DFMT_A8R8G8B8:
|
||||||
|
case D3DFMT_X8R8G8B8:
|
||||||
|
case D3DFMT_R5G6B5:
|
||||||
|
case D3DFMT_X1R5G5B5:
|
||||||
|
case D3DFMT_A1R5G5B5:
|
||||||
|
case D3DFMT_R8G8B8:
|
||||||
|
surface->getdc_supported = TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
surface->getdc_supported = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: Check MAX bounds of MultisampleQuality. */
|
||||||
|
if (multisample_quality > 0)
|
||||||
|
{
|
||||||
|
FIXME("Multisample quality set to %u, substituting 0.\n", multisample_quality);
|
||||||
|
multisample_quality = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wined3d_mutex_lock();
|
||||||
|
hr = IWineD3DDevice_CreateSurface(device->WineD3DDevice, width, height, wined3dformat_from_d3dformat(format),
|
||||||
|
lockable, discard, level, &surface->wineD3DSurface, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool,
|
||||||
|
multisample_type, multisample_quality, SURFACE_OPENGL, (IUnknown *)surface);
|
||||||
|
wined3d_mutex_unlock();
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
WARN("Failed to create wined3d surface, hr %#x.\n", hr);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
surface->parentDevice = (IDirect3DDevice9Ex *)device;
|
||||||
|
IDirect3DDevice9Ex_AddRef(surface->parentDevice);
|
||||||
|
|
||||||
|
return D3D_OK;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue