From c843e71ba57a89c5ba1a4ef8856aa4291cc9476c Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 13 Aug 2012 07:51:38 +0400 Subject: [PATCH] dwrite: Implement IDWriteBitmapRenderTarget_GetSize. --- dlls/dwrite/gdiinterop.c | 10 ++++++++-- dlls/dwrite/tests/font.c | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c index c3bcc889965..bac6e40e0fb 100644 --- a/dlls/dwrite/gdiinterop.c +++ b/dlls/dwrite/gdiinterop.c @@ -36,6 +36,7 @@ struct rendertarget { IDWriteBitmapRenderTarget IDWriteBitmapRenderTarget_iface; LONG ref; + SIZE size; HDC hdc; }; @@ -135,8 +136,10 @@ static HRESULT WINAPI rendertarget_SetCurrentTransform(IDWriteBitmapRenderTarget static HRESULT WINAPI rendertarget_GetSize(IDWriteBitmapRenderTarget *iface, SIZE *size) { struct rendertarget *This = impl_from_IDWriteBitmapRenderTarget(iface); - FIXME("(%p)->(%p): stub\n", This, size); - return E_NOTIMPL; + + TRACE("(%p)->(%p)\n", This, size); + *size = This->size; + return S_OK; } static HRESULT WINAPI rendertarget_Resize(IDWriteBitmapRenderTarget *iface, UINT32 width, UINT32 height) @@ -175,6 +178,9 @@ static HRESULT create_rendertarget(HDC hdc, UINT32 width, UINT32 height, IDWrite This->IDWriteBitmapRenderTarget_iface.lpVtbl = &rendertargetvtbl; This->ref = 1; + This->size.cx = width; + This->size.cy = height; + This->hdc = CreateCompatibleDC(hdc); memset(bmi, 0, sizeof(bmibuf)); diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c index 97cd4775cc2..ccaba88026a 100644 --- a/dlls/dwrite/tests/font.c +++ b/dlls/dwrite/tests/font.c @@ -158,6 +158,7 @@ static void test_CreateBitmapRenderTarget(void) DIBSECTION ds; HBITMAP hbm; HRESULT hr; + SIZE size; HDC hdc; int ret; @@ -168,6 +169,15 @@ static void test_CreateBitmapRenderTarget(void) hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 0, 0, &target); EXPECT_HR(hr, S_OK); +if (0) /* crashes on native */ + hr = IDWriteBitmapRenderTarget_GetSize(target, NULL); + + size.cx = size.cy = -1; + hr = IDWriteBitmapRenderTarget_GetSize(target, &size); + EXPECT_HR(hr, S_OK); + ok(size.cx == 0, "got %d\n", size.cx); + ok(size.cy == 0, "got %d\n", size.cy); + target2 = NULL; hr = IDWriteGdiInterop_CreateBitmapRenderTarget(interop, NULL, 0, 0, &target2); EXPECT_HR(hr, S_OK); @@ -213,6 +223,12 @@ static void test_CreateBitmapRenderTarget(void) ok(ds.dsBm.bmBitsPixel == 32, "got %d\n", ds.dsBm.bmBitsPixel); ok(ds.dsBm.bmBits != NULL, "got %p\n", ds.dsBm.bmBits); + size.cx = size.cy = -1; + hr = IDWriteBitmapRenderTarget_GetSize(target, &size); + EXPECT_HR(hr, S_OK); + ok(size.cx == 10, "got %d\n", size.cx); + ok(size.cy == 5, "got %d\n", size.cy); + IDWriteBitmapRenderTarget_Release(target); IDWriteGdiInterop_Release(interop);