[PATCH v4 3/5] d2d1: Implement d2d_effect_SetInputCount().
Ziqing Hui
zhui at codeweavers.com
Sat Aug 7 23:40:34 CDT 2021
Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
---
v4: Return ealier in d2d_effect_SetInputCount().
Call d2d_effect_SetInputCount in d2d_effect_init().
dlls/d2d1/d2d1_private.h | 2 ++
dlls/d2d1/effect.c | 49 ++++++++++++++++++++++++++++++++--------
dlls/d2d1/tests/d2d1.c | 2 --
3 files changed, 41 insertions(+), 12 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index 88c712cf51c..1391c24b053 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, const CLSID *effect_id) DECLSPEC_HIDDEN;
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c
index c884c3b8d4f..030797565e6 100644
--- a/dlls/d2d1/effect.c
+++ b/dlls/d2d1/effect.c
@@ -24,13 +24,15 @@ struct d2d_effect_info
{
const CLSID *clsid;
UINT32 default_input_count;
+ UINT32 min_inputs;
+ UINT32 max_inputs;
};
static const struct d2d_effect_info builtin_effects[] =
{
- {&CLSID_D2D12DAffineTransform, 1},
- {&CLSID_D2D13DPerspectiveTransform, 1},
- {&CLSID_D2D1Composite, 2}
+ {&CLSID_D2D12DAffineTransform, 1, 1, 1},
+ {&CLSID_D2D13DPerspectiveTransform, 1, 1, 1},
+ {&CLSID_D2D1Composite, 2, 1, 0xffffffff}
};
static inline struct d2d_effect *impl_from_ID2D1Effect(ID2D1Effect *iface)
@@ -190,9 +192,38 @@ 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]);
+ }
+ effect->input_count = count;
+ return S_OK;
+ }
+
+ if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
+ count, sizeof(*effect->inputs)))
+ {
+ ERR("Failed to resize inputs array.\n");
+ return E_OUTOFMEMORY;
+ }
+
+ memset(&effect->inputs[effect->input_count], 0, sizeof(*effect->inputs) * (count - effect->input_count));
+ effect->input_count = count;
+
+ return S_OK;
}
static void STDMETHODCALLTYPE d2d_effect_GetInput(ID2D1Effect *iface, UINT32 index, ID2D1Image **input)
@@ -302,12 +333,10 @@ HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory, const
{
if (IsEqualGUID(effect_id, builtin_effects[i].clsid))
{
- effect->input_count = builtin_effects[i].default_input_count;
+ effect->min_inputs = builtin_effects[i].min_inputs;
+ effect->max_inputs = builtin_effects[i].max_inputs;
- if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
- effect->input_count, sizeof(*effect->inputs)))
- return E_OUTOFMEMORY;
- memset(effect->inputs, 0, sizeof(*effect->inputs) * effect->input_count);
+ d2d_effect_SetInputCount(&effect->ID2D1Effect_iface, builtin_effects[i].default_input_count);
ID2D1Factory_AddRef(effect->factory = factory);
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 36882dc4918..d8cc3989261 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -9811,10 +9811,8 @@ 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
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
winetest_pop_context();
}
--
2.25.1
More information about the wine-devel
mailing list