[PATCH v3 3/5] d2d1: Implement d2d_effect_SetInputCount().

Ziqing Hui zhui at codeweavers.com
Thu Aug 5 03:06:03 CDT 2021


Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
---

v3: Return earlier to reduce indentation.
    Use d2d_array_reserve() to resize the inputs array.

 dlls/d2d1/d2d1_private.h |  2 ++
 dlls/d2d1/effect.c       | 34 ++++++++++++++++++++++++++++++++--
 dlls/d2d1/tests/d2d1.c   |  3 +--
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 48d15dfcf22..10d0598f20e 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -575,6 +575,8 @@ struct d2d_effect
     ID2D1Image **inputs;
     size_t inputs_size;
     size_t input_count;
+    UINT32 min_inputs;
+    UINT32 max_inputs;
 };
 
 HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) DECLSPEC_HIDDEN;
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c
index fa616ebe6be..a07ea34c4e2 100644
--- a/dlls/d2d1/effect.c
+++ b/dlls/d2d1/effect.c
@@ -177,9 +177,37 @@ static void STDMETHODCALLTYPE d2d_effect_SetInput(ID2D1Effect *iface, UINT32 ind
 
 static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UINT32 count)
 {
-    FIXME("iface %p, count %u stub!\n", iface, count);
+    struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
+    unsigned int i;
 
-    return E_NOTIMPL;
+    TRACE("iface %p, count %u.\n", iface, count);
+
+    if (count < effect->min_inputs || count > effect->max_inputs)
+        return E_INVALIDARG;
+    if (count == effect->input_count)
+        return S_OK;
+
+    if (count < effect->input_count)
+    {
+        for (i = count; i < effect->input_count; ++i)
+        {
+            if (effect->inputs[i])
+                ID2D1Image_Release(effect->inputs[i]);
+        }
+    }
+
+    if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
+                           count, sizeof(*effect->inputs)))
+    {
+        ERR("Failed to resize inputs array.\n");
+        return E_OUTOFMEMORY;
+    }
+
+    if (count > effect->input_count)
+        memset(effect->inputs + effect->input_count, 0,
+               sizeof(*effect->inputs) * (count - effect->input_count));
+
+    return S_OK;
 }
 
 static void STDMETHODCALLTYPE d2d_effect_GetInput(ID2D1Effect *iface, UINT32 index, ID2D1Image **input)
@@ -286,6 +314,8 @@ HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory)
     ID2D1Factory_AddRef(effect->factory = factory);
 
     effect->input_count = 1;
+    effect->min_inputs = 1;
+    effect->max_inputs = 1;
     if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
             effect->input_count, sizeof(*effect->inputs)))
         goto fail;
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 64d9765e866..0a74b6cabdc 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -9812,10 +9812,9 @@ static void test_effect(BOOL d3d11)
             winetest_push_context("Input %u", j);
             hr = ID2D1Effect_SetInputCount(effect, j);
             if (j < test->min_inputs || j > test->max_inputs)
-                todo_wine
                 ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
             else
-                todo_wine
+                todo_wine_if(test->max_inputs > 1 && j > 1)
                 ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
             winetest_pop_context();
         }
-- 
2.25.1




More information about the wine-devel mailing list