diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 3c49c7b326..47ba63cf2c 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -175,9 +175,11 @@ struct d2d_mesh { ID2D1Mesh ID2D1Mesh_iface; LONG refcount; + + ID2D1Factory *factory; }; -void d2d_mesh_init(struct d2d_mesh *mesh) DECLSPEC_HIDDEN; +void d2d_mesh_init(struct d2d_mesh *mesh, ID2D1Factory *factory) DECLSPEC_HIDDEN; struct d2d_bitmap { diff --git a/dlls/d2d1/mesh.c b/dlls/d2d1/mesh.c index b56638291f..28d34dad96 100644 --- a/dlls/d2d1/mesh.c +++ b/dlls/d2d1/mesh.c @@ -65,16 +65,21 @@ static ULONG STDMETHODCALLTYPE d2d_mesh_Release(ID2D1Mesh *iface) TRACE("%p decreasing refcount to %u.\n", iface, refcount); if (!refcount) + { + ID2D1Factory_Release(mesh->factory); HeapFree(GetProcessHeap(), 0, mesh); + } return refcount; } static void STDMETHODCALLTYPE d2d_mesh_GetFactory(ID2D1Mesh *iface, ID2D1Factory **factory) { - FIXME("iface %p, factory %p stub!\n", iface, factory); + struct d2d_mesh *mesh = impl_from_ID2D1Mesh(iface); - *factory = NULL; + TRACE("iface %p, factory %p.\n", iface, factory); + + ID2D1Factory_AddRef(*factory = mesh->factory); } static HRESULT STDMETHODCALLTYPE d2d_mesh_Open(ID2D1Mesh *iface, ID2D1TessellationSink **sink) @@ -93,8 +98,9 @@ static const struct ID2D1MeshVtbl d2d_mesh_vtbl = d2d_mesh_Open, }; -void d2d_mesh_init(struct d2d_mesh *mesh) +void d2d_mesh_init(struct d2d_mesh *mesh, ID2D1Factory *factory) { mesh->ID2D1Mesh_iface.lpVtbl = &d2d_mesh_vtbl; mesh->refcount = 1; + ID2D1Factory_AddRef(mesh->factory = factory); } diff --git a/dlls/d2d1/render_target.c b/dlls/d2d1/render_target.c index a25b8ea63e..438fceda51 100644 --- a/dlls/d2d1/render_target.c +++ b/dlls/d2d1/render_target.c @@ -533,6 +533,7 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateLayer(ID2D1RenderTa static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateMesh(ID2D1RenderTarget *iface, ID2D1Mesh **mesh) { + struct d2d_d3d_render_target *render_target = impl_from_ID2D1RenderTarget(iface); struct d2d_mesh *object; TRACE("iface %p, mesh %p.\n", iface, mesh); @@ -540,7 +541,7 @@ static HRESULT STDMETHODCALLTYPE d2d_d3d_render_target_CreateMesh(ID2D1RenderTar if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) return E_OUTOFMEMORY; - d2d_mesh_init(object); + d2d_mesh_init(object, render_target->factory); TRACE("Created mesh %p.\n", object); *mesh = &object->ID2D1Mesh_iface;