From afea35f56abe3a3830e3d622816d6431718ad1e2 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 29 Oct 2014 22:53:42 +0300 Subject: [PATCH] dwrite: Store pixels per dip value for a render target. --- dlls/dwrite/gdiinterop.c | 16 ++++++++++++---- dlls/dwrite/tests/font.c | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c index 0e2f9026c58..b099e5262f3 100644 --- a/dlls/dwrite/gdiinterop.c +++ b/dlls/dwrite/gdiinterop.c @@ -40,6 +40,7 @@ struct rendertarget { IDWriteBitmapRenderTarget IDWriteBitmapRenderTarget_iface; LONG ref; + FLOAT pixels_per_dip; DWRITE_MATRIX m; SIZE size; HDC hdc; @@ -140,15 +141,21 @@ static HDC WINAPI rendertarget_GetMemoryDC(IDWriteBitmapRenderTarget *iface) static FLOAT WINAPI rendertarget_GetPixelsPerDip(IDWriteBitmapRenderTarget *iface) { struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget(iface); - FIXME("(%p): stub\n", This); - return 1.0; + TRACE("(%p)\n", This); + return This->pixels_per_dip; } static HRESULT WINAPI rendertarget_SetPixelsPerDip(IDWriteBitmapRenderTarget *iface, FLOAT pixels_per_dip) { struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget(iface); - FIXME("(%p)->(%f): stub\n", This, pixels_per_dip); - return E_NOTIMPL; + + TRACE("(%p)->(%.2f)\n", This, pixels_per_dip); + + if (pixels_per_dip <= 0.0) + return E_INVALIDARG; + + This->pixels_per_dip = pixels_per_dip; + return S_OK; } static HRESULT WINAPI rendertarget_GetCurrentTransform(IDWriteBitmapRenderTarget *iface, DWRITE_MATRIX *transform) @@ -229,6 +236,7 @@ static HRESULT create_rendertarget(HDC hdc, UINT32 width, UINT32 height, IDWrite target->m.m11 = target->m.m22 = 1.0; target->m.m12 = target->m.m21 = 0.0; target->m.dx = target->m.dy = 0.0; + target->pixels_per_dip = 1.0; *ret = &target->IDWriteBitmapRenderTarget_iface; diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 29f3a390aee..e76dd6aad2f 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -379,6 +379,7 @@ static void test_CreateBitmapRenderTarget(void) DWRITE_MATRIX m; DIBSECTION ds; HRESULT hr; + FLOAT pdip; SIZE size; HDC hdc; int ret; @@ -511,6 +512,22 @@ if (0) /* crashes on native */ ok(m.m11 == 1.0 && m.m22 == 1.0 && m.m12 == 0.0 && m.m21 == 0.0, "got %.1f,%.1f,%.1f,%.1f\n", m.m11, m.m22, m.m12, m.m21); ok(m.dx == 0.0 && m.dy == 0.0, "got %.1f,%.1f\n", m.dx, m.dy); + /* pixels per dip */ + pdip = IDWriteBitmapRenderTarget_GetPixelsPerDip(target); + ok(pdip == 1.0, "got %.2f\n", pdip); + + hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, 2.0); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, -1.0); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + + hr = IDWriteBitmapRenderTarget_SetPixelsPerDip(target, 0.0); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + + pdip = IDWriteBitmapRenderTarget_GetPixelsPerDip(target); + ok(pdip == 2.0, "got %.2f\n", pdip); + IDWriteBitmapRenderTarget_Release(target); IDWriteGdiInterop_Release(interop); IDWriteFactory_Release(factory);