Commit cb9cc2cc authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d9: Get rid of IDirect3DSurface9Impl.

parent d4c5c03c
......@@ -187,33 +187,21 @@ struct d3d9_swapchain
HRESULT d3d9_swapchain_create(struct d3d9_device *device, D3DPRESENT_PARAMETERS *present_parameters,
struct d3d9_swapchain **swapchain) DECLSPEC_HIDDEN;
/* ----------------- */
/* IDirect3DSurface9 */
/* ----------------- */
/*****************************************************************************
* IDirect3DSurface9 implementation structure
*/
typedef struct IDirect3DSurface9Impl
struct d3d9_surface
{
IDirect3DSurface9 IDirect3DSurface9_iface;
LONG ref;
LONG refcount;
struct wined3d_surface *wined3d_surface;
IDirect3DDevice9Ex *parentDevice;
/* The surface container */
IUnknown *container;
/* If set forward refcounting to this object */
IUnknown *forwardReference;
BOOL getdc_supported;
} IDirect3DSurface9Impl;
IDirect3DDevice9Ex *parent_device;
IUnknown *container;
IUnknown *forwardReference;
BOOL getdc_supported;
};
HRESULT surface_init(IDirect3DSurface9Impl *surface, struct d3d9_device *device,
HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *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;
struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
/* ---------------------- */
/* IDirect3DVertexBuffer9 */
......
......@@ -391,7 +391,7 @@ static HRESULT WINAPI d3d9_device_SetCursorProperties(IDirect3DDevice9Ex *iface,
UINT hotspot_x, UINT hotspot_y, IDirect3DSurface9 *bitmap)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *bitmap_impl = unsafe_impl_from_IDirect3DSurface9(bitmap);
struct d3d9_surface *bitmap_impl = unsafe_impl_from_IDirect3DSurface9(bitmap);
HRESULT hr;
TRACE("iface %p, hotspot_x %u, hotspot_y %u, bitmap %p.\n",
......@@ -501,7 +501,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
wined3d_resource_get_desc(resource, &desc);
if (desc.pool == WINED3D_POOL_DEFAULT)
{
IDirect3DSurface9Impl *surface;
struct d3d9_surface *surface;
if (desc.resource_type != WINED3D_RTYPE_SURFACE)
{
......@@ -510,7 +510,7 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
}
surface = wined3d_resource_get_parent(resource);
if (surface->ref)
if (surface->refcount)
{
WARN("Surface %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", surface, resource);
return D3DERR_INVALIDCALL;
......@@ -589,7 +589,7 @@ static HRESULT WINAPI d3d9_device_GetBackBuffer(IDirect3DDevice9Ex *iface, UINT
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_surface *wined3d_surface = NULL;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
HRESULT hr;
TRACE("iface %p, swapchain %u, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
......@@ -706,7 +706,7 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface,
if (set_mem)
{
struct wined3d_resource *resource;
IDirect3DSurface9Impl *surface;
struct d3d9_surface *surface;
resource = wined3d_texture_get_sub_resource(object->wined3d_texture, 0);
surface = wined3d_resource_get_parent(resource);
......@@ -865,7 +865,7 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, IDirect3DSurface9 **surface,
UINT usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
{
IDirect3DSurface9Impl *object;
struct d3d9_surface *object;
HRESULT hr;
TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p.\n"
......@@ -873,8 +873,7 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
device, width, height, format, lockable, discard, level, surface, usage, pool,
multisample_type, multisample_quality);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirect3DSurface9Impl));
if (!object)
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
{
FIXME("Failed to allocate surface memory.\n");
return D3DERR_OUTOFVIDEOMEMORY;
......@@ -943,8 +942,8 @@ static HRESULT WINAPI d3d9_device_UpdateSurface(IDirect3DDevice9Ex *iface,
IDirect3DSurface9 *dst_surface, const POINT *dst_point)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
struct d3d9_surface *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
HRESULT hr;
TRACE("iface %p, src_surface %p, src_rect %p, dst_surface %p, dst_point %p.\n",
......@@ -981,8 +980,8 @@ static HRESULT WINAPI d3d9_device_UpdateTexture(IDirect3DDevice9Ex *iface,
static HRESULT WINAPI d3d9_device_GetRenderTargetData(IDirect3DDevice9Ex *iface,
IDirect3DSurface9 *render_target, IDirect3DSurface9 *dst_surface)
{
IDirect3DSurface9Impl *rt_impl = unsafe_impl_from_IDirect3DSurface9(render_target);
IDirect3DSurface9Impl *dst_impl = unsafe_impl_from_IDirect3DSurface9(dst_surface);
struct d3d9_surface *rt_impl = unsafe_impl_from_IDirect3DSurface9(render_target);
struct d3d9_surface *dst_impl = unsafe_impl_from_IDirect3DSurface9(dst_surface);
HRESULT hr;
TRACE("iface %p, render_target %p, dst_surface %p.\n", iface, render_target, dst_surface);
......@@ -998,7 +997,7 @@ static HRESULT WINAPI d3d9_device_GetFrontBufferData(IDirect3DDevice9Ex *iface,
UINT swapchain, IDirect3DSurface9 *dst_surface)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *dst_impl = unsafe_impl_from_IDirect3DSurface9(dst_surface);
struct d3d9_surface *dst_impl = unsafe_impl_from_IDirect3DSurface9(dst_surface);
HRESULT hr;
TRACE("iface %p, swapchain %u, dst_surface %p.\n", iface, swapchain, dst_surface);
......@@ -1014,8 +1013,8 @@ static HRESULT WINAPI d3d9_device_StretchRect(IDirect3DDevice9Ex *iface, IDirect
const RECT *src_rect, IDirect3DSurface9 *dst_surface, const RECT *dst_rect, D3DTEXTUREFILTERTYPE filter)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
struct d3d9_surface *src = unsafe_impl_from_IDirect3DSurface9(src_surface);
struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(dst_surface);
HRESULT hr = D3DERR_INVALIDCALL;
struct wined3d_resource_desc src_desc, dst_desc;
struct wined3d_resource *wined3d_resource;
......@@ -1085,7 +1084,7 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex *iface,
((color >> 24) & 0xff) / 255.0f,
};
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *surface_impl = unsafe_impl_from_IDirect3DSurface9(surface);
struct d3d9_surface *surface_impl = unsafe_impl_from_IDirect3DSurface9(surface);
struct wined3d_resource *wined3d_resource;
struct wined3d_resource_desc desc;
HRESULT hr;
......@@ -1141,7 +1140,7 @@ static HRESULT WINAPI d3d9_device_CreateOffscreenPlainSurface(IDirect3DDevice9Ex
static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 *surface)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *surface_impl = unsafe_impl_from_IDirect3DSurface9(surface);
struct d3d9_surface *surface_impl = unsafe_impl_from_IDirect3DSurface9(surface);
HRESULT hr;
TRACE("iface %p, idx %u, surface %p.\n", iface, idx, surface);
......@@ -1164,7 +1163,7 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWO
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_surface *wined3d_surface;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
HRESULT hr;
TRACE("iface %p, idx %u, surface %p.\n", iface, idx, surface);
......@@ -1201,7 +1200,7 @@ static HRESULT WINAPI d3d9_device_GetRenderTarget(IDirect3DDevice9Ex *iface, DWO
static HRESULT WINAPI d3d9_device_SetDepthStencilSurface(IDirect3DDevice9Ex *iface, IDirect3DSurface9 *depth_stencil)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
IDirect3DSurface9Impl *ds_impl = unsafe_impl_from_IDirect3DSurface9(depth_stencil);
struct d3d9_surface *ds_impl = unsafe_impl_from_IDirect3DSurface9(depth_stencil);
HRESULT hr;
TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil);
......@@ -1217,7 +1216,7 @@ static HRESULT WINAPI d3d9_device_GetDepthStencilSurface(IDirect3DDevice9Ex *ifa
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
struct wined3d_surface *wined3d_surface;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
HRESULT hr;
TRACE("iface %p, depth_stencil %p.\n", iface, depth_stencil);
......@@ -3095,7 +3094,7 @@ static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *
enum wined3d_pool pool, UINT level, enum wined3d_cubemap_face face, struct wined3d_surface **surface)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
IDirect3DSurface9Impl *d3d_surface;
struct d3d9_surface *d3d_surface;
BOOL lockable = TRUE;
HRESULT hr;
......@@ -3119,8 +3118,8 @@ static HRESULT CDECL device_parent_create_surface(struct wined3d_device_parent *
wined3d_surface_incref(*surface);
d3d_surface->container = container_parent;
IDirect3DDevice9Ex_Release(d3d_surface->parentDevice);
d3d_surface->parentDevice = NULL;
IDirect3DDevice9Ex_Release(d3d_surface->parent_device);
d3d_surface->parent_device = NULL;
IDirect3DSurface9_Release(&d3d_surface->IDirect3DSurface9_iface);
d3d_surface->forwardReference = container_parent;
......@@ -3134,7 +3133,7 @@ static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_par
struct wined3d_surface **surface)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
IDirect3DSurface9Impl *d3d_surface;
struct d3d9_surface *d3d_surface;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
......@@ -3166,7 +3165,7 @@ static HRESULT CDECL device_parent_create_depth_stencil(struct wined3d_device_pa
DWORD multisample_quality, BOOL discard, struct wined3d_surface **surface)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
IDirect3DSurface9Impl *d3d_surface;
struct d3d9_surface *d3d_surface;
HRESULT hr;
TRACE("device_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
......
......@@ -113,7 +113,7 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_swapchain_Present(IDirect3DSwapChai
static HRESULT WINAPI d3d9_swapchain_GetFrontBufferData(IDirect3DSwapChain9 *iface, IDirect3DSurface9 *surface)
{
struct d3d9_swapchain *swapchain = impl_from_IDirect3DSwapChain9(iface);
IDirect3DSurface9Impl *dst = unsafe_impl_from_IDirect3DSurface9(surface);
struct d3d9_surface *dst = unsafe_impl_from_IDirect3DSurface9(surface);
HRESULT hr;
TRACE("iface %p, surface %p.\n", iface, surface);
......@@ -130,7 +130,7 @@ static HRESULT WINAPI d3d9_swapchain_GetBackBuffer(IDirect3DSwapChain9 *iface,
{
struct d3d9_swapchain *swapchain = impl_from_IDirect3DSwapChain9(iface);
struct wined3d_surface *wined3d_surface = NULL;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
HRESULT hr;
TRACE("iface %p, backbuffer_idx %u, backbuffer_type %#x, backbuffer %p.\n",
......
......@@ -326,7 +326,7 @@ static HRESULT WINAPI d3d9_texture_2d_GetSurfaceLevel(IDirect3DTexture9 *iface,
{
struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
struct wined3d_resource *sub_resource;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
TRACE("iface %p, level %u, surface %p.\n", iface, level, surface);
......@@ -350,7 +350,7 @@ static HRESULT WINAPI d3d9_texture_2d_LockRect(IDirect3DTexture9 *iface,
{
struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
struct wined3d_resource *sub_resource;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
HRESULT hr;
TRACE("iface %p, level %u, locked_rect %p, rect %p, flags %#x.\n",
......@@ -373,7 +373,7 @@ static HRESULT WINAPI d3d9_texture_2d_UnlockRect(IDirect3DTexture9 *iface, UINT
{
struct d3d9_texture *texture = impl_from_IDirect3DTexture9(iface);
struct wined3d_resource *sub_resource;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
HRESULT hr;
TRACE("iface %p, level %u.\n", iface, level);
......@@ -748,7 +748,7 @@ static HRESULT WINAPI d3d9_texture_cube_GetCubeMapSurface(IDirect3DCubeTexture9
{
struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
struct wined3d_resource *sub_resource;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
UINT sub_resource_idx;
DWORD level_count;
......@@ -783,7 +783,7 @@ static HRESULT WINAPI d3d9_texture_cube_LockRect(IDirect3DCubeTexture9 *iface,
{
struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
struct wined3d_resource *sub_resource;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
UINT sub_resource_idx;
HRESULT hr;
......@@ -809,7 +809,7 @@ static HRESULT WINAPI d3d9_texture_cube_UnlockRect(IDirect3DCubeTexture9 *iface,
{
struct d3d9_texture *texture = impl_from_IDirect3DCubeTexture9(iface);
struct wined3d_resource *sub_resource;
IDirect3DSurface9Impl *surface_impl;
struct d3d9_surface *surface_impl;
UINT sub_resource_idx;
HRESULT hr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment