ddraw: Use wined3d_resource_map() in surface_lock().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-02-02 19:23:29 +01:00 committed by Alexandre Julliard
parent b922b55182
commit 36187987ed
5 changed files with 32 additions and 34 deletions

View File

@ -941,17 +941,17 @@ static HRESULT WINAPI ddraw_surface1_GetAttachedSurface(IDirectDrawSurface *ifac
* For more details, see IWineD3DSurface::LockRect * For more details, see IWineD3DSurface::LockRect
* *
*****************************************************************************/ *****************************************************************************/
static HRESULT surface_lock(struct ddraw_surface *This, static HRESULT surface_lock(struct ddraw_surface *surface,
RECT *Rect, DDSURFACEDESC2 *DDSD, DWORD Flags, HANDLE h) RECT *rect, DDSURFACEDESC2 *surface_desc, DWORD flags, HANDLE h)
{ {
struct wined3d_box box; struct wined3d_box box;
struct wined3d_map_desc map_desc; struct wined3d_map_desc map_desc;
HRESULT hr = DD_OK; HRESULT hr = DD_OK;
TRACE("This %p, rect %s, surface_desc %p, flags %#x, h %p.\n", TRACE("surface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
This, wine_dbgstr_rect(Rect), DDSD, Flags, h); surface, wine_dbgstr_rect(rect), surface_desc, flags, h);
/* This->surface_desc.dwWidth and dwHeight are changeable, thus lock */ /* surface->surface_desc.dwWidth and dwHeight are changeable, thus lock */
wined3d_mutex_lock(); wined3d_mutex_lock();
/* Should I check for the handle to be NULL? /* Should I check for the handle to be NULL?
@ -961,33 +961,31 @@ static HRESULT surface_lock(struct ddraw_surface *This,
*/ */
/* Windows zeroes this if the rect is invalid */ /* Windows zeroes this if the rect is invalid */
DDSD->lpSurface = 0; surface_desc->lpSurface = NULL;
if (Rect) if (rect)
{ {
if ((Rect->left < 0) if ((rect->left < 0) || (rect->top < 0)
|| (Rect->top < 0) || (rect->left > rect->right) || (rect->right > surface->surface_desc.dwWidth)
|| (Rect->left > Rect->right) || (rect->top > rect->bottom) || (rect->bottom > surface->surface_desc.dwHeight))
|| (Rect->top > Rect->bottom)
|| (Rect->right > This->surface_desc.dwWidth)
|| (Rect->bottom > This->surface_desc.dwHeight))
{ {
WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n"); WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
} }
box.left = Rect->left; box.left = rect->left;
box.top = Rect->top; box.top = rect->top;
box.right = Rect->right; box.right = rect->right;
box.bottom = Rect->bottom; box.bottom = rect->bottom;
box.front = 0; box.front = 0;
box.back = 1; box.back = 1;
} }
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(This, Rect, TRUE); hr = ddraw_surface_update_frontbuffer(surface, rect, TRUE);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = wined3d_surface_map(This->wined3d_surface, &map_desc, Rect ? &box : NULL, Flags); hr = wined3d_resource_map(wined3d_texture_get_resource(surface->wined3d_texture),
surface->sub_resource_idx, &map_desc, rect ? &box : NULL, flags);
if (FAILED(hr)) if (FAILED(hr))
{ {
wined3d_mutex_unlock(); wined3d_mutex_unlock();
@ -1004,22 +1002,23 @@ static HRESULT surface_lock(struct ddraw_surface *This,
} }
} }
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{ {
if (Flags & DDLOCK_READONLY) if (flags & DDLOCK_READONLY)
memset(&This->ddraw->primary_lock, 0, sizeof(This->ddraw->primary_lock)); memset(&surface->ddraw->primary_lock, 0, sizeof(surface->ddraw->primary_lock));
else if (Rect) else if (rect)
This->ddraw->primary_lock = *Rect; surface->ddraw->primary_lock = *rect;
else else
SetRect(&This->ddraw->primary_lock, 0, 0, This->surface_desc.dwWidth, This->surface_desc.dwHeight); SetRect(&surface->ddraw->primary_lock, 0, 0, surface->surface_desc.dwWidth, surface->surface_desc.dwHeight);
} }
/* Windows does not set DDSD_LPSURFACE on locked surfaces. */ /* Windows does not set DDSD_LPSURFACE on locked surfaces. */
DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc)); DD_STRUCT_COPY_BYSIZE(surface_desc, &surface->surface_desc);
DDSD->lpSurface = map_desc.data; surface_desc->lpSurface = map_desc.data;
TRACE("locked surface returning description :\n"); TRACE("locked surface returning description :\n");
if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(DDSD); if (TRACE_ON(ddraw))
DDRAW_dump_surface_desc(surface_desc);
wined3d_mutex_unlock(); wined3d_mutex_unlock();

View File

@ -2434,8 +2434,8 @@ HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
return WINED3D_OK; 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,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) const struct wined3d_box *box, DWORD flags)
{ {
const struct wined3d_format *format = surface->resource.format; const struct wined3d_format *format = surface->resource.format;
unsigned int fmt_flags = surface->container->resource.format_flags; unsigned int fmt_flags = surface->container->resource.format_flags;

View File

@ -226,7 +226,6 @@
@ cdecl wined3d_surface_get_parent(ptr) @ cdecl wined3d_surface_get_parent(ptr)
@ cdecl wined3d_surface_get_pitch(ptr) @ cdecl wined3d_surface_get_pitch(ptr)
@ cdecl wined3d_surface_get_resource(ptr) @ cdecl wined3d_surface_get_resource(ptr)
@ cdecl wined3d_surface_map(ptr ptr ptr long)
@ cdecl wined3d_surface_set_overlay_position(ptr long long) @ cdecl wined3d_surface_set_overlay_position(ptr long long)
@ cdecl wined3d_surface_unmap(ptr) @ cdecl wined3d_surface_unmap(ptr)
@ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr) @ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr)

View File

@ -2550,6 +2550,8 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
struct wined3d_context *context) DECLSPEC_HIDDEN; struct wined3d_context *context) DECLSPEC_HIDDEN;
HRESULT surface_load_location(struct wined3d_surface *surface, HRESULT surface_load_location(struct wined3d_surface *surface,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; struct wined3d_context *context, DWORD location) 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;
void surface_modify_ds_location(struct wined3d_surface *surface, DWORD location, UINT w, UINT h) DECLSPEC_HIDDEN; void surface_modify_ds_location(struct wined3d_surface *surface, DWORD location, UINT w, UINT h) DECLSPEC_HIDDEN;
void wined3d_surface_prepare(struct wined3d_surface *surface, struct wined3d_context *context, void wined3d_surface_prepare(struct wined3d_surface *surface, struct wined3d_context *context,
DWORD location) DECLSPEC_HIDDEN; DWORD location) DECLSPEC_HIDDEN;

View File

@ -2479,8 +2479,6 @@ HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surfac
void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface); void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface);
DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface); DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface);
struct wined3d_resource * __cdecl wined3d_surface_get_resource(struct wined3d_surface *surface); struct wined3d_resource * __cdecl wined3d_surface_get_resource(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);
HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y); HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y);
HRESULT __cdecl wined3d_surface_unmap(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_unmap(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect, HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect,