Commit d46021ba authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d2d1/effect: Recreate transform graph when input count changes.

parent 16710311
...@@ -189,7 +189,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_impl_PrepareForRender(ID2D1EffectImp ...@@ -189,7 +189,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_impl_PrepareForRender(ID2D1EffectImp
static HRESULT STDMETHODCALLTYPE d2d_effect_impl_SetGraph(ID2D1EffectImpl *iface, ID2D1TransformGraph *graph) static HRESULT STDMETHODCALLTYPE d2d_effect_impl_SetGraph(ID2D1EffectImpl *iface, ID2D1TransformGraph *graph)
{ {
return E_NOTIMPL; return S_OK;
} }
static const ID2D1EffectImplVtbl d2d_effect_impl_vtbl = static const ID2D1EffectImplVtbl d2d_effect_impl_vtbl =
...@@ -1045,7 +1045,8 @@ static void d2d_effect_cleanup(struct d2d_effect *effect) ...@@ -1045,7 +1045,8 @@ static void d2d_effect_cleanup(struct d2d_effect *effect)
} }
free(effect->inputs); free(effect->inputs);
ID2D1EffectContext_Release(&effect->effect_context->ID2D1EffectContext_iface); ID2D1EffectContext_Release(&effect->effect_context->ID2D1EffectContext_iface);
ID2D1TransformGraph_Release(&effect->graph->ID2D1TransformGraph_iface); if (effect->graph)
ID2D1TransformGraph_Release(&effect->graph->ID2D1TransformGraph_iface);
d2d_effect_properties_cleanup(&effect->properties); d2d_effect_properties_cleanup(&effect->properties);
if (effect->impl) if (effect->impl)
ID2D1EffectImpl_Release(effect->impl); ID2D1EffectImpl_Release(effect->impl);
...@@ -1239,6 +1240,8 @@ static void STDMETHODCALLTYPE d2d_effect_SetInput(ID2D1Effect *iface, UINT32 ind ...@@ -1239,6 +1240,8 @@ static void STDMETHODCALLTYPE d2d_effect_SetInput(ID2D1Effect *iface, UINT32 ind
static HRESULT d2d_effect_set_input_count(struct d2d_effect *effect, UINT32 count) static HRESULT d2d_effect_set_input_count(struct d2d_effect *effect, UINT32 count)
{ {
bool initialized = effect->inputs != NULL;
HRESULT hr = S_OK;
unsigned int i; unsigned int i;
if (count == effect->input_count) if (count == effect->input_count)
...@@ -1251,21 +1254,34 @@ static HRESULT d2d_effect_set_input_count(struct d2d_effect *effect, UINT32 coun ...@@ -1251,21 +1254,34 @@ static HRESULT d2d_effect_set_input_count(struct d2d_effect *effect, UINT32 coun
if (effect->inputs[i]) if (effect->inputs[i])
ID2D1Image_Release(effect->inputs[i]); ID2D1Image_Release(effect->inputs[i]);
} }
effect->input_count = count;
return S_OK;
} }
else
if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
count, sizeof(*effect->inputs)))
{ {
ERR("Failed to resize inputs array.\n"); if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
return E_OUTOFMEMORY; 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)); memset(&effect->inputs[effect->input_count], 0, sizeof(*effect->inputs) * (count - effect->input_count));
}
effect->input_count = count; effect->input_count = count;
return S_OK; if (initialized)
{
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);
}
return hr;
} }
static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UINT32 count) static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UINT32 count)
......
...@@ -11166,7 +11166,12 @@ static HRESULT STDMETHODCALLTYPE effect_impl_PrepareForRender(ID2D1EffectImpl *i ...@@ -11166,7 +11166,12 @@ static HRESULT STDMETHODCALLTYPE effect_impl_PrepareForRender(ID2D1EffectImpl *i
static HRESULT STDMETHODCALLTYPE effect_impl_SetGraph(ID2D1EffectImpl *iface, ID2D1TransformGraph *graph) static HRESULT STDMETHODCALLTYPE effect_impl_SetGraph(ID2D1EffectImpl *iface, ID2D1TransformGraph *graph)
{ {
return E_NOTIMPL; struct effect_impl *effect_impl = impl_from_ID2D1EffectImpl(iface);
ID2D1TransformGraph_Release(effect_impl->transform_graph);
ID2D1TransformGraph_AddRef(effect_impl->transform_graph = graph);
return S_OK;
} }
static const ID2D1EffectImplVtbl effect_impl_vtbl = static const ID2D1EffectImplVtbl effect_impl_vtbl =
...@@ -11496,6 +11501,13 @@ static void test_effect_register(BOOL d3d11) ...@@ -11496,6 +11501,13 @@ static void test_effect_register(BOOL d3d11)
(BYTE *)&integer, sizeof(integer)); (BYTE *)&integer, sizeof(integer));
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok(integer == 3, "Unexpected data %u.\n", integer); ok(integer == 3, "Unexpected data %u.\n", integer);
hr = ID2D1Effect_SetInputCount(effect, 4);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Effect_GetValue(effect, D2D1_PROPERTY_INPUTS, D2D1_PROPERTY_TYPE_ARRAY,
(BYTE *)&integer, sizeof(integer));
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok(integer == 3, "Unexpected data %u.\n", integer);
ID2D1Effect_Release(effect); ID2D1Effect_Release(effect);
hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect); hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment