d2d1: Improve bitmap creation DPI handling.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2019-10-24 17:40:48 +03:30 committed by Alexandre Julliard
parent 9a808acbd5
commit 9023c5a676
2 changed files with 21 additions and 14 deletions

View File

@ -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)

View File

@ -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
{