From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/effect.c | 51 +++++++++++++++++++++++++- dlls/d2d1/tests/d2d1.c | 83 ++++++++++++++++++++++++++++++++++++++++++ include/d2d1_1.idl | 4 ++ 3 files changed, 136 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index d6159055cbc..f0577a0b681 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -1159,11 +1159,58 @@ L"<?xml version='1.0'?> <Inputs> \ <Input name='Source'/> \ </Inputs> \ + <Property name='InterpolationMode' type='enum' /> \ + <Property name='BorderMode' type='enum' /> \ + <Property name='Depth' type='float' /> \ + <Property name='PerspectiveOrigin' type='vector2' /> \ + <Property name='LocalOffset' type='vector3' /> \ + <Property name='GlobalOffset' type='vector3' /> \ + <Property name='RotationOrigin' type='vector3' /> \ + <Property name='Rotation' type='vector3' /> \ </Effect>";
+struct _3d_perspective_transform_properties +{ + D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE interpolation_mode; + D2D1_BORDER_MODE border_mode; + float depth; + D2D1_VECTOR_2F perspective_origin; + D2D1_VECTOR_3F local_offset; + D2D1_VECTOR_3F global_offset; + D2D1_VECTOR_3F rotation_origin; + D2D1_VECTOR_3F rotation; +}; + +EFFECT_PROPERTY_RW(_3d_perspective_transform, interpolation_mode, ENUM) +EFFECT_PROPERTY_RW(_3d_perspective_transform, border_mode, ENUM) +EFFECT_PROPERTY_RW(_3d_perspective_transform, depth, FLOAT) +EFFECT_PROPERTY_RW(_3d_perspective_transform, perspective_origin, VECTOR2) +EFFECT_PROPERTY_RW(_3d_perspective_transform, local_offset, VECTOR3) +EFFECT_PROPERTY_RW(_3d_perspective_transform, global_offset, VECTOR3) +EFFECT_PROPERTY_RW(_3d_perspective_transform, rotation_origin, VECTOR3) +EFFECT_PROPERTY_RW(_3d_perspective_transform, rotation, VECTOR3) + +static const D2D1_PROPERTY_BINDING _3d_perspective_transform_bindings[] = +{ + { L"InterpolationMode", BINDING_RW(_3d_perspective_transform, interpolation_mode) }, + { L"BorderMode", BINDING_RW(_3d_perspective_transform, border_mode) }, + { L"Depth", BINDING_RW(_3d_perspective_transform, depth) }, + { L"PerspectiveOrigin", BINDING_RW(_3d_perspective_transform, perspective_origin) }, + { L"LocalOffset", BINDING_RW(_3d_perspective_transform, local_offset) }, + { L"GlobalOffset", BINDING_RW(_3d_perspective_transform, global_offset) }, + { L"RotationOrigin", BINDING_RW(_3d_perspective_transform, rotation_origin) }, + { L"Rotation", BINDING_RW(_3d_perspective_transform, rotation) }, +}; + static HRESULT __stdcall _3d_perspective_transform_factory(IUnknown **effect) { - return d2d_effect_create_impl(effect, NULL, 0); + static const struct _3d_perspective_transform_properties properties = + { + .interpolation_mode = D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE_LINEAR, + .border_mode = D2D1_BORDER_MODE_SOFT, + .depth = 1000.0f, + }; + return d2d_effect_create_impl(effect, &properties, sizeof(properties)); }
static const WCHAR composite_description[] = @@ -1474,7 +1521,7 @@ void d2d_effects_init_builtins(struct d2d_factory *factory) #define X(name) name##_description, name##_factory #define X2(name) name##_description, name##_factory, name##_bindings, ARRAY_SIZE(name##_bindings) { &CLSID_D2D12DAffineTransform, X2(_2d_affine_transform) }, - { &CLSID_D2D13DPerspectiveTransform, X(_3d_perspective_transform) }, + { &CLSID_D2D13DPerspectiveTransform, X2(_3d_perspective_transform) }, { &CLSID_D2D1Composite, X(composite) }, { &CLSID_D2D1Crop, X(crop) }, { &CLSID_D2D1Shadow, X2(shadow) }, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index d5aa8783060..61a83b1c40c 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -13638,6 +13638,88 @@ static void test_effect_shadow(BOOL d3d11) release_test_context(&ctx); }
+static void test_effect_3d_perspective_transform(BOOL d3d11) +{ + static const struct effect_property properties[] = + { + { L"InterpolationMode", D2D1_3DPERSPECTIVETRANSFORM_PROP_INTERPOLATION_MODE, D2D1_PROPERTY_TYPE_ENUM }, + { L"BorderMode", D2D1_3DPERSPECTIVETRANSFORM_PROP_BORDER_MODE, D2D1_PROPERTY_TYPE_ENUM }, + { L"Depth", D2D1_3DPERSPECTIVETRANSFORM_PROP_DEPTH, D2D1_PROPERTY_TYPE_FLOAT }, + { L"PerspectiveOrigin", D2D1_3DPERSPECTIVETRANSFORM_PROP_PERSPECTIVE_ORIGIN, D2D1_PROPERTY_TYPE_VECTOR2 }, + { L"LocalOffset", D2D1_3DPERSPECTIVETRANSFORM_PROP_LOCAL_OFFSET, D2D1_PROPERTY_TYPE_VECTOR3 }, + { L"GlobalOffset", D2D1_3DPERSPECTIVETRANSFORM_PROP_GLOBAL_OFFSET, D2D1_PROPERTY_TYPE_VECTOR3 }, + { L"RotationOrigin", D2D1_3DPERSPECTIVETRANSFORM_PROP_ROTATION_ORIGIN, D2D1_PROPERTY_TYPE_VECTOR3 }, + { L"Rotation", D2D1_3DPERSPECTIVETRANSFORM_PROP_ROTATION, D2D1_PROPERTY_TYPE_VECTOR3 }, + }; + struct d2d1_test_context ctx; + ID2D1DeviceContext *context; + unsigned int count, i; + ID2D1Effect *effect; + D2D1_VECTOR_3F vec3; + D2D1_VECTOR_2F vec2; + WCHAR name[64]; + HRESULT hr; + UINT32 v; + float f; + + if (!init_test_context(&ctx, d3d11)) + return; + + context = ctx.context; + + hr = ID2D1DeviceContext_CreateEffect(context, &CLSID_D2D13DPerspectiveTransform, &effect); + if (FAILED(hr)) + { + win_skip("3D Perspective Transform is not available.\n"); + release_test_context(&ctx); + return; + } + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + check_system_properties(effect); + + count = ID2D1Effect_GetPropertyCount(effect); + ok(count == 8, "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)); + } + + v = effect_get_enum_prop(effect, D2D1_3DPERSPECTIVETRANSFORM_PROP_INTERPOLATION_MODE); + ok(v == D2D1_3DPERSPECTIVETRANSFORM_INTERPOLATION_MODE_LINEAR, "Unexpected value %#x.\n", v); + + v = effect_get_enum_prop(effect, D2D1_3DPERSPECTIVETRANSFORM_PROP_BORDER_MODE); + ok(v == D2D1_BORDER_MODE_SOFT, "Unexpected value %#x.\n", v); + + f = effect_get_float_prop(effect, D2D1_3DPERSPECTIVETRANSFORM_PROP_DEPTH); + ok(f == 1000.0f, "Unexpected value %.8e.\n", f); + + vec2 = effect_get_vec2_prop(effect, D2D1_3DPERSPECTIVETRANSFORM_PROP_PERSPECTIVE_ORIGIN); + ok(vec2.x == 0.0f && vec2.y == 0.0f, "Unexpected value {%.8e,%.8e}.\n", vec2.x, vec2.y); + + vec3 = effect_get_vec3_prop(effect, D2D1_3DPERSPECTIVETRANSFORM_PROP_LOCAL_OFFSET); + ok(vec3.x == 0.0f && vec3.y == 0.0f && vec3.z == 0.0f, + "Unexpected value {%.8e,%.8e,%.8e}.\n", vec3.x, vec3.y, vec3.z); + + vec3 = effect_get_vec3_prop(effect, D2D1_3DPERSPECTIVETRANSFORM_PROP_GLOBAL_OFFSET); + ok(vec3.x == 0.0f && vec3.y == 0.0f && vec3.z == 0.0f, + "Unexpected value {%.8e,%.8e,%.8e}.\n", vec3.x, vec3.y, vec3.z); + + vec3 = effect_get_vec3_prop(effect, D2D1_3DPERSPECTIVETRANSFORM_PROP_ROTATION_ORIGIN); + ok(vec3.x == 0.0f && vec3.y == 0.0f && vec3.z == 0.0f, + "Unexpected value {%.8e,%.8e,%.8e}.\n", vec3.x, vec3.y, vec3.z); + + vec3 = effect_get_vec3_prop(effect, D2D1_3DPERSPECTIVETRANSFORM_PROP_ROTATION); + ok(vec3.x == 0.0f && vec3.y == 0.0f && vec3.z == 0.0f, + "Unexpected value {%.8e,%.8e,%.8e}.\n", vec3.x, vec3.y, vec3.z); + + ID2D1Effect_Release(effect); + release_test_context(&ctx); +} + static void test_effect_flood(BOOL d3d11) { static const struct effect_property properties[] = @@ -17093,6 +17175,7 @@ START_TEST(d2d1) queue_d3d10_test(test_effect_point_specular); queue_d3d10_test(test_effect_arithmetic_composite); queue_d3d10_test(test_effect_shadow); + queue_d3d10_test(test_effect_3d_perspective_transform); 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 ea46fa956eb..b81cead66ba 100644 --- a/include/d2d1_1.idl +++ b/include/d2d1_1.idl @@ -29,6 +29,10 @@ interface ID2D1ColorContext; interface ID2D1Effect; interface ID2D1BitmapBrush1;
+typedef D2D_VECTOR_2F D2D1_VECTOR_2F; +typedef D2D_VECTOR_3F D2D1_VECTOR_3F; +typedef D2D_VECTOR_4F D2D1_VECTOR_4F; + cpp_quote("#ifndef __dwrite_h__") /* already defined in dwrite.h but needed for WIDL */ typedef struct DWRITE_GLYPH_RUN_DESCRIPTION DWRITE_GLYPH_RUN_DESCRIPTION;
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/effect.c | 21 +++++++++++++++++++-- dlls/d2d1/tests/d2d1.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index f0577a0b681..c2b89ca94e6 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -1224,11 +1224,28 @@ L"<?xml version='1.0'?> \ <Input name='Source1'/> \ <Input name='Source2'/> \ </Inputs> \ + <Property name='Mode' type='enum' /> \ </Effect>";
+struct composite_properties +{ + D2D1_COMPOSITE_MODE mode; +}; + +EFFECT_PROPERTY_RW(composite, mode, ENUM) + +static const D2D1_PROPERTY_BINDING composite_bindings[] = +{ + { L"Mode", BINDING_RW(composite, mode) }, +}; + static HRESULT __stdcall composite_factory(IUnknown **effect) { - return d2d_effect_create_impl(effect, NULL, 0); + static const struct composite_properties properties = + { + .mode = D2D1_COMPOSITE_MODE_SOURCE_OVER, + }; + return d2d_effect_create_impl(effect, &properties, sizeof(properties)); }
static const WCHAR crop_description[] = @@ -1522,7 +1539,7 @@ void d2d_effects_init_builtins(struct d2d_factory *factory) #define X2(name) name##_description, name##_factory, name##_bindings, ARRAY_SIZE(name##_bindings) { &CLSID_D2D12DAffineTransform, X2(_2d_affine_transform) }, { &CLSID_D2D13DPerspectiveTransform, X2(_3d_perspective_transform) }, - { &CLSID_D2D1Composite, X(composite) }, + { &CLSID_D2D1Composite, X2(composite) }, { &CLSID_D2D1Crop, X(crop) }, { &CLSID_D2D1Shadow, X2(shadow) }, { &CLSID_D2D1Grayscale, X(grayscale) }, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 61a83b1c40c..7eb7ca94519 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -13798,6 +13798,47 @@ static void test_effect_flood(BOOL d3d11) release_test_context(&ctx); }
+static void test_effect_composite(BOOL d3d11) +{ + static const struct effect_property properties[] = + { + { L"Mode", D2D1_COMPOSITE_PROP_MODE, D2D1_PROPERTY_TYPE_ENUM }, + }; + 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_D2D1Composite, &effect); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + check_system_properties(effect); + + count = ID2D1Effect_GetPropertyCount(effect); + ok(count == 1, "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)); + } + + v = effect_get_enum_prop(effect, D2D1_COMPOSITE_PROP_MODE); + ok(v == D2D1_COMPOSITE_MODE_SOURCE_OVER, "Unexpected value %#x.\n", v); + + ID2D1Effect_Release(effect); + release_test_context(&ctx); +} + static void test_registered_effects(BOOL d3d11) { UINT32 ret, count, count2, count3; @@ -17176,6 +17217,7 @@ START_TEST(d2d1) queue_d3d10_test(test_effect_arithmetic_composite); queue_d3d10_test(test_effect_shadow); queue_d3d10_test(test_effect_3d_perspective_transform); + queue_d3d10_test(test_effect_composite); queue_test(test_effect_flood); queue_test(test_transform_graph); queue_test(test_offset_transform);