From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/d2d1_private.h | 2 ++ dlls/d2d1/effect.c | 51 +++++++++++++++++++++++----------------- dlls/d2d1/tests/d2d1.c | 3 --- 3 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h index dced9847390..9c314e08694 100644 --- a/dlls/d2d1/d2d1_private.h +++ b/dlls/d2d1/d2d1_private.h @@ -712,6 +712,8 @@ struct d2d_transform_graph { ID2D1TransformGraph ID2D1TransformGraph_iface; LONG refcount; + + UINT32 input_count; };
struct d2d_effect diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 50c4b01de12..3a3bc896fe9 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -66,9 +66,11 @@ static ULONG STDMETHODCALLTYPE d2d_transform_graph_Release(ID2D1TransformGraph *
static UINT32 STDMETHODCALLTYPE d2d_transform_graph_GetInputCount(ID2D1TransformGraph *iface) { - FIXME("iface %p stub!\n", iface); + struct d2d_transform_graph *graph = impl_from_ID2D1TransformGraph(iface); + + TRACE("iface %p.\n", iface);
- return 0; + return graph->input_count; }
static HRESULT STDMETHODCALLTYPE d2d_transform_graph_SetSingleTransformNode(ID2D1TransformGraph *iface, @@ -144,10 +146,20 @@ static const ID2D1TransformGraphVtbl d2d_transform_graph_vtbl = d2d_transform_graph_SetPassthroughGraph, };
-static void d2d_transform_graph_init(struct d2d_transform_graph *graph) +static HRESULT d2d_transform_graph_create(UINT32 input_count, struct d2d_transform_graph **graph) { - graph->ID2D1TransformGraph_iface.lpVtbl = &d2d_transform_graph_vtbl; - graph->refcount = 1; + struct d2d_transform_graph *object; + + if (!(object = calloc(1, sizeof(*object)))) + return E_OUTOFMEMORY; + + object->ID2D1TransformGraph_iface.lpVtbl = &d2d_transform_graph_vtbl; + object->refcount = 1; + object->input_count = input_count; + + *graph = object; + + return S_OK; }
static HRESULT STDMETHODCALLTYPE d2d_effect_impl_QueryInterface(ID2D1EffectImpl *iface, REFIID iid, void **out) @@ -1273,12 +1285,11 @@ static HRESULT d2d_effect_set_input_count(struct d2d_effect *effect, UINT32 coun ID2D1TransformGraph_Release(&effect->graph->ID2D1TransformGraph_iface); effect->graph = NULL;
- if (!(effect->graph = calloc(1, sizeof(*effect->graph)))) - return E_OUTOFMEMORY; - d2d_transform_graph_init(effect->graph); - - if (FAILED(hr = ID2D1EffectImpl_SetGraph(effect->impl, &effect->graph->ID2D1TransformGraph_iface))) - WARN("Failed to set a new transform graph, hr %#lx.\n", hr); + if (SUCCEEDED(hr = d2d_transform_graph_create(count, &effect->graph))) + { + if (FAILED(hr = ID2D1EffectImpl_SetGraph(effect->impl, &effect->graph->ID2D1TransformGraph_iface))) + WARN("Failed to set a new transform graph, hr %#lx.\n", hr); + } }
return hr; @@ -1626,7 +1637,6 @@ HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effec { struct d2d_effect_context *effect_context; const struct d2d_effect_registration *reg; - struct d2d_transform_graph *graph; struct d2d_effect *object; UINT32 input_count; WCHAR clsidW[39]; @@ -1642,16 +1652,8 @@ HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effec return E_OUTOFMEMORY; d2d_effect_context_init(effect_context, context);
- if (!(graph = calloc(1, sizeof(*graph)))) - { - ID2D1EffectContext_Release(&effect_context->ID2D1EffectContext_iface); - return E_OUTOFMEMORY; - } - d2d_transform_graph_init(graph); - if (!(object = calloc(1, sizeof(*object)))) { - ID2D1TransformGraph_Release(&graph->ID2D1TransformGraph_iface); ID2D1EffectContext_Release(&effect_context->ID2D1EffectContext_iface); return E_OUTOFMEMORY; } @@ -1660,7 +1662,6 @@ HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effec object->ID2D1Image_iface.lpVtbl = &d2d_effect_image_vtbl; object->refcount = 1; object->effect_context = effect_context; - object->graph = graph;
/* Create properties */ d2d_effect_duplicate_properties(&object->properties, ®->properties); @@ -1675,6 +1676,12 @@ HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effec d2d_effect_get_value(object, D2D1_PROPERTY_INPUTS, D2D1_PROPERTY_TYPE_ARRAY, (BYTE *)&input_count, sizeof(input_count)); d2d_effect_set_input_count(object, input_count);
+ if (FAILED(hr = d2d_transform_graph_create(input_count, &object->graph))) + { + ID2D1EffectContext_Release(&effect_context->ID2D1EffectContext_iface); + return hr; + } + if (FAILED(hr = reg->factory((IUnknown **)&object->impl))) { WARN("Failed to create implementation object, hr %#lx.\n", hr); @@ -1683,7 +1690,7 @@ HRESULT d2d_effect_create(struct d2d_device_context *context, const CLSID *effec }
if (FAILED(hr = ID2D1EffectImpl_Initialize(object->impl, &effect_context->ID2D1EffectContext_iface, - &graph->ID2D1TransformGraph_iface))) + &object->graph->ID2D1TransformGraph_iface))) { WARN("Failed to initialize effect, hr %#lx.\n", hr); ID2D1Effect_Release(&object->ID2D1Effect_iface); diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index b6db1e81178..05ed2d985e5 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -11523,7 +11523,6 @@ static void test_effect_register(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
count = ID2D1TransformGraph_GetInputCount(graph); - todo_wine ok(count == 3, "Unexpected input count %u.\n", count);
integer = 0; @@ -11549,7 +11548,6 @@ static void test_effect_register(BOOL d3d11) hr = ID2D1Effect_GetValueByName(effect, L"Graph", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&graph, sizeof(graph)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); count = ID2D1TransformGraph_GetInputCount(graph); - todo_wine ok(count == 4, "Unexpected input count %u.\n", count);
ID2D1Effect_Release(effect); @@ -12720,7 +12718,6 @@ static void test_transform_graph(BOOL d3d11) ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
count = ID2D1TransformGraph_GetInputCount(graph); - todo_wine ok(count == 1, "Unexpected input count %u.\n", count);
/* Create transforms */