Commit 9023c5a6 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

d2d1: Improve bitmap creation DPI handling.

parent 9a808acb
...@@ -313,6 +313,7 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, ...@@ -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) UINT32 pitch, const D2D1_BITMAP_PROPERTIES1 *desc, struct d2d_bitmap **bitmap)
{ {
D3D10_SUBRESOURCE_DATA resource_data; D3D10_SUBRESOURCE_DATA resource_data;
D2D1_BITMAP_PROPERTIES1 bitmap_desc;
D3D10_TEXTURE2D_DESC texture_desc; D3D10_TEXTURE2D_DESC texture_desc;
ID3D10Texture2D *texture; ID3D10Texture2D *texture;
HRESULT hr; HRESULT hr;
...@@ -324,6 +325,18 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size, ...@@ -324,6 +325,18 @@ HRESULT d2d_bitmap_create(struct d2d_device_context *context, D2D1_SIZE_U size,
return D2DERR_UNSUPPORTED_PIXEL_FORMAT; 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.Width = size.width;
texture_desc.Height = size.height; texture_desc.Height = size.height;
if (!texture_desc.Width || !texture_desc.Height) if (!texture_desc.Width || !texture_desc.Height)
......
...@@ -8169,9 +8169,8 @@ static void test_dpi(void) ...@@ -8169,9 +8169,8 @@ static void test_dpi(void)
bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW; bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
bitmap_desc.colorContext = NULL; bitmap_desc.colorContext = NULL;
hr = ID2D1DeviceContext_CreateBitmapFromWicBitmap(device_context, wic_bitmap_src, &bitmap_desc, &bitmap); 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",
ok(hr == create_dpi_tests[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, create_dpi_tests[i].hr);
i, hr, create_dpi_tests[i].hr);
IWICBitmapSource_Release(wic_bitmap_src); IWICBitmapSource_Release(wic_bitmap_src);
if (FAILED(hr)) if (FAILED(hr))
...@@ -8183,10 +8182,8 @@ static void test_dpi(void) ...@@ -8183,10 +8182,8 @@ static void test_dpi(void)
if (bitmap_desc.dpiX == 0.0f && bitmap_desc.dpiY == 0.0f) if (bitmap_desc.dpiX == 0.0f && bitmap_desc.dpiY == 0.0f)
{ {
/* Bitmap DPI values are inherited at creation time. */ /* 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", ok(dpi_x == init_dpi_x, "Test %u: Got unexpected dpi_x %.8e, expected %.8e.\n", i, dpi_x, init_dpi_x);
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);
todo_wine ok(dpi_y == init_dpi_y, "Test %u: Got unexpected dpi_y %.8e, expected %.8e.\n",
i, dpi_y, init_dpi_y);
} }
else else
{ {
...@@ -8225,9 +8222,8 @@ static void test_dpi(void) ...@@ -8225,9 +8222,8 @@ static void test_dpi(void)
bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW; bitmap_desc.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
bitmap_desc.colorContext = NULL; bitmap_desc.colorContext = NULL;
hr = ID2D1DeviceContext_CreateBitmap(device_context, size, NULL, 0, &bitmap_desc, &bitmap); 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",
ok(hr == create_dpi_tests[i].hr, "Test %u: Got unexpected hr %#x, expected %#x.\n", i, hr, create_dpi_tests[i].hr);
i, hr, create_dpi_tests[i].hr);
if (FAILED(hr)) if (FAILED(hr))
continue; continue;
...@@ -8238,10 +8234,8 @@ static void test_dpi(void) ...@@ -8238,10 +8234,8 @@ static void test_dpi(void)
if (bitmap_desc.dpiX == 0.0f && bitmap_desc.dpiY == 0.0f) if (bitmap_desc.dpiX == 0.0f && bitmap_desc.dpiY == 0.0f)
{ {
/* Bitmap DPI values are inherited at creation time. */ /* 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", ok(dpi_x == init_dpi_x, "Test %u: Got unexpected dpi_x %.8e, expected %.8e.\n", i, dpi_x, init_dpi_x);
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);
todo_wine ok(dpi_y == init_dpi_y, "Test %u: Got unexpected dpi_y %.8e, expected %.8e.\n",
i, dpi_y, init_dpi_y);
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment