d3d9: Make use of wined3d_texture_map in d3d9_surface_LockRect.

Also store wined3d_texture and sub_resource_idx in d3d9_surface.

Signed-off-by: Riccardo Bortolato <rikyz619@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Riccardo Bortolato 2015-10-12 12:44:10 +02:00 committed by Alexandre Julliard
parent ea51e1f107
commit df1101ff68
3 changed files with 11 additions and 6 deletions

View File

@ -214,6 +214,8 @@ struct d3d9_surface
{
IDirect3DSurface9 IDirect3DSurface9_iface;
struct d3d9_resource resource;
struct wined3d_texture *wined3d_texture;
unsigned int sub_resource_idx;
struct wined3d_surface *wined3d_surface;
struct list rtv_entry;
struct wined3d_rendertarget_view *wined3d_rtv;
@ -224,7 +226,7 @@ struct d3d9_surface
};
struct wined3d_rendertarget_view *d3d9_surface_get_rendertarget_view(struct d3d9_surface *surface) DECLSPEC_HIDDEN;
void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
void surface_init(struct d3d9_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;

View File

@ -3545,7 +3545,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
return E_OUTOFMEMORY;
surface_init(d3d_surface, wined3d_texture_get_parent(wined3d_texture), surface, parent_ops);
surface_init(d3d_surface, wined3d_texture, sub_resource_idx, surface, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);

View File

@ -251,7 +251,8 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface,
}
wined3d_mutex_lock();
hr = wined3d_surface_map(surface->wined3d_surface, &map_desc, rect ? &box : NULL, flags);
hr = wined3d_texture_map(surface->wined3d_texture, surface->sub_resource_idx,
&map_desc, rect ? &box : NULL, flags);
wined3d_mutex_unlock();
if (SUCCEEDED(hr))
@ -356,7 +357,7 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
surface_wined3d_object_destroyed,
};
void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
void surface_init(struct d3d9_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
{
struct wined3d_resource_desc desc;
@ -367,9 +368,11 @@ void surface_init(struct d3d9_surface *surface, IUnknown *container_parent,
surface->resource.refcount = 0;
surface->wined3d_surface = wined3d_surface;
list_init(&surface->rtv_entry);
surface->container = container_parent;
surface->container = wined3d_texture_get_parent(wined3d_texture);
surface->wined3d_texture = wined3d_texture;
surface->sub_resource_idx = sub_resource_idx;
if (container_parent && SUCCEEDED(IUnknown_QueryInterface(container_parent,
if (surface->container && SUCCEEDED(IUnknown_QueryInterface(surface->container,
&IID_IDirect3DBaseTexture9, (void **)&texture)))
{
surface->texture = unsafe_impl_from_IDirect3DBaseTexture9(texture);