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

ddraw: Use wined3d_resource_map() in surface_lock().

parent b922b551
......@@ -941,17 +941,17 @@ static HRESULT WINAPI ddraw_surface1_GetAttachedSurface(IDirectDrawSurface *ifac
* For more details, see IWineD3DSurface::LockRect
*
*****************************************************************************/
static HRESULT surface_lock(struct ddraw_surface *This,
RECT *Rect, DDSURFACEDESC2 *DDSD, DWORD Flags, HANDLE h)
static HRESULT surface_lock(struct ddraw_surface *surface,
RECT *rect, DDSURFACEDESC2 *surface_desc, DWORD flags, HANDLE h)
{
struct wined3d_box box;
struct wined3d_map_desc map_desc;
HRESULT hr = DD_OK;
TRACE("This %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
This, wine_dbgstr_rect(Rect), DDSD, Flags, h);
TRACE("surface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
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();
/* 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 */
DDSD->lpSurface = 0;
surface_desc->lpSurface = NULL;
if (Rect)
if (rect)
{
if ((Rect->left < 0)
|| (Rect->top < 0)
|| (Rect->left > Rect->right)
|| (Rect->top > Rect->bottom)
|| (Rect->right > This->surface_desc.dwWidth)
|| (Rect->bottom > This->surface_desc.dwHeight))
if ((rect->left < 0) || (rect->top < 0)
|| (rect->left > rect->right) || (rect->right > surface->surface_desc.dwWidth)
|| (rect->top > rect->bottom) || (rect->bottom > surface->surface_desc.dwHeight))
{
WARN("Trying to lock an invalid rectangle, returning DDERR_INVALIDPARAMS\n");
wined3d_mutex_unlock();
return DDERR_INVALIDPARAMS;
}
box.left = Rect->left;
box.top = Rect->top;
box.right = Rect->right;
box.bottom = Rect->bottom;
box.left = rect->left;
box.top = rect->top;
box.right = rect->right;
box.bottom = rect->bottom;
box.front = 0;
box.back = 1;
}
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(This, Rect, TRUE);
if (surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
hr = ddraw_surface_update_frontbuffer(surface, rect, TRUE);
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))
{
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)
memset(&This->ddraw->primary_lock, 0, sizeof(This->ddraw->primary_lock));
else if (Rect)
This->ddraw->primary_lock = *Rect;
if (flags & DDLOCK_READONLY)
memset(&surface->ddraw->primary_lock, 0, sizeof(surface->ddraw->primary_lock));
else if (rect)
surface->ddraw->primary_lock = *rect;
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. */
DD_STRUCT_COPY_BYSIZE(DDSD,&(This->surface_desc));
DDSD->lpSurface = map_desc.data;
DD_STRUCT_COPY_BYSIZE(surface_desc, &surface->surface_desc);
surface_desc->lpSurface = map_desc.data;
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();
......
......@@ -2434,8 +2434,8 @@ HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
return WINED3D_OK;
}
HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
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;
unsigned int fmt_flags = surface->container->resource.format_flags;
......
......@@ -226,7 +226,6 @@
@ cdecl wined3d_surface_get_parent(ptr)
@ cdecl wined3d_surface_get_pitch(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_unmap(ptr)
@ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr)
......
......@@ -2550,6 +2550,8 @@ void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
struct wined3d_context *context) DECLSPEC_HIDDEN;
HRESULT surface_load_location(struct wined3d_surface *surface,
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 wined3d_surface_prepare(struct wined3d_surface *surface, struct wined3d_context *context,
DWORD location) DECLSPEC_HIDDEN;
......
......@@ -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);
DWORD __cdecl wined3d_surface_get_pitch(const 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_unmap(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect,
......
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