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

d2d1/effect: Use property binding methods.

parent 49c801d0
...@@ -278,11 +278,16 @@ static UINT32 d2d_effect_properties_get_value_size(const struct d2d_effect *effe ...@@ -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) const struct d2d_effect_properties *properties, UINT32 index)
{ {
struct d2d_effect_property *prop; struct d2d_effect_property *prop;
UINT32 size;
if (!(prop = d2d_effect_properties_get_property_by_index(properties, index))) if (!(prop = d2d_effect_properties_get_property_by_index(properties, index)))
return 0; 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; return prop->size;
} }
...@@ -300,10 +305,13 @@ static HRESULT d2d_effect_property_get_value(const struct d2d_effect *effect, ...@@ -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, const struct d2d_effect_properties *properties, const struct d2d_effect_property *prop,
D2D1_PROPERTY_TYPE type, BYTE *value, UINT32 size) D2D1_PROPERTY_TYPE type, BYTE *value, UINT32 size)
{ {
UINT32 actual_size;
if (type != D2D1_PROPERTY_TYPE_UNKNOWN && prop->type != type) return E_INVALIDARG; 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; 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) switch (prop->type)
{ {
...@@ -321,12 +329,29 @@ static HRESULT d2d_effect_property_get_value(const struct d2d_effect *effect, ...@@ -321,12 +329,29 @@ static HRESULT d2d_effect_property_get_value(const struct d2d_effect *effect,
return S_OK; 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) 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; return S_OK;
} }
...@@ -877,7 +902,7 @@ static HRESULT STDMETHODCALLTYPE d2d_effect_SetValueByName(ID2D1Effect *iface, c ...@@ -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))) if (!(prop = d2d_effect_properties_get_property_by_name(&effect->properties, name)))
return D2DERR_INVALID_PROPERTY; 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, 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 ...@@ -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))) if (!(prop = d2d_effect_properties_get_property_by_index(&effect->properties, index)))
return D2DERR_INVALID_PROPERTY; 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, static HRESULT STDMETHODCALLTYPE d2d_effect_GetValueByName(ID2D1Effect *iface, const WCHAR *name,
......
...@@ -10818,7 +10818,6 @@ static void test_effect_register(BOOL d3d11) ...@@ -10818,7 +10818,6 @@ static void test_effect_register(BOOL d3d11)
hr = ID2D1Effect_GetValueByName(effect, L"Context", hr = ID2D1Effect_GetValueByName(effect, L"Context",
D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine
ok(integer == 10, "Got unexpected integer %u.\n", integer); ok(integer == 10, "Got unexpected integer %u.\n", integer);
ok(effect_context == NULL, "Got unexpected effect context %p.\n", effect_context); ok(effect_context == NULL, "Got unexpected effect context %p.\n", effect_context);
ID2D1Effect_Release(effect); ID2D1Effect_Release(effect);
...@@ -10837,7 +10836,6 @@ static void test_effect_register(BOOL d3d11) ...@@ -10837,7 +10836,6 @@ static void test_effect_register(BOOL d3d11)
hr = ID2D1Effect_GetValueByName(effect, L"Context", hr = ID2D1Effect_GetValueByName(effect, L"Context",
D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine
ok(integer == 10, "Got unexpected integer %u.\n", integer); ok(integer == 10, "Got unexpected integer %u.\n", integer);
ok(effect_context == NULL, "Got unexpected effect context %p.\n", effect_context); ok(effect_context == NULL, "Got unexpected effect context %p.\n", effect_context);
ID2D1Effect_Release(effect); ID2D1Effect_Release(effect);
...@@ -11107,31 +11105,26 @@ static void test_effect_properties(BOOL d3d11) ...@@ -11107,31 +11105,26 @@ static void test_effect_properties(BOOL d3d11)
hr = ID2D1Effect_GetValueByName(effect, hr = ID2D1Effect_GetValueByName(effect,
L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); L"Context", D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context));
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine
ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef, ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef,
"Got unexpected effect context %p.\n", effect_context); "Got unexpected effect context %p.\n", effect_context);
effect_context = (ID2D1EffectContext *)0xdeadbeef; effect_context = (ID2D1EffectContext *)0xdeadbeef;
hr = ID2D1Effect_GetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(effect_context)); 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); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine
ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef, ok(effect_context != NULL && effect_context != (ID2D1EffectContext *)0xdeadbeef,
"Got unexpected effect context %p.\n", effect_context); "Got unexpected effect context %p.\n", effect_context);
hr = ID2D1Effect_SetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(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); ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
integer = 0xdeadbeef; integer = 0xdeadbeef;
hr = ID2D1Effect_GetValueByName(effect, L"Integer", D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); hr = ID2D1Effect_GetValueByName(effect, L"Integer", D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine
ok(integer == 10, "Got unexpected integer %u.", integer); ok(integer == 10, "Got unexpected integer %u.", integer);
integer = 0xdeadbeef; integer = 0xdeadbeef;
hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine
ok(integer == 10, "Got unexpected integer %u.", integer); ok(integer == 10, "Got unexpected integer %u.", integer);
integer = 20; integer = 20;
...@@ -11140,8 +11133,7 @@ static void test_effect_properties(BOOL d3d11) ...@@ -11140,8 +11133,7 @@ static void test_effect_properties(BOOL d3d11)
integer = 0xdeadbeef; integer = 0xdeadbeef;
hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); hr = ID2D1Effect_GetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer));
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
todo_wine ok(integer == 20, "Got unexpected integer %u\n.", integer);
ok(integer == 20, "Got unexpected integer %u.", integer);
ID2D1Effect_Release(effect); ID2D1Effect_Release(effect);
hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect); hr = ID2D1Factory1_UnregisterEffect(factory, &CLSID_TestEffect);
...@@ -11173,10 +11165,8 @@ static void test_effect_properties(BOOL d3d11) ...@@ -11173,10 +11165,8 @@ static void test_effect_properties(BOOL d3d11)
ok(integer == 0, "Got unexpected integer %u.", integer); ok(integer == 0, "Got unexpected integer %u.", integer);
hr = ID2D1Effect_SetValue(effect, 0, D2D1_PROPERTY_TYPE_IUNKNOWN, (BYTE *)&effect_context, sizeof(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); ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
hr = ID2D1Effect_SetValue(effect, 1, D2D1_PROPERTY_TYPE_UINT32, (BYTE *)&integer, sizeof(integer)); 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); ok(hr == E_INVALIDARG || broken(hr == S_OK) /* win8 */, "Got unexpected hr %#lx.\n", hr);
ID2D1Effect_Release(effect); ID2D1Effect_Release(effect);
......
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