Nikolay Sivov : dwrite: Update cached bitmap size on Resize() as well.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jul 22 13:40:38 CDT 2015


Module: wine
Branch: master
Commit: 5178c8b111673161167b2c6d12ac6a9e20eb7c7a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5178c8b111673161167b2c6d12ac6a9e20eb7c7a

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Wed Jul 22 11:54:53 2015 +0300

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




More information about the wine-cvs mailing list