Signed-off-by: Ziqing Hui zhui@codeweavers.com ---
v4: Call d2d_array_reserve() before factory. memset() "effect->input_count" inputs.
dlls/d2d1/d2d1_private.h | 5 ++++- dlls/d2d1/device.c | 8 +++++++- dlls/d2d1/effect.c | 25 +++++++++++++++++++++---- dlls/d2d1/tests/d2d1.c | 2 +- 4 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index ce99e7c3432..48d15dfcf22 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -572,9 +572,12 @@ struct d2d_effect LONG refcount;
ID2D1Factory *factory; + ID2D1Image **inputs; + size_t inputs_size; + size_t input_count; };
-void d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) DECLSPEC_HIDDEN; +HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) DECLSPEC_HIDDEN;
static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size) { diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 0647bc57fc3..d8704f1b43b 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1887,13 +1887,19 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceCont { struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); struct d2d_effect *object; + HRESULT hr;
FIXME("iface %p, effect_id %s, effect %p stub!\n", iface, debugstr_guid(effect_id), effect);
if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY;
- d2d_effect_init(object, context->factory); + if (FAILED(hr = d2d_effect_init(object, context->factory))) + { + WARN("Failed to initialize effect, hr %#x.\n", hr); + heap_free(object); + return hr; + }
TRACE("Created effect %p.\n", object); *effect = &object->ID2D1Effect_iface; diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 40dd2187953..acf83ab1b02 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -25,6 +25,12 @@ static inline struct d2d_effect *impl_from_ID2D1Effect(ID2D1Effect *iface) return CONTAINING_RECORD(iface, struct d2d_effect, ID2D1Effect_iface); }
+static void d2d_effect_cleanup(struct d2d_effect *effect) +{ + heap_free(effect->inputs); + ID2D1Factory_Release(effect->factory); +} + static HRESULT STDMETHODCALLTYPE d2d_effect_QueryInterface(ID2D1Effect *iface, REFIID iid, void **out) { struct d2d_effect *effect = impl_from_ID2D1Effect(iface); @@ -72,7 +78,7 @@ static ULONG STDMETHODCALLTYPE d2d_effect_Release(ID2D1Effect *iface)
if (!refcount) { - ID2D1Factory_Release(effect->factory); + d2d_effect_cleanup(effect); heap_free(effect); }
@@ -183,9 +189,11 @@ static void STDMETHODCALLTYPE d2d_effect_GetInput(ID2D1Effect *iface, UINT32 ind
static UINT32 STDMETHODCALLTYPE d2d_effect_GetInputCount(ID2D1Effect *iface) { - FIXME("iface %p stub!\n", iface); + struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
- return 0; + TRACE("iface %p.\n", iface); + + return effect->input_count; }
static void STDMETHODCALLTYPE d2d_effect_GetOutput(ID2D1Effect *iface, ID2D1Image **output) @@ -269,10 +277,19 @@ static const ID2D1ImageVtbl d2d_effect_image_vtbl = d2d_effect_image_GetFactory, };
-void d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) +HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) { effect->ID2D1Effect_iface.lpVtbl = &d2d_effect_vtbl; effect->ID2D1Image_iface.lpVtbl = &d2d_effect_image_vtbl; effect->refcount = 1; + + effect->input_count = 1; + 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); + ID2D1Factory_AddRef(effect->factory = factory); + + return S_OK; } diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 146952d7418..64d9765e866 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9802,7 +9802,7 @@ static void test_effect(BOOL d3d11) }
input_count = ID2D1Effect_GetInputCount(effect); - todo_wine + todo_wine_if(test->default_input_count != 1) ok (input_count == test->default_input_count, "Got unexpected input count %u, expected %u.\n", input_count, test->default_input_count);
Signed-off-by: Ziqing Hui zhui@codeweavers.com ---
v4: This is a new patch in this patch set.
dlls/d2d1/d2d1_private.h | 2 +- dlls/d2d1/device.c | 2 +- dlls/d2d1/effect.c | 41 ++++++++++++++++++++++++++++++++-------- dlls/d2d1/tests/d2d1.c | 1 - 4 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index 48d15dfcf22..88c712cf51c 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -577,7 +577,7 @@ struct d2d_effect size_t input_count; };
-HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) DECLSPEC_HIDDEN; +HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory, const CLSID *effect_id) DECLSPEC_HIDDEN;
static inline BOOL d2d_array_reserve(void **elements, size_t *capacity, size_t count, size_t size) { diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index d8704f1b43b..c6ef2e28690 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1894,7 +1894,7 @@ static HRESULT STDMETHODCALLTYPE d2d_device_context_CreateEffect(ID2D1DeviceCont if (!(object = heap_alloc_zero(sizeof(*object)))) return E_OUTOFMEMORY;
- if (FAILED(hr = d2d_effect_init(object, context->factory))) + if (FAILED(hr = d2d_effect_init(object, context->factory, effect_id))) { WARN("Failed to initialize effect, hr %#x.\n", hr); heap_free(object); diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index acf83ab1b02..c884c3b8d4f 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -20,6 +20,19 @@
WINE_DEFAULT_DEBUG_CHANNEL(d2d);
+struct d2d_effect_info +{ + const CLSID *clsid; + UINT32 default_input_count; +}; + +static const struct d2d_effect_info builtin_effects[] = +{ + {&CLSID_D2D12DAffineTransform, 1}, + {&CLSID_D2D13DPerspectiveTransform, 1}, + {&CLSID_D2D1Composite, 2} +}; + static inline struct d2d_effect *impl_from_ID2D1Effect(ID2D1Effect *iface) { return CONTAINING_RECORD(iface, struct d2d_effect, ID2D1Effect_iface); @@ -277,19 +290,31 @@ static const ID2D1ImageVtbl d2d_effect_image_vtbl = d2d_effect_image_GetFactory, };
-HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) +HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory, const CLSID *effect_id) { + unsigned int i; + effect->ID2D1Effect_iface.lpVtbl = &d2d_effect_vtbl; effect->ID2D1Image_iface.lpVtbl = &d2d_effect_image_vtbl; effect->refcount = 1;
- effect->input_count = 1; - 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); + for (i = 0; i < ARRAY_SIZE(builtin_effects); ++i) + { + if (IsEqualGUID(effect_id, builtin_effects[i].clsid)) + { + effect->input_count = builtin_effects[i].default_input_count;
- ID2D1Factory_AddRef(effect->factory = factory); + 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);
- return S_OK; + ID2D1Factory_AddRef(effect->factory = factory); + + return S_OK; + } + } + + WARN("Unsupported effect clsid %s.\n", debugstr_guid(effect_id)); + return E_FAIL; } diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 64d9765e866..36882dc4918 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9802,7 +9802,6 @@ static void test_effect(BOOL d3d11) }
input_count = ID2D1Effect_GetInputCount(effect); - todo_wine_if(test->default_input_count != 1) ok (input_count == test->default_input_count, "Got unexpected input count %u, expected %u.\n", input_count, test->default_input_count);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=95236
Your paranoid android.
=== debiant2 (32 bit Hindi:India report) ===
Report validation errors: d2d1:d2d1 is missing some skip messages
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Ziqing Hui zhui@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(); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=95237
Your paranoid android.
=== debiant2 (32 bit German report) ===
Report validation errors: d2d1:d2d1 is missing some skip messages
On Sun, 8 Aug 2021 at 06:41, Ziqing Hui zhui@codeweavers.com wrote:
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;
};
If we take it one step further, we can just store a struct d2d_effect_info pointer in the d2d_effect structure.
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;
And then e.g. the line about would become "if (count < effect->info->min_inputs || count > effect->info->max_inputs)"
Signed-off-by: Ziqing Hui zhui@codeweavers.com ---
v4: Use %#x for boolean value. Remove a check in d2d_effect_cleanup().
dlls/d2d1/effect.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 030797565e6..798b5051647 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -42,6 +42,13 @@ static inline struct d2d_effect *impl_from_ID2D1Effect(ID2D1Effect *iface)
static void d2d_effect_cleanup(struct d2d_effect *effect) { + unsigned int i; + + for (i = 0; i < effect->input_count; ++i) + { + if (effect->inputs[i]) + ID2D1Image_Release(effect->inputs[i]); + } heap_free(effect->inputs); ID2D1Factory_Release(effect->factory); } @@ -187,7 +194,17 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_GetSubProperties(ID2D1Effect *iface,
static void STDMETHODCALLTYPE d2d_effect_SetInput(ID2D1Effect *iface, UINT32 index, ID2D1Image *input, BOOL invalidate) { - FIXME("iface %p, index %u, input %p, invalidate %d stub!\n", iface, index, input, invalidate); + struct d2d_effect *effect = impl_from_ID2D1Effect(iface); + + TRACE("iface %p, index %u, input %p, invalidate %#x.\n", iface, index, input, invalidate); + + if (index >= effect->input_count) + return; + + ID2D1Image_AddRef(input); + if (effect->inputs[index]) + ID2D1Image_Release(effect->inputs[index]); + effect->inputs[index] = input; }
static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UINT32 count)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/effect.c | 9 ++++++++- dlls/d2d1/tests/d2d1.c | 7 +------ 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 798b5051647..50894fb6152 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -245,7 +245,14 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UI
static void STDMETHODCALLTYPE d2d_effect_GetInput(ID2D1Effect *iface, UINT32 index, ID2D1Image **input) { - FIXME("iface %p, index %u, input %p stub!\n", iface, index, input); + struct d2d_effect *effect = impl_from_ID2D1Effect(iface); + + TRACE("iface %p, index %u, input %p.\n", iface, index, input); + + if (index < effect->input_count && effect->inputs[index]) + ID2D1Image_AddRef(*input = effect->inputs[index]); + else + *input = NULL; }
static UINT32 STDMETHODCALLTYPE d2d_effect_GetInputCount(ID2D1Effect *iface) diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index d8cc3989261..f655274754e 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9822,7 +9822,6 @@ static void test_effect(BOOL d3d11) { winetest_push_context("Input %u", j); ID2D1Effect_GetInput(effect, j, &image_a); - todo_wine ok(image_a == NULL, "Got unexpected image_a %p.\n", image_a); winetest_pop_context(); } @@ -9843,14 +9842,11 @@ static void test_effect(BOOL d3d11) ID2D1Effect_GetInput(effect, j, &image_a); if (j == 0) { - todo_wine ok(image_a == (ID2D1Image *)bitmap, "Got unexpected image_a %p.\n", image_a); - if (image_a == (ID2D1Image *)bitmap) - ID2D1Image_Release(image_a); + ID2D1Image_Release(image_a); } else { - todo_wine ok(image_a == NULL, "Got unexpected image_a %p.\n", image_a); } winetest_pop_context(); @@ -9862,7 +9858,6 @@ static void test_effect(BOOL d3d11) image_a = (ID2D1Image *)0xdeadbeef; ID2D1Effect_SetInput(effect, j, (ID2D1Image *)bitmap, FALSE); ID2D1Effect_GetInput(effect, j, &image_a); - todo_wine ok(image_a == NULL, "Got unexpected image_a %p.\n", image_a); winetest_pop_context(); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=95235
Your paranoid android.
=== debiant2 (32 bit French report) ===
Report validation errors: d2d1:d2d1 is missing some skip messages