ddraw: Use wined3d_texture_get_pitch() in ddraw_surface_init().

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-12 11:06:07 +01:00 committed by Alexandre Julliard
parent f8c858c375
commit 6e5fa92299
8 changed files with 12 additions and 30 deletions

View File

@ -4774,7 +4774,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
return DDERR_OUTOFVIDEOMEMORY;
}
ddraw_surface_init(ddraw_surface, ddraw, wined3d_texture, sub_resource_idx, surface, parent_ops);
ddraw_surface_init(ddraw_surface, ddraw, wined3d_texture, sub_resource_idx, parent_ops);
*parent = ddraw_surface;
ddraw_update_lost_surfaces(ddraw);

View File

@ -213,7 +213,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) DECLSPEC_HIDDEN;
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
const RECT *rect, BOOL read) DECLSPEC_HIDDEN;

View File

@ -6253,9 +6253,10 @@ fail:
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
const struct wined3d_parent_ops **parent_ops)
{
struct ddraw_texture *texture = wined3d_texture_get_parent(wined3d_texture);
unsigned int texture_level, row_pitch, slice_pitch;
DDSURFACEDESC2 *desc = &surface->surface_desc;
unsigned int version = texture->version;
@ -6290,24 +6291,21 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
*desc = texture->surface_desc;
surface->first_attached = surface;
texture_level = desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP ? sub_resource_idx % desc->u2.dwMipMapCount : 0;
wined3d_texture_get_pitch(wined3d_texture, texture_level, &row_pitch, &slice_pitch);
if (format_is_compressed(&desc->u4.ddpfPixelFormat))
{
unsigned int texture_level, row_pitch;
texture_level = desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP ? sub_resource_idx % desc->u2.dwMipMapCount : 0;
row_pitch = wined3d_surface_get_pitch(wined3d_surface);
if (desc->dwFlags & DDSD_LPSURFACE)
desc->u1.dwLinearSize = ~0u;
else
desc->u1.dwLinearSize = row_pitch * ((max(1, desc->dwHeight >> texture_level) + 3) / 4);
desc->u1.dwLinearSize = slice_pitch;
desc->dwFlags |= DDSD_LINEARSIZE;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_PITCH);
}
else
{
if (!(desc->dwFlags & DDSD_LPSURFACE))
desc->u1.lPitch = wined3d_surface_get_pitch(wined3d_surface);
desc->u1.lPitch = row_pitch;
desc->dwFlags |= DDSD_PITCH;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_LINEARSIZE);
}

View File

@ -1883,19 +1883,6 @@ static inline unsigned short float_32_to_16(const float *in)
return ret;
}
DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
{
unsigned int row_pitch, slice_pitch;
TRACE("surface %p.\n", surface);
wined3d_texture_get_pitch(surface->container, surface->texture_level, &row_pitch, &slice_pitch);
TRACE("Returning %u.\n", row_pitch);
return row_pitch;
}
HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
{
struct wined3d_resource *texture_resource = &surface->container->resource;

View File

@ -499,7 +499,7 @@ void * CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture)
return texture->resource.parent;
}
void wined3d_texture_get_pitch(const struct wined3d_texture *texture,
void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture,
unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
{
const struct wined3d_resource *resource = &texture->resource;

View File

@ -220,8 +220,6 @@
@ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_surface_get_pitch(ptr)
@ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr)
@ cdecl wined3d_swapchain_decref(ptr)
@ cdecl wined3d_swapchain_get_back_buffer(ptr long)
@ -250,6 +248,7 @@
@ cdecl wined3d_texture_get_lod(ptr)
@ cdecl wined3d_texture_get_overlay_position(ptr long ptr ptr)
@ cdecl wined3d_texture_get_parent(ptr)
@ cdecl wined3d_texture_get_pitch(ptr long ptr ptr)
@ cdecl wined3d_texture_get_resource(ptr)
@ cdecl wined3d_texture_get_sub_resource(ptr long)
@ cdecl wined3d_texture_incref(ptr)

View File

@ -2402,8 +2402,6 @@ void wined3d_texture_bind(struct wined3d_texture *texture,
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_force_reload(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
void wined3d_texture_get_pitch(const struct wined3d_texture *texture,
unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
void wined3d_texture_load(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_prepare_texture(struct wined3d_texture *texture,

View File

@ -2479,8 +2479,6 @@ HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device,
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface);
HRESULT __cdecl wined3d_swapchain_create(struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
ULONG __cdecl wined3d_swapchain_decref(struct wined3d_swapchain *swapchain);
@ -2527,6 +2525,8 @@ DWORD __cdecl wined3d_texture_get_lod(const struct wined3d_texture *texture);
HRESULT __cdecl wined3d_texture_get_overlay_position(const struct wined3d_texture *texture,
unsigned int sub_resource_idx, LONG *x, LONG *y);
void * __cdecl wined3d_texture_get_parent(const struct wined3d_texture *texture);
void __cdecl wined3d_texture_get_pitch(const struct wined3d_texture *texture,
unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch);
struct wined3d_resource * __cdecl wined3d_texture_get_resource(struct wined3d_texture *texture);
struct wined3d_resource * __cdecl wined3d_texture_get_sub_resource(const struct wined3d_texture *texture,
UINT sub_resource_idx);