From 30d0aa2712dbdfe8f532118f9829c7999c0326a7 Mon Sep 17 00:00:00 2001
From: Lucian Poston <lucian.poston@gmail.com>
Date: Thu, 3 May 2018 00:38:06 -0700
Subject: [PATCH] d2d1: Use ID2D1Factory1 in d2d_geometry

https://bugs.winehq.org/show_bug.cgi?id=44052

Signed-off-by: Lucian Poston <lucian.poston@gmail.com>
---
 dlls/d2d1/d2d1_private.h |  8 ++++----
 dlls/d2d1/factory.c      |  6 +++---
 dlls/d2d1/geometry.c     | 30 +++++++++++++++++++++---------
 3 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 70b841df8cb..85c56524de4 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -424,7 +424,7 @@ struct d2d_geometry
     ID2D1Geometry ID2D1Geometry_iface;
     LONG refcount;
 
-    ID2D1Factory *factory;
+    ID2D1Factory1 *factory;
 
     D2D_MATRIX_3X2_F transform;
 
@@ -494,10 +494,10 @@ struct d2d_geometry
     } u;
 };
 
-void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory) DECLSPEC_HIDDEN;
+void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory1 *factory) DECLSPEC_HIDDEN;
 HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry,
-        ID2D1Factory *factory, const D2D1_RECT_F *rect) DECLSPEC_HIDDEN;
-void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
+        ID2D1Factory1 *factory, const D2D1_RECT_F *rect) DECLSPEC_HIDDEN;
+void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory1 *factory,
         ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform) DECLSPEC_HIDDEN;
 HRESULT d2d_geometry_group_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
         D2D1_FILL_MODE fill_mode, ID2D1Geometry **src_geometries, unsigned int geometry_count) DECLSPEC_HIDDEN;
diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c
index c2a0405abdd..33c2d173596 100644
--- a/dlls/d2d1/factory.c
+++ b/dlls/d2d1/factory.c
@@ -141,7 +141,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateRectangleGeometry(ID2D1Factor
     if (!(object = heap_alloc_zero(sizeof(*object))))
         return E_OUTOFMEMORY;
 
-    if (FAILED(hr = d2d_rectangle_geometry_init(object, (ID2D1Factory *)iface, rect)))
+    if (FAILED(hr = d2d_rectangle_geometry_init(object, iface, rect)))
     {
         WARN("Failed to initialize rectangle geometry, hr %#x.\n", hr);
         heap_free(object);
@@ -207,7 +207,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateTransformedGeometry(ID2D1Fact
     if (!(object = heap_alloc_zero(sizeof(*object))))
         return E_OUTOFMEMORY;
 
-    d2d_transformed_geometry_init(object, (ID2D1Factory *)iface, src_geometry, transform);
+    d2d_transformed_geometry_init(object, iface, src_geometry, transform);
 
     TRACE("Created transformed geometry %p.\n", object);
     *transformed_geometry = (ID2D1TransformedGeometry *)&object->ID2D1Geometry_iface;
@@ -224,7 +224,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreatePathGeometry(ID2D1Factory2 *i
     if (!(object = heap_alloc_zero(sizeof(*object))))
         return E_OUTOFMEMORY;
 
-    d2d_path_geometry_init(object, (ID2D1Factory *)iface);
+    d2d_path_geometry_init(object, iface);
 
     TRACE("Created path geometry %p.\n", object);
     *geometry = (ID2D1PathGeometry *)&object->ID2D1Geometry_iface;
diff --git a/dlls/d2d1/geometry.c b/dlls/d2d1/geometry.c
index 250ff0c5535..7b67e247f7a 100644
--- a/dlls/d2d1/geometry.c
+++ b/dlls/d2d1/geometry.c
@@ -2343,15 +2343,15 @@ static void d2d_geometry_cleanup(struct d2d_geometry *geometry)
     heap_free(geometry->fill.bezier_vertices);
     heap_free(geometry->fill.faces);
     heap_free(geometry->fill.vertices);
-    ID2D1Factory_Release(geometry->factory);
+    ID2D1Factory1_Release(geometry->factory);
 }
 
-static void d2d_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
+static void d2d_geometry_init(struct d2d_geometry *geometry, ID2D1Factory1 *factory,
         const D2D1_MATRIX_3X2_F *transform, const struct ID2D1GeometryVtbl *vtbl)
 {
     geometry->ID2D1Geometry_iface.lpVtbl = vtbl;
     geometry->refcount = 1;
-    ID2D1Factory_AddRef(geometry->factory = factory);
+    ID2D1Factory1_AddRef(geometry->factory = factory);
     geometry->transform = *transform;
 }
 
@@ -3040,10 +3040,14 @@ static ULONG STDMETHODCALLTYPE d2d_path_geometry_Release(ID2D1PathGeometry *ifac
 static void STDMETHODCALLTYPE d2d_path_geometry_GetFactory(ID2D1PathGeometry *iface, ID2D1Factory **factory)
 {
     struct d2d_geometry *geometry = impl_from_ID2D1PathGeometry(iface);
+    HRESULT hr;
 
     TRACE("iface %p, factory %p.\n", iface, factory);
 
-    ID2D1Factory_AddRef(*factory = geometry->factory);
+    if (FAILED(hr = ID2D1Factory1_QueryInterface(geometry->factory, &IID_ID2D1Factory, (void **)factory)))
+    {
+        WARN("Unable to query ID2D1Factory interface %#x", hr);
+    }
 }
 
 static HRESULT STDMETHODCALLTYPE d2d_path_geometry_GetBounds(ID2D1PathGeometry *iface,
@@ -3491,7 +3495,7 @@ static const struct ID2D1PathGeometryVtbl d2d_path_geometry_vtbl =
     d2d_path_geometry_GetFigureCount,
 };
 
-void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory)
+void d2d_path_geometry_init(struct d2d_geometry *geometry, ID2D1Factory1 *factory)
 {
     d2d_geometry_init(geometry, factory, &identity, (ID2D1GeometryVtbl *)&d2d_path_geometry_vtbl);
     geometry->u.path.ID2D1GeometrySink_iface.lpVtbl = &d2d_geometry_sink_vtbl;
@@ -3556,10 +3560,14 @@ static ULONG STDMETHODCALLTYPE d2d_rectangle_geometry_Release(ID2D1RectangleGeom
 static void STDMETHODCALLTYPE d2d_rectangle_geometry_GetFactory(ID2D1RectangleGeometry *iface, ID2D1Factory **factory)
 {
     struct d2d_geometry *geometry = impl_from_ID2D1RectangleGeometry(iface);
+    HRESULT hr;
 
     TRACE("iface %p, factory %p.\n", iface, factory);
 
-    ID2D1Factory_AddRef(*factory = geometry->factory);
+    if (FAILED(hr = ID2D1Factory1_QueryInterface(geometry->factory, &IID_ID2D1Factory, (void **)factory)))
+    {
+        WARN("Unable to query ID2D1Factory interface %#x", hr);
+    }
 }
 
 static HRESULT STDMETHODCALLTYPE d2d_rectangle_geometry_GetBounds(ID2D1RectangleGeometry *iface,
@@ -3779,7 +3787,7 @@ static const struct ID2D1RectangleGeometryVtbl d2d_rectangle_geometry_vtbl =
     d2d_rectangle_geometry_GetRect,
 };
 
-HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory, const D2D1_RECT_F *rect)
+HRESULT d2d_rectangle_geometry_init(struct d2d_geometry *geometry, ID2D1Factory1 *factory, const D2D1_RECT_F *rect)
 {
     struct d2d_face *f;
     D2D1_POINT_2F *v;
@@ -3900,10 +3908,14 @@ static void STDMETHODCALLTYPE d2d_transformed_geometry_GetFactory(ID2D1Transform
         ID2D1Factory **factory)
 {
     struct d2d_geometry *geometry = impl_from_ID2D1TransformedGeometry(iface);
+    HRESULT hr;
 
     TRACE("iface %p, factory %p.\n", iface, factory);
 
-    ID2D1Factory_AddRef(*factory = geometry->factory);
+    if (FAILED(hr = ID2D1Factory1_QueryInterface(geometry->factory, &IID_ID2D1Factory, (void **)factory)))
+    {
+        WARN("Unable to query ID2D1Factory interface %#x", hr);
+    }
 }
 
 static HRESULT STDMETHODCALLTYPE d2d_transformed_geometry_GetBounds(ID2D1TransformedGeometry *iface,
@@ -4096,7 +4108,7 @@ static const struct ID2D1TransformedGeometryVtbl d2d_transformed_geometry_vtbl =
     d2d_transformed_geometry_GetTransform,
 };
 
-void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory *factory,
+void d2d_transformed_geometry_init(struct d2d_geometry *geometry, ID2D1Factory1 *factory,
         ID2D1Geometry *src_geometry, const D2D_MATRIX_3X2_F *transform)
 {
     struct d2d_geometry *src_impl;
-- 
2.20.1

