ddraw: Factor out ddraw_surface_lock_ddsd() function.

Signed-off-by: Paul Gofman <gofmanp@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2020-03-26 16:09:40 +03:00 committed by Alexandre Julliard
parent d36a45e553
commit 62ff00b066
1 changed files with 14 additions and 29 deletions

View File

@ -1128,17 +1128,13 @@ static HRESULT WINAPI ddraw_surface4_Lock(IDirectDrawSurface4 *iface, RECT *rect
return surface_lock(surface, rect, surface_desc, surface_desc_size, flags, h);
}
static HRESULT WINAPI ddraw_surface3_Lock(IDirectDrawSurface3 *iface, RECT *rect,
static HRESULT ddraw_surface_lock_ddsd(struct ddraw_surface *surface, RECT *rect,
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
{
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
unsigned int surface_desc_size;
DDSURFACEDESC2 surface_desc2;
HRESULT hr;
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size))
return DDERR_INVALIDPARAMS;
@ -1150,48 +1146,37 @@ static HRESULT WINAPI ddraw_surface3_Lock(IDirectDrawSurface3 *iface, RECT *rect
return hr;
}
static HRESULT WINAPI ddraw_surface3_Lock(IDirectDrawSurface3 *iface, RECT *rect,
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
{
struct ddraw_surface *surface = impl_from_IDirectDrawSurface3(iface);
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h);
}
static HRESULT WINAPI ddraw_surface2_Lock(IDirectDrawSurface2 *iface, RECT *rect,
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
{
struct ddraw_surface *surface = impl_from_IDirectDrawSurface2(iface);
unsigned int surface_desc_size;
DDSURFACEDESC2 surface_desc2;
HRESULT hr;
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size))
return DDERR_INVALIDPARAMS;
surface_desc2.dwSize = surface_desc->dwSize;
surface_desc2.dwFlags = 0;
hr = surface_lock(surface, rect, &surface_desc2, surface_desc_size, flags, h);
DDSD2_to_DDSD(&surface_desc2, surface_desc);
surface_desc->dwSize = surface_desc2.dwSize;
return hr;
return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h);
}
static HRESULT WINAPI ddraw_surface1_Lock(IDirectDrawSurface *iface, RECT *rect,
DDSURFACEDESC *surface_desc, DWORD flags, HANDLE h)
{
struct ddraw_surface *surface = impl_from_IDirectDrawSurface(iface);
unsigned int surface_desc_size;
DDSURFACEDESC2 surface_desc2;
HRESULT hr;
TRACE("iface %p, rect %s, surface_desc %p, flags %#x, h %p.\n",
iface, wine_dbgstr_rect(rect), surface_desc, flags, h);
if (!surface_validate_lock_desc(surface, surface_desc, &surface_desc_size))
return DDERR_INVALIDPARAMS;
surface_desc2.dwSize = surface_desc->dwSize;
surface_desc2.dwFlags = 0;
hr = surface_lock(surface, rect, &surface_desc2, surface_desc_size, flags, h);
DDSD2_to_DDSD(&surface_desc2, surface_desc);
surface_desc->dwSize = surface_desc2.dwSize;
return hr;
return ddraw_surface_lock_ddsd(surface, rect, surface_desc, flags, h);
}
/*****************************************************************************