[PATCH 5/5] d2d1: Implement GetImageLocalBounds() for D2D1Grayscale.

Ziqing Hui zhui at codeweavers.com
Wed Apr 20 03:04:29 CDT 2022


Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
---
 dlls/d2d1/device.c     | 32 ++++++++++++++++++++++++++++++--
 dlls/d2d1/tests/d2d1.c |  4 ++--
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c
index 13c99458cfa..99fab24125b 100644
--- a/dlls/d2d1/device.c
+++ b/dlls/d2d1/device.c
@@ -1979,9 +1979,12 @@ static void STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1Device
         ID2D1Image *image, D2D1_RECT_F *local_bounds)
 {
     struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
+    ID2D1Bitmap *bitmap = NULL;
+    ID2D1Effect *effect = NULL;
     D2D_SIZE_U pixel_size;
-    ID2D1Bitmap *bitmap;
+    const CLSID *clsid;
     D2D_SIZE_F size;
+    unsigned int i;
 
     TRACE("iface %p, image %p, local_bounds %p.\n", iface, image, local_bounds);
 
@@ -2007,12 +2010,37 @@ static void STDMETHODCALLTYPE d2d_device_context_GetImageLocalBounds(ID2D1Device
                 WARN("Unknown unit mode %#x.\n", context->drawing_state.unitMode);
                 break;
         }
-        ID2D1Bitmap_Release(bitmap);
+    }
+    else if (SUCCEEDED(ID2D1Image_QueryInterface(image, &IID_ID2D1Effect, (void **)&effect)))
+    {
+        struct d2d_effect *effect_impl = unsafe_impl_from_ID2D1Effect(effect);
+
+        for (i = 0; i < effect_impl->input_count; ++i)
+        {
+            if (!effect_impl->inputs[i])
+                goto done;
+        }
+
+        clsid = effect_impl->info->clsid;
+        if (IsEqualGUID(clsid, &CLSID_D2D1Grayscale))
+        {
+            ID2D1DeviceContext_GetImageLocalBounds(iface, (ID2D1Image *)effect_impl->inputs[0], local_bounds);
+        }
+        else
+        {
+            FIXME("Unable to get local bounds of effect %s.\n", debugstr_guid(clsid));
+        }
     }
     else
     {
         FIXME("Unable to get local bounds of image %p.\n", image);
     }
+
+done:
+    if (effect)
+        ID2D1Effect_Release(effect);
+    if (bitmap)
+        ID2D1Bitmap_Release(bitmap);
 }
 
 static HRESULT STDMETHODCALLTYPE d2d_device_context_GetImageWorldBounds(ID2D1DeviceContext *iface,
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index 441ffc4ac34..9944d409017 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -10482,7 +10482,7 @@ static void test_effect_grayscale(BOOL d3d11)
         ID2D1Effect_GetOutput(effect, &output);
 
         ID2D1DeviceContext_GetImageLocalBounds(context, output, &bounds);
-        todo_wine ok(compare_rect(&bounds, 0.0f, 0.0f, input_size.width, input_size.height, 0),
+        ok(compare_rect(&bounds, 0.0f, 0.0f, input_size.width, input_size.height, 0),
                 "Got unexpected output bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n",
                 bounds.left, bounds.top, bounds.right, bounds.bottom,
                 0.0f, 0.0f, (float)input_size.width, (float)input_size.height);
@@ -10894,7 +10894,7 @@ static void test_image_bounds(BOOL d3d11)
         {&CLSID_D2D1Composite,              1, TRUE},
         {&CLSID_D2D1Crop,                   1, TRUE},
         {&CLSID_D2D1Shadow,                 1, TRUE},
-        {&CLSID_D2D1Grayscale,              3, TRUE},
+        {&CLSID_D2D1Grayscale,              3},
     };
 
     if (!init_test_context(&ctx, d3d11))
-- 
2.25.1




More information about the wine-devel mailing list