[PATCH 2/6] d2d1: Keep a reference to ID2D1Device in d2d_bitmap.

Rémi Bernon rbernon at codeweavers.com
Mon Jan 18 06:57:42 CST 2021


Instead of ID2D1Factory.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
 dlls/d2d1/bitmap.c       | 12 ++++++++----
 dlls/d2d1/d2d1_private.h |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c
index 7ed57052b98..bc58d7d92d5 100644
--- a/dlls/d2d1/bitmap.c
+++ b/dlls/d2d1/bitmap.c
@@ -73,7 +73,7 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_Release(ID2D1Bitmap1 *iface)
         if (bitmap->surface)
             IDXGISurface_Release(bitmap->surface);
         ID3D10Resource_Release(bitmap->resource);
-        ID2D1Factory_Release(bitmap->factory);
+        ID2D1Device_Release(bitmap->device);
         heap_free(bitmap);
     }
 
@@ -86,7 +86,7 @@ static void STDMETHODCALLTYPE d2d_bitmap_GetFactory(ID2D1Bitmap1 *iface, ID2D1Fa
 
     TRACE("iface %p, factory %p.\n", iface, factory);
 
-    ID2D1Factory_AddRef(*factory = bitmap->factory);
+    ID2D1Device_GetFactory(bitmap->device, factory);
 }
 
 static D2D1_SIZE_F * STDMETHODCALLTYPE d2d_bitmap_GetSize(ID2D1Bitmap1 *iface, D2D1_SIZE_F *size)
@@ -277,7 +277,7 @@ static void d2d_bitmap_init(struct d2d_bitmap *bitmap, struct d2d_device_context
 
     bitmap->ID2D1Bitmap1_iface.lpVtbl = &d2d_bitmap_vtbl;
     bitmap->refcount = 1;
-    ID2D1Factory_AddRef(bitmap->factory = context->factory);
+    ID2D1Device_AddRef(bitmap->device = context->device);
     ID3D10Resource_AddRef(bitmap->resource = resource);
     bitmap->pixel_size = size;
     bitmap->format = desc->pixelFormat;
@@ -385,14 +385,18 @@ HRESULT d2d_bitmap_create_shared(struct d2d_device_context *context, REFIID iid,
     if (IsEqualGUID(iid, &IID_ID2D1Bitmap))
     {
         struct d2d_bitmap *src_impl = unsafe_impl_from_ID2D1Bitmap(data);
+        ID2D1Factory *factory;
         ID3D10Device *device;
         HRESULT hr = S_OK;
 
-        if (src_impl->factory != context->factory)
+        ID2D1Device_GetFactory(src_impl->device, &factory);
+        if (factory != context->factory)
         {
+            ID2D1Factory_Release(factory);
             hr = D2DERR_WRONG_FACTORY;
             goto failed;
         }
+        ID2D1Factory_Release(factory);
 
         ID3D10Resource_GetDevice(src_impl->resource, &device);
         ID3D10Device_Release(device);
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 4546d5c1e3a..436c4b0f245 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -348,7 +348,7 @@ struct d2d_bitmap
     ID2D1Bitmap1 ID2D1Bitmap1_iface;
     LONG refcount;
 
-    ID2D1Factory *factory;
+    ID2D1Device *device;
     ID3D10ShaderResourceView *srv;
     ID3D10RenderTargetView *rtv;
     IDXGISurface *surface;
-- 
2.30.0




More information about the wine-devel mailing list