From: Riccardo Bortolato Subject: [PATCH 07/12] wined3d: replace wined3d_{surface, volume}_(un)map with wined3d_texture_(un)map Message-Id: <1442996856-32611-7-git-send-email-rikyz619@gmail.com> Date: Wed, 23 Sep 2015 10:27:31 +0200 this commit changes d3d8, d3d9 and ddraw. the old functions are then removed from the public interface. --- dlls/d3d8/surface.c | 13 +++---------- dlls/d3d8/volume.c | 13 +++---------- dlls/d3d9/surface.c | 13 +++---------- dlls/d3d9/volume.c | 13 +++---------- dlls/ddraw/surface.c | 30 +++++++----------------------- dlls/wined3d/surface.c | 4 ++-- dlls/wined3d/volume.c | 4 ++-- dlls/wined3d/wined3d.spec | 4 ---- dlls/wined3d/wined3d_private.h | 6 ++++++ include/wine/wined3d.h | 5 ----- 10 files changed, 29 insertions(+), 76 deletions(-) diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index aabd3cd..11a2c89 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -209,8 +209,6 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags) { struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface); - struct wined3d_resource *sub_resource; - struct wined3d_surface *wined3d_surface; struct wined3d_box box; struct wined3d_map_desc map_desc; HRESULT hr; @@ -244,9 +242,8 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface, box.back = 1; } - sub_resource = wined3d_texture_get_sub_resource(surface->wined3d_texture, surface->sub_resource_idx); - wined3d_surface = wined3d_surface_from_resource(sub_resource); - hr = wined3d_surface_map(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)) @@ -266,16 +263,12 @@ static HRESULT WINAPI d3d8_surface_LockRect(IDirect3DSurface8 *iface, static HRESULT WINAPI d3d8_surface_UnlockRect(IDirect3DSurface8 *iface) { struct d3d8_surface *surface = impl_from_IDirect3DSurface8(iface); - struct wined3d_resource *sub_resource; - struct wined3d_surface *wined3d_surface; HRESULT hr; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - sub_resource = wined3d_texture_get_sub_resource(surface->wined3d_texture, surface->sub_resource_idx); - wined3d_surface = wined3d_surface_from_resource(sub_resource); - hr = wined3d_surface_unmap(wined3d_surface); + hr = wined3d_texture_unmap(surface->wined3d_texture, surface->sub_resource_idx); wined3d_mutex_unlock(); switch(hr) diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c index cba06bc..b7a84d5 100644 --- a/dlls/d3d8/volume.c +++ b/dlls/d3d8/volume.c @@ -141,8 +141,6 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); - struct wined3d_resource *sub_resource; - struct wined3d_volume *wined3d_volume; struct wined3d_map_desc map_desc; HRESULT hr; @@ -150,9 +148,8 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, iface, locked_box, box, flags); wined3d_mutex_lock(); - sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); - wined3d_volume = wined3d_volume_from_resource(sub_resource); - hr = wined3d_volume_map(wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags); + hr = wined3d_texture_map(volume->wined3d_texture, volume->sub_resource_idx, + &map_desc, (const struct wined3d_box *)box, flags); wined3d_mutex_unlock(); locked_box->RowPitch = map_desc.row_pitch; @@ -165,16 +162,12 @@ static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface) { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); - struct wined3d_resource *sub_resource; - struct wined3d_volume *wined3d_volume; HRESULT hr; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); - wined3d_volume = wined3d_volume_from_resource(sub_resource); - hr = wined3d_volume_unmap(wined3d_volume); + hr = wined3d_texture_unmap(volume->wined3d_texture, volume->sub_resource_idx); wined3d_mutex_unlock(); return hr; diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index 9e5626d..1c44c96 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -245,8 +245,6 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface, D3DLOCKED_RECT *locked_rect, const RECT *rect, DWORD flags) { struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface); - struct wined3d_resource *sub_resource; - struct wined3d_surface *wined3d_surface; struct wined3d_box box; struct wined3d_map_desc map_desc; HRESULT hr; @@ -265,9 +263,8 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface, } wined3d_mutex_lock(); - sub_resource = wined3d_texture_get_sub_resource(surface->wined3d_texture, surface->sub_resource_idx); - wined3d_surface = wined3d_surface_from_resource(sub_resource); - hr = wined3d_surface_map(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)) @@ -282,16 +279,12 @@ static HRESULT WINAPI d3d9_surface_LockRect(IDirect3DSurface9 *iface, static HRESULT WINAPI d3d9_surface_UnlockRect(IDirect3DSurface9 *iface) { struct d3d9_surface *surface = impl_from_IDirect3DSurface9(iface); - struct wined3d_resource *sub_resource; - struct wined3d_surface *wined3d_surface; HRESULT hr; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - sub_resource = wined3d_texture_get_sub_resource(surface->wined3d_texture, surface->sub_resource_idx); - wined3d_surface = wined3d_surface_from_resource(sub_resource); - hr = wined3d_surface_unmap(wined3d_surface); + hr = wined3d_texture_unmap(surface->wined3d_texture, surface->sub_resource_idx); wined3d_mutex_unlock(); switch(hr) diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c index 4c258b9..ca72f99 100644 --- a/dlls/d3d9/volume.c +++ b/dlls/d3d9/volume.c @@ -141,8 +141,6 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - struct wined3d_resource *sub_resource; - struct wined3d_volume *wined3d_volume; struct wined3d_map_desc map_desc; HRESULT hr; @@ -150,9 +148,8 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, iface, locked_box, box, flags); wined3d_mutex_lock(); - sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); - wined3d_volume = wined3d_volume_from_resource(sub_resource); - hr = wined3d_volume_map(wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags); + hr = wined3d_texture_map(volume->wined3d_texture, volume->sub_resource_idx, + &map_desc, (const struct wined3d_box *)box, flags); wined3d_mutex_unlock(); locked_box->RowPitch = map_desc.row_pitch; @@ -165,16 +162,12 @@ static HRESULT WINAPI d3d9_volume_LockBox(IDirect3DVolume9 *iface, static HRESULT WINAPI d3d9_volume_UnlockBox(IDirect3DVolume9 *iface) { struct d3d9_volume *volume = impl_from_IDirect3DVolume9(iface); - struct wined3d_resource *sub_resource; - struct wined3d_volume *wined3d_volume; HRESULT hr; TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - sub_resource = wined3d_texture_get_sub_resource(volume->wined3d_texture, volume->sub_resource_idx); - wined3d_volume = wined3d_volume_from_resource(sub_resource); - hr = wined3d_volume_unmap(wined3d_volume); + hr = wined3d_texture_unmap(volume->wined3d_texture, volume->sub_resource_idx); wined3d_mutex_unlock(); return hr; diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index ac20c17..dcf7c61 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -968,8 +968,6 @@ static HRESULT WINAPI ddraw_surface1_GetAttachedSurface(IDirectDrawSurface *ifac static HRESULT surface_lock(struct ddraw_surface *This, RECT *Rect, DDSURFACEDESC2 *DDSD, DWORD Flags, HANDLE h) { - struct wined3d_resource *sub_resource; - struct wined3d_surface *wined3d_surface; struct wined3d_box box; struct wined3d_map_desc map_desc; HRESULT hr = DD_OK; @@ -1010,13 +1008,10 @@ static HRESULT surface_lock(struct ddraw_surface *This, box.back = 1; } - sub_resource = wined3d_texture_get_sub_resource(This->wined3d_texture, This->sub_resource_idx); - wined3d_surface = wined3d_surface_from_resource(sub_resource); - if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) hr = ddraw_surface_update_frontbuffer(This, Rect, TRUE); if (SUCCEEDED(hr)) - hr = wined3d_surface_map(wined3d_surface, &map_desc, Rect ? &box : NULL, Flags); + hr = wined3d_texture_map(This->wined3d_texture, This->sub_resource_idx, &map_desc, Rect ? &box : NULL, Flags); if (FAILED(hr)) { wined3d_mutex_unlock(); @@ -1184,16 +1179,12 @@ static HRESULT WINAPI ddraw_surface1_Lock(IDirectDrawSurface *iface, RECT *rect, static HRESULT WINAPI DECLSPEC_HOTPATCH ddraw_surface7_Unlock(IDirectDrawSurface7 *iface, RECT *pRect) { struct ddraw_surface *surface = impl_from_IDirectDrawSurface7(iface); - struct wined3d_resource *sub_resource; - struct wined3d_surface *wined3d_surface; HRESULT hr; TRACE("iface %p, rect %s.\n", iface, wine_dbgstr_rect(pRect)); wined3d_mutex_lock(); - sub_resource = wined3d_texture_get_sub_resource(surface->wined3d_texture, surface->sub_resource_idx); - wined3d_surface = wined3d_surface_from_resource(sub_resource); - hr = wined3d_surface_unmap(wined3d_surface); + hr = wined3d_texture_unmap(surface->wined3d_texture, surface->sub_resource_idx); if (SUCCEEDED(hr) && surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) hr = ddraw_surface_update_frontbuffer(surface, &surface->ddraw->primary_lock, FALSE); wined3d_mutex_unlock(); @@ -5233,15 +5224,8 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu } else { - struct wined3d_resource *sub_resource; - struct wined3d_surface *wined3d_surface_src, *wined3d_surface_dst; struct wined3d_map_desc src_map_desc, dst_map_desc; - sub_resource = wined3d_texture_get_sub_resource(src_surface->wined3d_texture, src_surface->sub_resource_idx); - wined3d_surface_src = wined3d_surface_from_resource(sub_resource); - sub_resource = wined3d_texture_get_sub_resource(dst_surface->wined3d_texture, dst_surface->sub_resource_idx); - wined3d_surface_dst = wined3d_surface_from_resource(sub_resource); - /* Copy the src blit color key if the source has one, don't erase * the destination's ckey if the source has none */ if (src_desc->dwFlags & DDSD_CKSRCBLT) @@ -5253,7 +5237,7 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu /* Copy the main memory texture into the surface that corresponds * to the OpenGL texture object. */ - hr = wined3d_surface_map(wined3d_surface_src, &src_map_desc, NULL, 0); + hr = wined3d_texture_map(src_surface->wined3d_texture, src_surface->sub_resource_idx, &src_map_desc, NULL, 0); if (FAILED(hr)) { ERR("Failed to lock source surface, hr %#x.\n", hr); @@ -5261,11 +5245,11 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu return D3DERR_TEXTURE_LOAD_FAILED; } - hr = wined3d_surface_map(wined3d_surface_dst, &dst_map_desc, NULL, 0); + hr = wined3d_texture_map(dst_surface->wined3d_texture, dst_surface->sub_resource_idx, &dst_map_desc, NULL, 0); if (FAILED(hr)) { ERR("Failed to lock destination surface, hr %#x.\n", hr); - wined3d_surface_unmap(wined3d_surface_src); + wined3d_texture_unmap(src_surface->wined3d_texture, src_surface->sub_resource_idx); wined3d_mutex_unlock(); return D3DERR_TEXTURE_LOAD_FAILED; } @@ -5275,8 +5259,8 @@ static HRESULT WINAPI d3d_texture2_Load(IDirect3DTexture2 *iface, IDirect3DTextu else memcpy(dst_map_desc.data, src_map_desc.data, src_map_desc.row_pitch * src_desc->dwHeight); - wined3d_surface_unmap(wined3d_surface_src); - wined3d_surface_unmap(wined3d_surface_dst); + wined3d_texture_unmap(src_surface->wined3d_texture, src_surface->sub_resource_idx); + wined3d_texture_unmap(dst_surface->wined3d_texture, dst_surface->sub_resource_idx); } if (src_surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_MIPMAP) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index f42226d..3399b48 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -2447,7 +2447,7 @@ struct wined3d_surface * CDECL wined3d_surface_from_resource(struct wined3d_reso return surface_from_resource(resource); } -HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface) +HRESULT wined3d_surface_unmap(struct wined3d_surface *surface) { TRACE("surface %p.\n", surface); @@ -2463,7 +2463,7 @@ HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface) return WINED3D_OK; } -HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, +HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) { const struct wined3d_format *format = surface->resource.format; diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index 934245d..0837b96 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -531,7 +531,7 @@ static BOOL wined3d_volume_check_box_dimensions(const struct wined3d_volume *vol return TRUE; } -HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume, +HRESULT wined3d_volume_map(struct wined3d_volume *volume, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) { struct wined3d_device *device = volume->resource.device; @@ -681,7 +681,7 @@ struct wined3d_volume * CDECL wined3d_volume_from_resource(struct wined3d_resour return volume_from_resource(resource); } -HRESULT CDECL wined3d_volume_unmap(struct wined3d_volume *volume) +HRESULT wined3d_volume_unmap(struct wined3d_volume *volume) { TRACE("volume %p.\n", volume); diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index a39d946..b101f83 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -232,12 +232,10 @@ @ cdecl wined3d_surface_getdc(ptr ptr) @ cdecl wined3d_surface_incref(ptr) @ cdecl wined3d_surface_is_lost(ptr) -@ cdecl wined3d_surface_map(ptr ptr ptr long) @ cdecl wined3d_surface_preload(ptr) @ cdecl wined3d_surface_releasedc(ptr ptr) @ cdecl wined3d_surface_restore(ptr) @ cdecl wined3d_surface_set_overlay_position(ptr long long) -@ cdecl wined3d_surface_unmap(ptr) @ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr) @ cdecl wined3d_surface_update_overlay_z_order(ptr long ptr) @@ -285,5 +283,3 @@ @ cdecl wined3d_volume_from_resource(ptr) @ cdecl wined3d_volume_get_resource(ptr) -@ cdecl wined3d_volume_map(ptr ptr ptr long) -@ cdecl wined3d_volume_unmap(ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index eb4a0fc..7860c3f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2335,6 +2335,9 @@ void wined3d_volume_get_pitch(const struct wined3d_volume *volume, UINT *row_pit void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) DECLSPEC_HIDDEN; void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN; +HRESULT wined3d_volume_map(struct wined3d_volume *volume, + struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) DECLSPEC_HIDDEN; +HRESULT wined3d_volume_unmap(struct wined3d_volume *volume) DECLSPEC_HIDDEN; void wined3d_volume_validate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN; void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN; @@ -2453,6 +2456,9 @@ HRESULT wined3d_surface_create(struct wined3d_texture *container, const struct w struct wined3d_surface **surface) DECLSPEC_HIDDEN; void wined3d_surface_destroy(struct wined3d_surface *surface) DECLSPEC_HIDDEN; void surface_prepare_map_memory(struct wined3d_surface *surface) DECLSPEC_HIDDEN; +HRESULT wined3d_surface_map(struct wined3d_surface *surface, + struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) DECLSPEC_HIDDEN; +HRESULT wined3d_surface_unmap(struct wined3d_surface *surface) DECLSPEC_HIDDEN; void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info, const struct wined3d_format *format, const RECT *src_rect, UINT src_pitch, const POINT *dst_point, BOOL srgb, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index e9e72eb..514aa35 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2489,8 +2489,6 @@ struct wined3d_resource * __cdecl wined3d_surface_get_resource(struct wined3d_su HRESULT __cdecl wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc); ULONG __cdecl wined3d_surface_incref(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_is_lost(const struct wined3d_surface *surface); -HRESULT __cdecl wined3d_surface_map(struct wined3d_surface *surface, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); void __cdecl wined3d_surface_preload(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc); HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface); @@ -2571,9 +2569,6 @@ ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaratio struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource); struct wined3d_resource * __cdecl wined3d_volume_get_resource(struct wined3d_volume *volume); -HRESULT __cdecl wined3d_volume_map(struct wined3d_volume *volume, - struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); -HRESULT __cdecl wined3d_volume_unmap(struct wined3d_volume *volume); /* Return the integer base-2 logarithm of x. Undefined for x == 0. */ static inline unsigned int wined3d_log2i(unsigned int x) -- 1.9.1