d3d9: Use unsafe_impl_from_IDirect3DSurface9 for app provided ifaces.

This commit is contained in:
Michael Stefaniuc 2011-07-07 10:54:02 +02:00 committed by Alexandre Julliard
parent 640234c504
commit a7530e7892
4 changed files with 29 additions and 17 deletions

View File

@ -241,6 +241,7 @@ typedef struct 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) DECLSPEC_HIDDEN;
IDirect3DSurface9Impl *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
/* ---------------------- */
/* IDirect3DVertexBuffer9 */

View File

@ -400,7 +400,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetCursorProperties(IDirect3DDevice9E
UINT XHotSpot, UINT YHotSpot, IDirect3DSurface9 *pCursorBitmap)
{
IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pCursorBitmap;
IDirect3DSurface9Impl *pSurface = unsafe_impl_from_IDirect3DSurface9(pCursorBitmap);
HRESULT hr;
TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n",
@ -970,15 +970,16 @@ static HRESULT WINAPI IDirect3DDevice9Impl_UpdateSurface(IDirect3DDevice9Ex *ifa
IDirect3DSurface9 *pDestinationSurface, const POINT *pDestPoint)
{
IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *src = unsafe_impl_from_IDirect3DSurface9(pSourceSurface);
IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(pDestinationSurface);
HRESULT hr;
TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
iface, pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
wined3d_mutex_lock();
hr = wined3d_device_update_surface(This->wined3d_device,
((IDirect3DSurface9Impl *)pSourceSurface)->wined3d_surface, pSourceRect,
((IDirect3DSurface9Impl *)pDestinationSurface)->wined3d_surface, pDestPoint);
hr = wined3d_device_update_surface(This->wined3d_device, src->wined3d_surface, pSourceRect,
dst->wined3d_surface, pDestPoint);
wined3d_mutex_unlock();
return hr;
@ -1004,8 +1005,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_UpdateTexture(IDirect3DDevice9Ex *ifa
static HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTargetData(IDirect3DDevice9Ex *iface,
IDirect3DSurface9 *pRenderTarget, IDirect3DSurface9 *pDestSurface)
{
IDirect3DSurface9Impl *renderTarget = (IDirect3DSurface9Impl *)pRenderTarget;
IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
IDirect3DSurface9Impl *renderTarget = unsafe_impl_from_IDirect3DSurface9(pRenderTarget);
IDirect3DSurface9Impl *destSurface = unsafe_impl_from_IDirect3DSurface9(pDestSurface);
HRESULT hr;
TRACE("iface %p, render_target %p, dst_surface %p.\n", iface, pRenderTarget, pDestSurface);
@ -1022,7 +1023,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(IDirect3DDevice9Ex
UINT iSwapChain, IDirect3DSurface9 *pDestSurface)
{
IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *destSurface = (IDirect3DSurface9Impl *)pDestSurface;
IDirect3DSurface9Impl *destSurface = unsafe_impl_from_IDirect3DSurface9(pDestSurface);
HRESULT hr;
TRACE("iface %p, swapchain %u, dst_surface %p.\n", iface, iSwapChain, pDestSurface);
@ -1037,8 +1038,8 @@ static HRESULT WINAPI IDirect3DDevice9Impl_GetFrontBufferData(IDirect3DDevice9Ex
static HRESULT WINAPI IDirect3DDevice9Impl_StretchRect(IDirect3DDevice9Ex *iface, IDirect3DSurface9 *pSourceSurface,
const RECT *pSourceRect, IDirect3DSurface9 *pDestSurface, const RECT *pDestRect, D3DTEXTUREFILTERTYPE Filter)
{
IDirect3DSurface9Impl *src = (IDirect3DSurface9Impl *) pSourceSurface;
IDirect3DSurface9Impl *dst = (IDirect3DSurface9Impl *) pDestSurface;
IDirect3DSurface9Impl *src = unsafe_impl_from_IDirect3DSurface9(pSourceSurface);
IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(pDestSurface);
HRESULT hr;
TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_rect %p, filter %#x.\n",
@ -1062,7 +1063,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_ColorFill(IDirect3DDevice9Ex *iface,
((color >> 24) & 0xff) / 255.0f,
};
IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *surface = (IDirect3DSurface9Impl *)pSurface;
IDirect3DSurface9Impl *surface = unsafe_impl_from_IDirect3DSurface9(pSurface);
struct wined3d_resource *wined3d_resource;
struct wined3d_resource_desc desc;
HRESULT hr;
@ -1124,7 +1125,7 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(IDirect3DDevice9Ex *i
DWORD RenderTargetIndex, IDirect3DSurface9 *pRenderTarget)
{
IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
IDirect3DSurface9Impl *pSurface = unsafe_impl_from_IDirect3DSurface9(pRenderTarget);
HRESULT hr;
TRACE("iface %p, idx %u, surface %p.\n", iface, RenderTargetIndex, pRenderTarget);
@ -1190,13 +1191,11 @@ static HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(IDirect3DDevic
IDirect3DSurface9 *pZStencilSurface)
{
IDirect3DDevice9Impl *This = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *pSurface;
IDirect3DSurface9Impl *pSurface = unsafe_impl_from_IDirect3DSurface9(pZStencilSurface);
HRESULT hr;
TRACE("iface %p, depth_stencil %p.\n", iface, pZStencilSurface);
pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
wined3d_mutex_lock();
hr = wined3d_device_set_depth_stencil(This->wined3d_device, pSurface ? pSurface->wined3d_surface : NULL);
wined3d_mutex_unlock();

View File

@ -20,6 +20,7 @@
*/
#include "config.h"
#include <assert.h>
#include "d3d9_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d9);
@ -423,3 +424,12 @@ HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *devic
return D3D_OK;
}
IDirect3DSurface9Impl *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)
{
if (!iface)
return NULL;
assert(iface->lpVtbl == &Direct3DSurface9_Vtbl);
return impl_from_IDirect3DSurface9(iface);
}

View File

@ -98,15 +98,17 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH IDirect3DSwapChain9Impl_Present(LPDIRECT
return hr;
}
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(LPDIRECT3DSWAPCHAIN9 iface, IDirect3DSurface9* pDestSurface) {
static HRESULT WINAPI IDirect3DSwapChain9Impl_GetFrontBufferData(IDirect3DSwapChain9 *iface,
IDirect3DSurface9 *pDestSurface)
{
IDirect3DSwapChain9Impl *This = (IDirect3DSwapChain9Impl *)iface;
IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(pDestSurface);
HRESULT hr;
TRACE("iface %p, surface %p.\n", iface, pDestSurface);
wined3d_mutex_lock();
hr = wined3d_swapchain_get_front_buffer_data(This->wined3d_swapchain,
((IDirect3DSurface9Impl *)pDestSurface)->wined3d_surface);
hr = wined3d_swapchain_get_front_buffer_data(This->wined3d_swapchain, dst->wined3d_surface);
wined3d_mutex_unlock();
return hr;