Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/d2d1_private.h | 4 +++ dlls/d2d1/effect.c | 61 ++++++++++++++++++++++++++++++++++++---- dlls/d2d1/tests/d2d1.c | 10 ++----- 3 files changed, 61 insertions(+), 14 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index ce99e7c3432..a80e1b6a18d 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -572,6 +572,10 @@ struct d2d_effect LONG refcount;
ID2D1Factory *factory; + UINT32 min_inputs; + UINT32 max_inputs; + ID2D1Image **inputs; + UINT32 inputs_count; };
void d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory) DECLSPEC_HIDDEN; diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 40dd2187953..50b1c5917f4 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -67,12 +67,19 @@ static ULONG STDMETHODCALLTYPE d2d_effect_Release(ID2D1Effect *iface) { struct d2d_effect *effect = impl_from_ID2D1Effect(iface); ULONG refcount = InterlockedDecrement(&effect->refcount); + unsigned int i;
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (!refcount) { ID2D1Factory_Release(effect->factory); + for (i = 0; i < effect->inputs_count; ++i) + { + if (effect->inputs[i]) + ID2D1Image_Release(effect->inputs[i]); + } + heap_free(effect->inputs); heap_free(effect); }
@@ -166,26 +173,64 @@ 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 %d.\n", iface, index, input, invalidate); + + if (index < effect->inputs_count) + { + if (effect->inputs[index]) + ID2D1Image_Release(effect->inputs[index]); + ID2D1Image_AddRef(effect->inputs[index] = input); + } }
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->inputs_count) + { + if (count < effect->inputs_count) + { + for (i = count; i < effect->inputs_count; ++i) + { + if (effect->inputs[i]) + ID2D1Image_Release(effect->inputs[i]); + } + } + effect->inputs_count = count; + HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, effect->inputs, sizeof(*effect->inputs) * count); + } + + return S_OK; }
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->inputs_count && effect->inputs[index]) + ID2D1Image_AddRef(*input = effect->inputs[index]); + else + *input = NULL; }
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->inputs_count; }
static void STDMETHODCALLTYPE d2d_effect_GetOutput(ID2D1Effect *iface, ID2D1Image **output) @@ -274,5 +319,9 @@ void 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->min_inputs = 1; + effect->max_inputs = 1; + effect->inputs_count = 1; + effect->inputs = heap_alloc_zero(sizeof(*effect->inputs)); ID2D1Factory_AddRef(effect->factory = factory); } diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 7971d1396bc..f265b88796b 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9800,8 +9800,6 @@ static void test_effect(BOOL d3d11) max_inputs, test->max_inputs); }
- todo_wine - { input_count = ID2D1Effect_GetInputCount(effect); ok (input_count == 1 || input_count == 2, "Got unexpected input count %u.\n", input_count);
@@ -9812,6 +9810,7 @@ static void test_effect(BOOL d3d11) if (j < test->min_inputs || j > test->max_inputs) ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); else + todo_wine_if(test->max_inputs > 1 && j > 1) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); }
@@ -9821,7 +9820,6 @@ static void test_effect(BOOL d3d11) ID2D1Effect_GetInput(effect, j, &image_a); ok(image_a == NULL, "Got unexpected image_a %p.\n", image_a); } - }
set_size_u(&size, 1, 1); bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; @@ -9831,8 +9829,6 @@ static void test_effect(BOOL d3d11) hr = ID2D1RenderTarget_CreateBitmap(ctx.rt, size, NULL, 4, &bitmap_desc, &bitmap); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- todo_wine - { ID2D1Effect_SetInput(effect, 0, (ID2D1Image *)bitmap, FALSE); for (j = 0; j < input_count + off_limit_tests; ++j) { @@ -9843,8 +9839,7 @@ static void test_effect(BOOL d3d11) if (j == 0) { 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 { @@ -9852,7 +9847,6 @@ static void test_effect(BOOL d3d11) } } ID2D1Bitmap_Release(bitmap); - }
ID2D1Effect_Release(effect); winetest_pop_context();