[PATCH 3/3] d2d1: Improve bitmap creation DPI handling.

Henri Verbeet hverbeet at codeweavers.com
Thu Oct 24 09:10:48 CDT 2019


From: Akihiro Sagawa <sagawa.aki at gmail.com>

Signed-off-by: Akihiro Sagawa <sagawa.aki at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
This supersedes patch 171797.

 dlls/d2d1/bitmap.c     | 13 +++++++++++++
 dlls/d2d1/tests/d2d1.c | 22 ++++++++--------------
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/dlls/d2d1/bitmap.c b/dlls/d2d1/bitmap.c
index dc5ed9e6ad7..bc958e50a11 100644
--- a/dlls/d2d1/bitmap.c
+++ b/dlls/d2d1/bitmap.c
@@ -313,6 +313,7 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size,
         UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
 {
     D3D10_SUBRESOURCE_DATA resource_data;
+    D2D1_BITMAP_PROPERTIES1 bitmap_desc;
     D3D10_TEXTURE2D_DESC texture_desc;
     ID3D10Texture2D *texture;
     HRESULT hr;
@@ -324,6 +325,18 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size,
         return D2DERR_UNSUPPORTED_PIXEL_FORMAT;
     }
 
+    if (desc->dpiX == 0.0f && desc->dpiY == 0.0f)
+    {
+        bitmap_desc = *desc;
+        bitmap_desc.dpiX = context->desc.dpiX;
+        bitmap_desc.dpiY = context->desc.dpiY;
+        desc = &bitmap_desc;
+    }
+    else if (desc->dpiX <= 0.0f || desc->dpiY <= 0.0f)
+    {
+        return E_INVALIDARG;
+    }
+
     texture_desc.Width = size.width;
     texture_desc.Height = size.height;
     if (!texture_desc.Width || !texture_desc.Height)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c
index a71477be3b4..0ed51c7f805 100644
--- a/dlls/d2d1/tests/d2d1.c
+++ b/dlls/d2d1/tests/d2d1.c
@@ -8169,9 +8169,8 @@ static void test_dpi(void)
         bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
         bitmap_desc.colorContext = NULL;
         hr = ID2D1DeviceContext_CreateBitmapFromWicBitmap(device_context, wic_bitmap_src, &bitmap_desc, &bitmap);
-        todo_wine_if(FAILED(create_dpi_tests[i].hr))
-            ok(hr == create_dpi_tests[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n",
-                    i, hr, create_dpi_tests[i].hr);
+        ok(hr == create_dpi_tests[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n",
+                i, hr, create_dpi_tests[i].hr);
         IWICBitmapSource_Release(wic_bitmap_src);
 
         if (FAILED(hr))
@@ -8183,10 +8182,8 @@ static void test_dpi(void)
         if (bitmap_desc.dpiX == 0.0f && bitmap_desc.dpiY == 0.0f)
         {
             /* Bitmap DPI values are inherited at creation time. */
-            todo_wine ok(dpi_x == init_dpi_x, "Test %u: Got unexpected dpi_x %.8e, expected %.8e.\n",
-                    i, dpi_x, init_dpi_x);
-            todo_wine ok(dpi_y == init_dpi_y, "Test %u: Got unexpected dpi_y %.8e, expected %.8e.\n",
-                    i, dpi_y, init_dpi_y);
+            ok(dpi_x == init_dpi_x, "Test %u: Got unexpected dpi_x %.8e, expected %.8e.\n", i, dpi_x, init_dpi_x);
+            ok(dpi_y == init_dpi_y, "Test %u: Got unexpected dpi_y %.8e, expected %.8e.\n", i, dpi_y, init_dpi_y);
         }
         else
         {
@@ -8225,9 +8222,8 @@ static void test_dpi(void)
         bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
         bitmap_desc.colorContext = NULL;
         hr = ID2D1DeviceContext_CreateBitmap(device_context, size, NULL, 0, &bitmap_desc, &bitmap);
-        todo_wine_if(FAILED(create_dpi_tests[i].hr))
-            ok(hr == create_dpi_tests[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n",
-                    i, hr, create_dpi_tests[i].hr);
+        ok(hr == create_dpi_tests[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n",
+                i, hr, create_dpi_tests[i].hr);
 
         if (FAILED(hr))
             continue;
@@ -8238,10 +8234,8 @@ static void test_dpi(void)
         if (bitmap_desc.dpiX == 0.0f && bitmap_desc.dpiY == 0.0f)
         {
             /* Bitmap DPI values are inherited at creation time. */
-            todo_wine ok(dpi_x == init_dpi_x, "Test %u: Got unexpected dpi_x %.8e, expected %.8e.\n",
-                    i, dpi_x, init_dpi_x);
-            todo_wine ok(dpi_y == init_dpi_y, "Test %u: Got unexpected dpi_y %.8e, expected %.8e.\n",
-                    i, dpi_y, init_dpi_y);
+            ok(dpi_x == init_dpi_x, "Test %u: Got unexpected dpi_x %.8e, expected %.8e.\n", i, dpi_x, init_dpi_x);
+            ok(dpi_y == init_dpi_y, "Test %u: Got unexpected dpi_y %.8e, expected %.8e.\n", i, dpi_y, init_dpi_y);
         }
         else
         {
-- 
2.11.0




More information about the wine-devel mailing list