dwrite: Store pixels per dip value for a render target.

This commit is contained in:
Nikolay Sivov 2014-10-29 22:53:42 +03:00 committed by Alexandre Julliard
parent 7126921615
commit afea35f56a
2 changed files with 29 additions and 4 deletions

View File

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

View File

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