From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/d2d1/effect.c | 25 +++++++++++++++++++++++-- dlls/d2d1/tests/d2d1.c | 32 +++++++++++++++++++++++--------- 2 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/dlls/d2d1/effect.c b/dlls/d2d1/effect.c index a47da0f2e09..4776cdcdb6d 100644 --- a/dlls/d2d1/effect.c +++ b/dlls/d2d1/effect.c @@ -1259,11 +1259,32 @@ L"<?xml version='1.0'?> \ <Input name='Source'/> \ </Inputs> \ <Property name='Rect' type='vector4' /> \ + <Property name='BorderMode' type='enum' /> \ </Effect>";
+struct crop_properties +{ + D2D1_VECTOR_4F rect; + D2D1_BORDER_MODE border_mode; +}; + +EFFECT_PROPERTY_RW(crop, rect, VECTOR4) +EFFECT_PROPERTY_RW(crop, border_mode, ENUM) + +static const D2D1_PROPERTY_BINDING crop_bindings[] = +{ + { L"Rect", BINDING_RW(crop, rect) }, + { L"BorderMode", BINDING_RW(crop, border_mode) }, +}; + static HRESULT __stdcall crop_factory(IUnknown **effect) { - return d2d_effect_create_impl(effect, NULL, 0); + static const struct crop_properties properties = + { + .rect = { -INFINITY, -INFINITY, INFINITY, INFINITY }, + .border_mode = D2D1_BORDER_MODE_SOFT, + }; + return d2d_effect_create_impl(effect, &properties, sizeof(properties)); }
static const WCHAR shadow_description[] = @@ -1540,7 +1561,7 @@ void d2d_effects_init_builtins(struct d2d_factory *factory) { &CLSID_D2D12DAffineTransform, X2(_2d_affine_transform) }, { &CLSID_D2D13DPerspectiveTransform, X2(_3d_perspective_transform) }, { &CLSID_D2D1Composite, X2(composite) }, - { &CLSID_D2D1Crop, X(crop) }, + { &CLSID_D2D1Crop, X2(crop) }, { &CLSID_D2D1Shadow, X2(shadow) }, { &CLSID_D2D1Grayscale, X(grayscale) }, { &CLSID_D2D1ColorMatrix, X(color_matrix) }, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 7eb7ca94519..660f4a39838 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -13228,6 +13228,11 @@ static void test_effect_2d_affine(BOOL d3d11)
static void test_effect_crop(BOOL d3d11) { + static const struct effect_property properties[] = + { + { L"Rect", D2D1_CROP_PROP_RECT, D2D1_PROPERTY_TYPE_VECTOR4 }, + { L"BorderMode", D2D1_CROP_PROP_BORDER_MODE, D2D1_PROPERTY_TYPE_ENUM }, + }; D2D1_BITMAP_PROPERTIES1 bitmap_desc; struct d2d1_test_context ctx; ID2D1DeviceContext *context; @@ -13238,8 +13243,11 @@ static void test_effect_crop(BOOL d3d11) ID2D1Bitmap1 *bitmap; DWORD image[16 * 16]; ID2D1Effect *effect; + D2D1_VECTOR_4F vec4; ID2D1Image *output; + WCHAR name[64]; HRESULT hr; + UINT32 v;
const struct crop_effect_test { @@ -13277,7 +13285,21 @@ static void test_effect_crop(BOOL d3d11) check_system_properties(effect);
count = ID2D1Effect_GetPropertyCount(effect); - todo_wine ok(count == 2, "Got unexpected property count %u.\n", count); + ok(count == 2, "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)); + } + + vec4 = effect_get_vec4_prop(effect, D2D1_CROP_PROP_RECT); + ok(vec4.x == -INFINITY && vec4.y == -INFINITY && vec4.z == INFINITY && vec4.w == INFINITY, + "Unexpected value {%.8e,%.8e,%.8e,%.8e}.\n", vec4.x, vec4.y, vec4.z, vec4.w); + + v = effect_get_enum_prop(effect, D2D1_CROP_PROP_BORDER_MODE); + ok(v == D2D1_BORDER_MODE_SOFT, "Unexpected value %#x.\n", v);
for (i = 0; i < ARRAY_SIZE(crop_effect_tests); ++i) { @@ -13298,14 +13320,7 @@ static void test_effect_crop(BOOL d3d11) ID2D1Effect_SetInput(effect, 0, (ID2D1Image *)bitmap, FALSE); hr = ID2D1Effect_SetValue(effect, D2D1_CROP_PROP_RECT, D2D1_PROPERTY_TYPE_VECTOR4, (const BYTE *)&test->crop_rect, sizeof(test->crop_rect)); - todo_wine ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); - if (hr == D2DERR_INVALID_PROPERTY) - { - ID2D1Bitmap1_Release(bitmap); - winetest_pop_context(); - continue; - } ID2D1Effect_GetOutput(effect, &output);
set_rect(&output_bounds, -1.0f, -1.0f, -1.0f, -1.0f); @@ -15982,7 +15997,6 @@ static void test_get_effect_properties(BOOL d3d11) ID2D1Properties_Release(properties2);
count = ID2D1Properties_GetPropertyCount(properties); - todo_wine ok(count == 2, "Unexpected property count %u.\n", count);
hr = ID2D1Properties_GetPropertyName(properties, 0, buffW, ARRAY_SIZE(buffW));