From: Akihiro Sagawa Subject: [PATCH 2/3] d2d1: ID2D1DeviceContext::SetTarget() doesn't update device context DPI values. Message-Id: <20191006235446.5098.375B48EC@gmail.com> Date: Sun, 06 Oct 2019 23:57:31 +0900 Signed-off-by: Akihiro Sagawa --- dlls/d2d1/device.c | 8 +++----- dlls/d2d1/tests/d2d1.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 98f06a2..f51824e 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -1940,9 +1940,7 @@ static void d2d_device_context_reset_target(struct d2d_device_context *context) ID2D1Bitmap1_Release(&context->target->ID2D1Bitmap1_iface); context->target = NULL; - context->desc.dpiX = 96.0f; - context->desc.dpiY = 96.0f; - + /* N.B. DPI settings are kept. */ memset(&context->desc.pixelFormat, 0, sizeof(context->desc.pixelFormat)); memset(&context->pixel_size, 0, sizeof(context->pixel_size)); @@ -1983,8 +1981,6 @@ static void STDMETHODCALLTYPE d2d_device_context_SetTarget(ID2D1DeviceContext *i d2d_device_context_reset_target(context); /* Set sizes and pixel format. */ - context->desc.dpiX = bitmap_impl->dpi_x; - context->desc.dpiY = bitmap_impl->dpi_y; context->pixel_size = bitmap_impl->pixel_size; context->desc.pixelFormat = bitmap_impl->format; context->target = bitmap_impl; @@ -3771,6 +3767,8 @@ HRESULT d2d_d3d_create_render_target(ID2D1Device *device, IDXGISurface *surface, return hr; } + ID2D1DeviceContext_SetDpi(&object->ID2D1DeviceContext_iface, bitmap_desc.dpiX, bitmap_desc.dpiY); + if (surface) { bitmap_desc.pixelFormat = desc->pixelFormat; diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index c8fc7da..4a20a7b 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -8138,9 +8138,9 @@ static void test_device_context_target(void) /* Device context DPI values aren't updated by SetTarget. */ ID2D1DeviceContext_GetDpi(device_context, &dpi_x, &dpi_y); - todo_wine ok(dpi_x == dc_dpi_x, "Wrong dpi_x %.8e, expected %.8e, test %u\n", + ok(dpi_x == dc_dpi_x, "Wrong dpi_x %.8e, expected %.8e, test %u\n", dpi_x, dc_dpi_x, i); - todo_wine ok(dpi_y == dc_dpi_y, "Wrong dpi_y %.8e, expected %.8e, test %u\n", + ok(dpi_y == dc_dpi_y, "Wrong dpi_y %.8e, expected %.8e, test %u\n", dpi_y, dc_dpi_y, i); ID2D1Bitmap1_Release(bitmap); } @@ -8209,9 +8209,9 @@ static void test_device_context_target(void) /* Device context DPI values aren't updated by SetTarget. */ ID2D1DeviceContext_GetDpi(device_context, &dpi_x, &dpi_y); - todo_wine ok(dpi_x == dc_dpi_x, "Wrong dpi_x %.8e, expected %.8e, test %u\n", + ok(dpi_x == dc_dpi_x, "Wrong dpi_x %.8e, expected %.8e, test %u\n", dpi_x, dc_dpi_x, i); - todo_wine ok(dpi_y == dc_dpi_y, "Wrong dpi_y %.8e, expected %.8e, test %u\n", + ok(dpi_y == dc_dpi_y, "Wrong dpi_y %.8e, expected %.8e, test %u\n", dpi_y, dc_dpi_y, i); ID2D1Bitmap1_Release(bitmap); @@ -8268,9 +8268,9 @@ static void test_device_context_target(void) /* Device context DPI values aren't updated by SetTarget. */ ID2D1DeviceContext_GetDpi(device_context, &dpi_x, &dpi_y); - todo_wine ok(dpi_x == dc_dpi_x, "Wrong dpi_x %.8e, expected %.8e, test %u\n", + ok(dpi_x == dc_dpi_x, "Wrong dpi_x %.8e, expected %.8e, test %u\n", dpi_x, dc_dpi_x, i); - todo_wine ok(dpi_y == dc_dpi_y, "Wrong dpi_y %.8e, expected %.8e, test %u\n", + ok(dpi_y == dc_dpi_y, "Wrong dpi_y %.8e, expected %.8e, test %u\n", dpi_y, dc_dpi_y, i); ID2D1Bitmap1_Release(bitmap); @@ -8278,8 +8278,8 @@ static void test_device_context_target(void) ID2D1DeviceContext_SetTarget(device_context, NULL); ID2D1DeviceContext_GetDpi(device_context, &dpi_x, &dpi_y); - todo_wine ok(dpi_x == dc_dpi_x, "Wrong dpi_x %.8e, expected %.8e\n", dpi_x, dc_dpi_x); - todo_wine ok(dpi_y == dc_dpi_y, "Wrong dpi_y %.8e, expected %.8e\n", dpi_y, dc_dpi_y); + ok(dpi_x == dc_dpi_x, "Wrong dpi_x %.8e, expected %.8e\n", dpi_x, dc_dpi_x); + ok(dpi_y == dc_dpi_y, "Wrong dpi_y %.8e, expected %.8e\n", dpi_y, dc_dpi_y); ID2D1DeviceContext_Release(device_context);