From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/effect.c | 30 ++++++++++++++++++-- dlls/d2d1/tests/d2d1.c | 62 +++++++++++++++++++++++++++++++++++++++++ include/d2d1_1.idl | 5 +++- include/d2d1effects.idl | 15 ++++++++++ 4 files changed, 109 insertions(+), 3 deletions(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index 4776cdcdb6d..003fdb02e5d 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -1358,11 +1358,37 @@ L"<?xml version='1.0'?> \ <Inputs > \ <Input name='Source'/> \ </Inputs> \ + <Property name='ColorMatrix' type='matrix5x4' /> \ + <Property name='AlphaMode' type='enum' /> \ + <Property name='ClampOutput' type='bool' /> \ </Effect>";
+struct color_matrix_properties +{ + D2D1_MATRIX_5X4_F color_matrix; + D2D1_COLORMATRIX_ALPHA_MODE alpha_mode; + BOOL clamp_output; +}; + +EFFECT_PROPERTY_RW(color_matrix, color_matrix, MATRIX_5X4) +EFFECT_PROPERTY_RW(color_matrix, alpha_mode, ENUM) +EFFECT_PROPERTY_RW(color_matrix, clamp_output, BOOL) + +static const D2D1_PROPERTY_BINDING color_matrix_bindings[] = +{ + { L"ColorMatrix", BINDING_RW(color_matrix, color_matrix) }, + { L"AlphaMode", BINDING_RW(color_matrix, alpha_mode) }, + { L"ClampOutput", BINDING_RW(color_matrix, clamp_output) }, +}; + static HRESULT __stdcall color_matrix_factory(IUnknown **effect) { - return d2d_effect_create_impl(effect, NULL, 0); + static const struct color_matrix_properties properties = + { + .color_matrix = { ._11 = 1.0f, ._22 = 1.0f, ._33 = 1.0f, ._44 = 1.0f }, + .alpha_mode = D2D1_COLORMATRIX_ALPHA_MODE_PREMULTIPLIED, + }; + return d2d_effect_create_impl(effect, &properties, sizeof(properties)); }
static const WCHAR flood_description[] = @@ -1564,7 +1590,7 @@ void d2d_effects_init_builtins(struct d2d_factory *factory) { &CLSID_D2D1Crop, X2(crop) }, { &CLSID_D2D1Shadow, X2(shadow) }, { &CLSID_D2D1Grayscale, X(grayscale) }, - { &CLSID_D2D1ColorMatrix, X(color_matrix) }, + { &CLSID_D2D1ColorMatrix, X2(color_matrix) }, { &CLSID_D2D1Flood, X2(flood) }, { &CLSID_D2D1GaussianBlur, X2(gaussian_blur) }, { &CLSID_D2D1PointSpecular, X2(point_specular) }, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 660f4a39838..f01f51661d9 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -132,6 +132,15 @@ static UINT32 _effect_get_bool_prop(ID2D1Effect *effect, UINT32 prop, int line) return v; }
+#define effect_get_mat5x4_prop(a,b,c) _effect_get_mat5x4_prop(a,b,c,__LINE__) +static void _effect_get_mat5x4_prop(ID2D1Effect *effect, UINT32 prop, D2D1_MATRIX_5X4_F *m, int line) +{ + HRESULT hr; + + hr = ID2D1Effect_GetValue(effect, prop, D2D1_PROPERTY_TYPE_MATRIX_5X4, (BYTE *)m, sizeof(*m)); + ok_(__FILE__, line)(hr == S_OK, "Unexpected hr %#lx.\n", hr); +} + static const WCHAR *effect_xml_a = L"<?xml version='1.0'?> \ <Effect> \ @@ -13854,6 +13863,58 @@ static void test_effect_composite(BOOL d3d11) release_test_context(&ctx); }
+static void test_effect_color_matrix(BOOL d3d11) +{ + static const struct effect_property properties[] = + { + { L"ColorMatrix", D2D1_COLORMATRIX_PROP_COLOR_MATRIX, D2D1_PROPERTY_TYPE_MATRIX_5X4 }, + { L"AlphaMode", D2D1_COLORMATRIX_PROP_ALPHA_MODE, D2D1_PROPERTY_TYPE_ENUM }, + { L"ClampOutput", D2D1_COLORMATRIX_PROP_CLAMP_OUTPUT, D2D1_PROPERTY_TYPE_BOOL }, + }; + D2D1_MATRIX_5X4_F m, identity; + struct d2d1_test_context ctx; + ID2D1DeviceContext *context; + unsigned int count, i; + ID2D1Effect *effect; + WCHAR name[64]; + HRESULT hr; + UINT32 v; + + if (!init_test_context(&ctx, d3d11)) + return; + + context = ctx.context; + + hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D1ColorMatrix, &effect); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + check_system_properties(effect); + + count = ID2D1Effect_GetPropertyCount(effect); + ok(count == 3, "Got unexpected property count %u.\n", count); + + for (i = 0; i < ARRAY_SIZE(properties); ++i) + { + hr = ID2D1Effect_GetPropertyName(effect, properties[i].index, name, 64); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + ok(!wcscmp(name, properties[i].name), "Unexpected name %s.\n", wine_dbgstr_w(name)); + } + + memset(&identity, 0, sizeof(identity)); + identity._11 = identity._22 = identity._33 = identity._44 = 1.0f; + effect_get_mat5x4_prop(effect, D2D1_COLORMATRIX_PROP_COLOR_MATRIX, &m); + ok(!memcmp(&m, &identity, sizeof(m)), "Unexpected value.\n"); + + v = effect_get_enum_prop(effect, D2D1_COLORMATRIX_PROP_ALPHA_MODE); + ok(v == D2D1_COLORMATRIX_ALPHA_MODE_PREMULTIPLIED, "Unexpected value %#x.\n", v); + + v = effect_get_bool_prop(effect, D2D1_COLORMATRIX_PROP_CLAMP_OUTPUT); + ok(!v, "Unexpected value %#x.\n", v); + + ID2D1Effect_Release(effect); + release_test_context(&ctx); +} + static void test_registered_effects(BOOL d3d11) { UINT32 ret, count, count2, count3; @@ -17232,6 +17293,7 @@ START_TEST(d2d1) queue_d3d10_test(test_effect_shadow); queue_d3d10_test(test_effect_3d_perspective_transform); queue_d3d10_test(test_effect_composite); + queue_d3d10_test(test_effect_color_matrix); queue_test(test_effect_flood); queue_test(test_transform_graph); queue_test(test_offset_transform); diff --git a/include/d2d1_1.idl b/include/d2d1_1.idl index b81cead66ba..b9eb13e272a 100644 --- a/include/d2d1_1.idl +++ b/include/d2d1_1.idl @@ -33,6 +33,10 @@ typedef D2D_VECTOR_2F D2D1_VECTOR_2F; typedef D2D_VECTOR_3F D2D1_VECTOR_3F; typedef D2D_VECTOR_4F D2D1_VECTOR_4F;
+typedef D2D_MATRIX_4X3_F D2D1_MATRIX_4X3_F; +typedef D2D_MATRIX_4X4_F D2D1_MATRIX_4X4_F; +typedef D2D_MATRIX_5X4_F D2D1_MATRIX_5X4_F; + cpp_quote("#ifndef __dwrite_h__") /* already defined in dwrite.h but needed for WIDL */ typedef struct DWRITE_GLYPH_RUN_DESCRIPTION DWRITE_GLYPH_RUN_DESCRIPTION; @@ -162,7 +166,6 @@ typedef enum D2D1_LAYER_OPTIONS1 } D2D1_LAYER_OPTIONS1;
struct D2D1_PROPERTY_BINDING; -typedef D2D_MATRIX_4X4_F D2D1_MATRIX_4X4_F;
typedef enum D2D1_PROPERTY_TYPE { diff --git a/include/d2d1effects.idl b/include/d2d1effects.idl index efaeba5c92d..5534314468e 100644 --- a/include/d2d1effects.idl +++ b/include/d2d1effects.idl @@ -219,3 +219,18 @@ typedef enum D2D1_FLOOD_PROP D2D1_FLOOD_PROP_COLOR = 0, D2D1_FLOOD_PROP_FORCE_DWORD = 0xffffffff } D2D1_FLOOD_PROP; + +typedef enum D2D1_COLORMATRIX_PROP +{ + D2D1_COLORMATRIX_PROP_COLOR_MATRIX = 0, + D2D1_COLORMATRIX_PROP_ALPHA_MODE = 1, + D2D1_COLORMATRIX_PROP_CLAMP_OUTPUT = 2, + D2D1_COLORMATRIX_PROP_FORCE_DWORD = 0xffffffff +} D2D1_COLORMATRIX_PROP; + +typedef enum D2D1_COLORMATRIX_ALPHA_MODE +{ + D2D1_COLORMATRIX_ALPHA_MODE_PREMULTIPLIED = 1, + D2D1_COLORMATRIX_ALPHA_MODE_STRAIGHT = 2, + D2D1_COLORMATRIX_ALPHA_MODE_FORCE_DWORD = 0xffffffff +} D2D1_COLORMATRIX_ALPHA_MODE;