[PATCH 6/9] d2d1: Move CreateEffect() implementation to effect context.

Ziqing Hui zhui at codeweavers.com
Wed Apr 27 23:26:18 CDT 2022


Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
---
 dlls/d2d1/device.c | 17 ++++-------------
 dlls/d2d1/effect.c | 22 ++++++++++++++++++++--
 2 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c
index 13c99458cfa..8f23f44051b 100644
--- a/dlls/d2d1/device.c
+++ b/dlls/d2d1/device.c
@@ -1890,25 +1890,16 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceCont
         REFCLSID effect_id, ID2D1Effect **effect)
 {
     struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
-    struct d2d_effect *object;
-    HRESULT hr;
+    struct d2d_effect_context *effect_context;
 
     FIXME("iface %p, effect_id %s, effect %p stub!\n", iface, debugstr_guid(effect_id), effect);
 
-    if (!(object = heap_alloc_zero(sizeof(*object))))
+    if (!(effect_context = heap_alloc_zero(sizeof(*effect_context))))
         return E_OUTOFMEMORY;
 
-    if (FAILED(hr = d2d_effect_init(object, context->factory, effect_id)))
-    {
-        WARN("Failed to initialise effect, hr %#lx.\n", hr);
-        heap_free(object);
-        return hr;
-    }
+    d2d_effect_context_init(effect_context, iface);
 
-    TRACE("Created effect %p.\n", object);
-    *effect = &object->ID2D1Effect_iface;
-
-    return S_OK;
+    return ID2D1EffectContext_CreateEffect(&effect_context->ID2D1EffectContext_iface, effect_id, effect);
 }
 
 static HRESULT STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_CreateGradientStopCollection(
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c
index af826701beb..f931c494a07 100644
--- a/dlls/d2d1/effect.c
+++ b/dlls/d2d1/effect.c
@@ -92,9 +92,27 @@ static void STDMETHODCALLTYPE d2d_effect_context_GetDpi(ID2D1EffectContext *ifac
 static HRESULT STDMETHODCALLTYPE d2d_effect_context_CreateEffect(ID2D1EffectContext *iface,
         REFCLSID clsid, ID2D1Effect **effect)
 {
-    FIXME("iface %p, clsid %s, effect %p stub!\n", iface, debugstr_guid(clsid), effect);
+    struct d2d_effect_context *effect_context = impl_from_ID2D1EffectContext(iface);
+    struct d2d_effect *object;
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    TRACE("iface %p, clsid %s, effect %p.\n", iface, debugstr_guid(clsid), effect);
+
+    if (!(object = heap_alloc_zero(sizeof(*object))))
+        return E_OUTOFMEMORY;
+
+    if (FAILED(hr = d2d_effect_init(object,
+            &effect_context->ID2D1EffectContext_iface, effect_context->factory, clsid)))
+    {
+        WARN("Failed to initialise effect, hr %#lx.\n", hr);
+        heap_free(object);
+        return hr;
+    }
+
+    TRACE("Created effect %p.\n", object);
+    *effect = &object->ID2D1Effect_iface;
+
+    return S_OK;
 }
 
 static HRESULT STDMETHODCALLTYPE d2d_effect_context_GetMaximumSupportedFeatureLevel(ID2D1EffectContext *iface,
-- 
2.25.1




More information about the wine-devel mailing list