Module: wine Branch: master Commit: e0828a70b27526e271021773f900b9172ca8722d URL: https://gitlab.winehq.org/wine/wine/-/commit/e0828a70b27526e271021773f900b91... Author: Zebediah Figura <zfigura(a)codeweavers.com> Date: Tue Apr 11 19:32:31 2023 -0500 d3d8: Move surface allocation to d3d8_surface_create(). Renamed from d3d8_surface_init() accordingly. --- dlls/d3d8/d3d8_private.h | 4 ++-- dlls/d3d8/device.c | 4 +--- dlls/d3d8/surface.c | 9 ++++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h index 1471ef97708..c1d43b2dfce 100644 --- a/dlls/d3d8/d3d8_private.h +++ b/dlls/d3d8/d3d8_private.h @@ -202,11 +202,11 @@ struct d3d8_surface }; struct wined3d_rendertarget_view *d3d8_surface_acquire_rendertarget_view(struct d3d8_surface *surface) DECLSPEC_HIDDEN; +struct d3d8_surface *d3d8_surface_create(struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, + const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct d3d8_device *d3d8_surface_get_device(const struct d3d8_surface *surface) DECLSPEC_HIDDEN; void d3d8_surface_release_rendertarget_view(struct d3d8_surface *surface, struct wined3d_rendertarget_view *rtv) DECLSPEC_HIDDEN; -void surface_init(struct d3d8_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, - const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN; struct d3d8_vertexbuffer diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 539dd7a89b9..5d96d1b625b 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -3568,12 +3568,10 @@ static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_d { struct d3d8_surface *d3d_surface; - if (!(d3d_surface = heap_alloc_zero(sizeof(*d3d_surface)))) + if (!(d3d_surface = d3d8_surface_create(wined3d_texture, sub_resource_idx, parent_ops))) return E_OUTOFMEMORY; - surface_init(d3d_surface, wined3d_texture, sub_resource_idx, parent_ops); *parent = d3d_surface; - TRACE("Created surface %p.\n", d3d_surface); } else if (type == WINED3D_RTYPE_TEXTURE_3D) { diff --git a/dlls/d3d8/surface.c b/dlls/d3d8/surface.c index bd07a077d08..a0281bff230 100644 --- a/dlls/d3d8/surface.c +++ b/dlls/d3d8/surface.c @@ -309,10 +309,14 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops = surface_wined3d_object_destroyed, }; -void surface_init(struct d3d8_surface *surface, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, +struct d3d8_surface *d3d8_surface_create(struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, const struct wined3d_parent_ops **parent_ops) { IDirect3DBaseTexture8 *texture; + struct d3d8_surface *surface; + + if (!(surface = heap_alloc_zero(sizeof(*surface)))) + return NULL; surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl; d3d8_resource_init(&surface->resource); @@ -330,6 +334,9 @@ void surface_init(struct d3d8_surface *surface, struct wined3d_texture *wined3d_ } *parent_ops = &d3d8_surface_wined3d_parent_ops; + + TRACE("Created surface %p.\n", surface); + return surface; } static void STDMETHODCALLTYPE view_wined3d_object_destroyed(void *parent)