diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index bb3f978081e..f0577ed7dbf 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -188,7 +188,7 @@ struct d2d_mesh ID2D1Factory *factory; }; -void d2d_mesh_init(struct d2d_mesh *mesh, ID2D1Factory *factory) DECLSPEC_HIDDEN; +HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh) DECLSPEC_HIDDEN; struct d2d_bitmap { diff --git a/dlls/d2d1/mesh.c b/dlls/d2d1/mesh.c index 28d34dad964..eb223ad8ea5 100644 --- a/dlls/d2d1/mesh.c +++ b/dlls/d2d1/mesh.c @@ -98,9 +98,15 @@ static const struct ID2D1MeshVtbl d2d_mesh_vtbl = d2d_mesh_Open, }; -void d2d_mesh_init(struct d2d_mesh *mesh, ID2D1Factory *factory) +HRESULT d2d_mesh_create(ID2D1Factory *factory, struct d2d_mesh **mesh) { - mesh->ID2D1Mesh_iface.lpVtbl = &d2d_mesh_vtbl; - mesh->refcount = 1; - ID2D1Factory_AddRef(mesh->factory = factory); + if (!(*mesh = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(**mesh)))) + return E_OUTOFMEMORY; + + (*mesh)->ID2D1Mesh_iface.lpVtbl = &d2d_mesh_vtbl; + (*mesh)->refcount = 1; + ID2D1Factory_AddRef((*mesh)->factory = factory); + + TRACE("Created mesh %p.\n", *mesh); + return S_OK; } diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c index 287d7c3137f..5005840ecd4 100644 --- a/dlls/d2d1/render_target.c +++ b/dlls/d2d1/render_target.c @@ -446,18 +446,14 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateMesh(ID2D1RenderTar { struct d2d_d3d_render_target *render_target = impl_from_ID2D1RenderTarget(iface); struct d2d_mesh *object; + HRESULT hr; TRACE("iface %p, mesh %p.\n", iface, mesh); - if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) - return E_OUTOFMEMORY; + if (SUCCEEDED(hr = d2d_mesh_create(render_target->factory, &object))) + *mesh = &object->ID2D1Mesh_iface; - d2d_mesh_init(object, render_target->factory); - - TRACE("Created mesh %p.\n", object); - *mesh = &object->ID2D1Mesh_iface; - - return S_OK; + return hr; } static void STDMETHODCALLTYPE d2d_d3d_render_target_DrawLine(ID2D1RenderTarget *iface,