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);