[PATCH 2/2] dwrite: Update cached bitmap size on Resize() as well
Nikolay Sivov
nsivov at codeweavers.com
Wed Jul 22 03:54:53 CDT 2015
---
-------------- next part --------------
>From e93898423868e316d2ff19b33d0b99be78b2ddf7 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Wed, 22 Jul 2015 11:47:26 +0300
Subject: [PATCH 2/2] dwrite: Update cached bitmap size on Resize() as well
---
dlls/dwrite/gdiinterop.c | 16 ++++++++--------
dlls/dwrite/tests/font.c | 24 ++++++++++++++++++++++++
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/dlls/dwrite/gdiinterop.c b/dlls/dwrite/gdiinterop.c
index c3f19ac..aeb61eb 100644
--- a/dlls/dwrite/gdiinterop.c
+++ b/dlls/dwrite/gdiinterop.c
@@ -47,12 +47,15 @@ struct rendertarget {
HDC hdc;
};
-static HRESULT create_target_dibsection(HDC hdc, UINT32 width, UINT32 height)
+static HRESULT create_target_dibsection(struct rendertarget *target, UINT32 width, UINT32 height)
{
char bmibuf[FIELD_OFFSET(BITMAPINFO, bmiColors[256])];
BITMAPINFO *bmi = (BITMAPINFO*)bmibuf;
HBITMAP hbm;
+ target->size.cx = width;
+ target->size.cy = height;
+
memset(bmi, 0, sizeof(bmibuf));
bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
bmi->bmiHeader.biHeight = -height;
@@ -61,11 +64,11 @@ static HRESULT create_target_dibsection(HDC hdc, UINT32 width, UINT32 height)
bmi->bmiHeader.biPlanes = 1;
bmi->bmiHeader.biCompression = BI_RGB;
- hbm = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, NULL, NULL, 0);
+ hbm = CreateDIBSection(target->hdc, bmi, DIB_RGB_COLORS, NULL, NULL, 0);
if (!hbm)
hbm = CreateBitmap(1, 1, 1, 1, NULL);
- DeleteObject(SelectObject(hdc, hbm));
+ DeleteObject(SelectObject(target->hdc, hbm));
return S_OK;
}
@@ -199,7 +202,7 @@ static HRESULT WINAPI rendertarget_Resize(IDWriteBitmapRenderTarget1 *iface, UIN
if (This->size.cx == width && This->size.cy == height)
return S_OK;
- return create_target_dibsection(This->hdc, width, height);
+ return create_target_dibsection(This, width, height);
}
static DWRITE_TEXT_ANTIALIAS_MODE WINAPI rendertarget_GetTextAntialiasMode(IDWriteBitmapRenderTarget1 *iface)
@@ -251,11 +254,8 @@ static HRESULT create_rendertarget(HDC hdc, UINT32 width, UINT32 height, IDWrite
target->IDWriteBitmapRenderTarget1_iface.lpVtbl = &rendertargetvtbl;
target->ref = 1;
- target->size.cx = width;
- target->size.cy = height;
-
target->hdc = CreateCompatibleDC(hdc);
- hr = create_target_dibsection(target->hdc, width, height);
+ hr = create_target_dibsection(target, width, height);
if (FAILED(hr)) {
IDWriteBitmapRenderTarget1_Release(&target->IDWriteBitmapRenderTarget1_iface);
return hr;
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index c85193a..0565e09 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -849,18 +849,36 @@ if (0) /* crashes on native */
hr = IDWriteBitmapRenderTarget_Resize(target, 5, 5);
ok(hr == S_OK, "got 0x%08x\n", hr);
+ size.cx = size.cy = -1;
+ hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(size.cx == 5, "got %d\n", size.cx);
+ ok(size.cy == 5, "got %d\n", size.cy);
+
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
hr = IDWriteBitmapRenderTarget_Resize(target, 20, 5);
ok(hr == S_OK, "got 0x%08x\n", hr);
+ size.cx = size.cy = -1;
+ hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(size.cx == 20, "got %d\n", size.cx);
+ ok(size.cy == 5, "got %d\n", size.cy);
+
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
hr = IDWriteBitmapRenderTarget_Resize(target, 1, 5);
ok(hr == S_OK, "got 0x%08x\n", hr);
+ size.cx = size.cy = -1;
+ hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(size.cx == 1, "got %d\n", size.cx);
+ ok(size.cy == 5, "got %d\n", size.cy);
+
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
@@ -876,6 +894,12 @@ if (0) /* crashes on native */
hr = IDWriteBitmapRenderTarget_Resize(target, 0, 5);
ok(hr == S_OK, "got 0x%08x\n", hr);
+ size.cx = size.cy = -1;
+ hr = IDWriteBitmapRenderTarget_GetSize(target, &size);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(size.cx == 0, "got %d\n", size.cx);
+ ok(size.cy == 5, "got %d\n", size.cy);
+
hbm2 = GetCurrentObject(hdc, OBJ_BITMAP);
ok(hbm2 != hbm, "got %p, %p\n", hbm2, hbm);
--
2.1.4
More information about the wine-patches
mailing list