Module: wine Branch: master Commit: e2908463b96ab57088f202a35bd6274a047d8091 URL: https://source.winehq.org/git/wine.git/?a=commit;h=e2908463b96ab57088f202a35...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Mon Jun 27 00:25:02 2022 +0300
d2d1/effect: Use property binding methods.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
---
dlls/d2d1/effect.c | 39 ++++++++++++++++++++++++++++++++------- dlls/d2d1/tests/d2d1.c | 12 +----------- 2 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 3e587eb7547..672cac2a0cd 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -278,11 +278,16 @@ static UINT32 d2d_effect_properties_get_value_size(const struct d2d_effect *effe const struct d2d_effect_properties *properties, UINT32 index) { struct d2d_effect_property *prop; + UINT32 size;
if (!(prop = d2d_effect_properties_get_property_by_index(properties, index))) return 0;
- /* FIXME: use gettter */ + if (prop->get_function) + { + if (FAILED(prop->get_function((IUnknown *)effect->impl, NULL, 0, &size))) return 0; + return size; + }
return prop->size; } @@ -300,10 +305,13 @@ static HRESULT d2d_effect_property_get_value(const struct d2d_effect *effect, const struct d2d_effect_properties *properties, const struct d2d_effect_property *prop, D2D1_PROPERTY_TYPE type, BYTE *value, UINT32 size) { + UINT32 actual_size; + if (type != D2D1_PROPERTY_TYPE_UNKNOWN && prop->type != type) return E_INVALIDARG; if (prop->type != D2D1_PROPERTY_TYPE_STRING && prop->size != size) return E_INVALIDARG;
- /* FIXME: use getter */ + if (prop->get_function) + return prop->get_function((IUnknown *)effect->impl, value, size, &actual_size);
switch (prop->type) { @@ -321,12 +329,29 @@ static HRESULT d2d_effect_property_get_value(const struct d2d_effect *effect, return S_OK; }
-static HRESULT d2d_effect_property_set_value(struct d2d_effect_property *property, +static HRESULT d2d_effect_property_set_value(const struct d2d_effect *effect, + struct d2d_effect_properties *properties, struct d2d_effect_property *prop, D2D1_PROPERTY_TYPE type, const BYTE *value, UINT32 size) { - if (property->readonly) return E_INVALIDARG; + if (prop->readonly) return E_INVALIDARG; + if (type != D2D1_PROPERTY_TYPE_UNKNOWN && prop->type != type) return E_INVALIDARG; + if (prop->get_function && !prop->set_function) return E_INVALIDARG; + if (prop->index < 0x80000000 && !prop->set_function) return E_INVALIDARG; + + if (prop->set_function) + return prop->set_function((IUnknown *)effect->impl, value, size); + + if (prop->size != size) return E_INVALIDARG;
- FIXME("Unimplemented.\n"); + switch (prop->type) + { + case D2D1_PROPERTY_TYPE_BOOL: + case D2D1_PROPERTY_TYPE_UINT32: + memcpy(properties->data.ptr + prop->data.offset, value, size); + break; + default: + FIXME("Unhandled type %u.\n", prop->type); + }
return S_OK; } @@ -877,7 +902,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_SetValueByName(ID2D1Effect *iface, c if (!(prop = d2d_effect_properties_get_property_by_name(&effect->properties, name))) return D2DERR_INVALID_PROPERTY;
- return d2d_effect_property_set_value(prop, type, value, value_size); + return d2d_effect_property_set_value(effect, &effect->properties, prop, type, value, value_size); }
static HRESULT STDMETHODCALLTYPE d2d_effect_SetValue(ID2D1Effect *iface, UINT32 index, D2D1_PROPERTY_TYPE type, @@ -891,7 +916,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_SetValue(ID2D1Effect *iface, UINT32 if (!(prop = d2d_effect_properties_get_property_by_index(&effect->properties, index))) return D2DERR_INVALID_PROPERTY;
- return d2d_effect_property_set_value(prop, type, value, value_size); + return d2d_effect_property_set_value(effect, &effect->properties, prop, type, value, value_size); }
static HRESULT STDMETHODCALLTYPE d2d_effect_GetValueByName(ID2D1Effect *iface, const WCHAR *name, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 9e64b1354c4..9156afa71c5 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -10818,7 +10818,6 @@ static void test_effect_register(BOOL d3d11) hr = ID2D1Effect_GetValueByName(effect, L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine ok(integer == 10, "Got unexpected integer %u.\n", integer); ok(effect_context == NULL, "Got unexpected effect context %p.\n", effect_context); ID2D1Effect_Release(effect); @@ -10837,7 +10836,6 @@ static void test_effect_register(BOOL d3d11) hr = ID2D1Effect_GetValueByName(effect, L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine ok(integer == 10, "Got unexpected integer %u.\n", integer); ok(effect_context == NULL, "Got unexpected effect context %p.\n", effect_context); ID2D1Effect_Release(effect); @@ -11107,31 +11105,26 @@ static void test_effect_properties(BOOL d3d11) hr = ID2D1Effect_GetValueByName(effect, L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef, "Got unexpected effect context %p.\n", effect_context);
effect_context = (ID2D1EffectContext *)0xdeadbeef; hr = ID2D1Effect_GetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef, "Got unexpected effect context %p.\n", effect_context);
hr = ID2D1Effect_SetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); - todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
integer = 0xdeadbeef; hr = ID2D1Effect_GetValueByName(effect, L"Integer", D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine ok(integer == 10, "Got unexpected integer %u.", integer);
integer = 0xdeadbeef; hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine ok(integer == 10, "Got unexpected integer %u.", integer);
integer = 20; @@ -11140,8 +11133,7 @@ static void test_effect_properties(BOOL d3d11) integer = 0xdeadbeef; hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - todo_wine - ok(integer == 20, "Got unexpected integer %u.", integer); + ok(integer == 20, "Got unexpected integer %u\n.", integer);
ID2D1Effect_Release(effect); hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect); @@ -11173,10 +11165,8 @@ static void test_effect_properties(BOOL d3d11) ok(integer == 0, "Got unexpected integer %u.", integer);
hr = ID2D1Effect_SetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); - todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr); hr = ID2D1Effect_SetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); - todo_wine ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Got unexpected hr %#lx.\n", hr);
ID2D1Effect_Release(effect);