Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/tests/d2d1.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index e412459ebf2..9937d9d4a82 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9584,6 +9584,38 @@ static void test_dpi(BOOL d3d11) release_test_context(&ctx); }
+static void test_unit_mode(BOOL d3d11) +{ + struct d2d1_test_context ctx; + ID2D1DeviceContext *context; + D2D1_UNIT_MODE unit_mode; + HRESULT hr; + + if (!init_test_context(&ctx, d3d11)) + return; + + hr = ID2D1RenderTarget_QueryInterface(ctx.rt, &IID_ID2D1DeviceContext, (void **)&context); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + unit_mode = ID2D1DeviceContext_GetUnitMode(context); + ok(unit_mode == D2D1_UNIT_MODE_DIPS, "Got unexpected unit mode %#x.\n", unit_mode); + + ID2D1DeviceContext_SetUnitMode(context, 0xdeadbeef); + unit_mode = ID2D1DeviceContext_GetUnitMode(context); + ok(unit_mode == D2D1_UNIT_MODE_DIPS, "Got unexpected unit mode %#x.\n", unit_mode); + + ID2D1DeviceContext_SetUnitMode(context, D2D1_UNIT_MODE_PIXELS); + unit_mode = ID2D1DeviceContext_GetUnitMode(context); + todo_wine ok(unit_mode == D2D1_UNIT_MODE_PIXELS, "Got unexpected unit mode %#x.\n", unit_mode); + + ID2D1DeviceContext_SetUnitMode(context, 0xdeadbeef); + unit_mode = ID2D1DeviceContext_GetUnitMode(context); + todo_wine ok(unit_mode == D2D1_UNIT_MODE_PIXELS, "Got unexpected unit mode %#x.\n", unit_mode); + + ID2D1DeviceContext_Release(context); + release_test_context(&ctx); +} + static void test_wic_bitmap_format(BOOL d3d11) { IWICImagingFactory *wic_factory; @@ -10919,6 +10951,7 @@ START_TEST(d2d1) queue_test(test_command_list); queue_d3d10_test(test_max_bitmap_size); queue_test(test_dpi); + queue_test(test_unit_mode); queue_test(test_wic_bitmap_format); queue_d3d10_test(test_math); queue_d3d10_test(test_colour_space);
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/d2d1/device.c | 15 ++++++++++++--- dlls/d2d1/tests/d2d1.c | 5 ++--- 2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 43c65ebddc1..5a0698a371a 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -2149,14 +2149,23 @@ static D2D1_PRIMITIVE_BLEND STDMETHODCALLTYPE d2d_device_context_GetPrimitiveBle
static void STDMETHODCALLTYPE d2d_device_context_SetUnitMode(ID2D1DeviceContext *iface, D2D1_UNIT_MODE unit_mode) { - FIXME("iface %p, unit_mode %#x stub!\n", iface, unit_mode); + struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface); + + TRACE("iface %p, unit_mode %#x.\n", iface, unit_mode); + + if (unit_mode == D2D1_UNIT_MODE_DIPS || unit_mode == D2D1_UNIT_MODE_PIXELS) + { + context->drawing_state.unitMode = unit_mode; + } }
static D2D1_UNIT_MODE STDMETHODCALLTYPE d2d_device_context_GetUnitMode(ID2D1DeviceContext *iface) { - FIXME("iface %p stub!\n", iface); + struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
- return D2D1_UNIT_MODE_DIPS; + TRACE("iface %p.\n", iface); + + return context->drawing_state.unitMode; }
static void STDMETHODCALLTYPE d2d_device_context_ID2D1DeviceContext_DrawGlyphRun(ID2D1DeviceContext *iface, diff --git a/dlls/d2d1/tests/d2d1.c b/dlls/d2d1/tests/d2d1.c index 9937d9d4a82..ca80a8e946b 100644 --- a/dlls/d2d1/tests/d2d1.c +++ b/dlls/d2d1/tests/d2d1.c @@ -9606,11 +9606,11 @@ static void test_unit_mode(BOOL d3d11)
ID2D1DeviceContext_SetUnitMode(context, D2D1_UNIT_MODE_PIXELS); unit_mode = ID2D1DeviceContext_GetUnitMode(context); - todo_wine ok(unit_mode == D2D1_UNIT_MODE_PIXELS, "Got unexpected unit mode %#x.\n", unit_mode); + ok(unit_mode == D2D1_UNIT_MODE_PIXELS, "Got unexpected unit mode %#x.\n", unit_mode);
ID2D1DeviceContext_SetUnitMode(context, 0xdeadbeef); unit_mode = ID2D1DeviceContext_GetUnitMode(context); - todo_wine ok(unit_mode == D2D1_UNIT_MODE_PIXELS, "Got unexpected unit mode %#x.\n", unit_mode); + ok(unit_mode == D2D1_UNIT_MODE_PIXELS, "Got unexpected unit mode %#x.\n", unit_mode);
ID2D1DeviceContext_Release(context); release_test_context(&ctx); @@ -10874,7 +10874,6 @@ static void test_image_bounds(BOOL d3d11) ok(unit_mode == D2D1_UNIT_MODE_DIPS, "Got unexpected unit mode %#x.\n", unit_mode); ID2D1DeviceContext_SetUnitMode(context, D2D1_UNIT_MODE_PIXELS); ID2D1DeviceContext_GetImageLocalBounds(context, (ID2D1Image *)bitmap, &bounds); - todo_wine_if(!compare_float(test->dpi_x, 96.0f, 0) || !compare_float(test->dpi_y, 96.0f, 0)) ok(compare_rect(&bounds, 0.0f, 0.0f, test->pixel_size.width, test->pixel_size.height, 0), "Got unexpected bounds {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e}.\n", bounds.left, bounds.top, bounds.right, bounds.bottom, 0.0f, 0.0f,
On Wed, 13 Apr 2022 at 04:59, Ziqing Hui zhui@codeweavers.com wrote:
static void STDMETHODCALLTYPE d2d_device_context_SetUnitMode(ID2D1DeviceContext *iface, D2D1_UNIT_MODE unit_mode) {
- FIXME("iface %p, unit_mode %#x stub!\n", iface, unit_mode);
- struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
- TRACE("iface %p, unit_mode %#x.\n", iface, unit_mode);
- if (unit_mode == D2D1_UNIT_MODE_DIPS || unit_mode == D2D1_UNIT_MODE_PIXELS)
- {
context->drawing_state.unitMode = unit_mode;
- }
}
I think we'd want to print at least a WARN if the application attempts to set an unrecognised unit mode, instead of silently ignoring it.
static D2D1_UNIT_MODE STDMETHODCALLTYPE d2d_device_context_GetUnitMode(ID2D1DeviceContext *iface) {
- FIXME("iface %p stub!\n", iface);
- struct d2d_device_context *context = impl_from_ID2D1DeviceContext(iface);
- return D2D1_UNIT_MODE_DIPS;
- TRACE("iface %p.\n", iface);
- return context->drawing_state.unitMode;
}
I think there's no real reason d2d_device_context_GetUnitMode() and d2d_device_context_SetUnitMode() need to be in the patch, so it's probably best to just send those separately.