[PATCH] uxtheme: Fix buffer dc origin and clipping
Nikolay Sivov
nsivov at codeweavers.com
Tue Apr 25 00:54:07 CDT 2017
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
For https://bugs.winehq.org/show_bug.cgi?id=42871
dlls/uxtheme/buffer.c | 4 +++-
dlls/uxtheme/tests/system.c | 55 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/dlls/uxtheme/buffer.c b/dlls/uxtheme/buffer.c
index bbf4c9d1c7..664515c278 100644
--- a/dlls/uxtheme/buffer.c
+++ b/dlls/uxtheme/buffer.c
@@ -137,6 +137,8 @@ HPAINTBUFFER WINAPI BeginBufferedPaint(HDC targetdc, const RECT *rect,
return NULL;
}
+ SetWindowOrgEx(buffer->memorydc, rect->left, rect->top, NULL);
+ IntersectClipRect(buffer->memorydc, rect->left, rect->top, rect->right, rect->bottom);
DeleteObject(SelectObject(buffer->memorydc, buffer->bitmap));
*retdc = buffer->memorydc;
@@ -160,7 +162,7 @@ HRESULT WINAPI EndBufferedPaint(HPAINTBUFFER bufferhandle, BOOL update)
{
if (!BitBlt(buffer->targetdc, buffer->rect.left, buffer->rect.top,
buffer->rect.right - buffer->rect.left, buffer->rect.bottom - buffer->rect.top,
- buffer->memorydc, 0, 0, SRCCOPY))
+ buffer->memorydc, buffer->rect.left, buffer->rect.top, SRCCOPY))
{
WARN("BitBlt() failed\n");
}
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c
index 2348a1da2c..1842be449a 100644
--- a/dlls/uxtheme/tests/system.c
+++ b/dlls/uxtheme/tests/system.c
@@ -523,14 +523,42 @@ static void test_CloseThemeData(void)
ok( hRes == E_HANDLE, "Expected E_HANDLE, got 0x%08x\n", hRes);
}
+static void test_buffer_dc_props(HDC hdc, const RECT *rect)
+{
+ static const XFORM ident = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f };
+ XFORM xform;
+ POINT org;
+ RECT box;
+ BOOL ret;
+
+ ret = GetWorldTransform(hdc, &xform);
+ ok(ret, "Failed to get world transform\n");
+ ok(!memcmp(&xform, &ident, sizeof(xform)), "Unexpected world transform\n");
+
+ ret = GetViewportOrgEx(hdc, &org);
+ ok(ret, "Failed to get vport origin\n");
+ ok(org.x == 0 && org.y == 0, "Unexpected vport origin\n");
+
+ ret = GetWindowOrgEx(hdc, &org);
+ ok(ret, "Failed to get vport origin\n");
+ ok(org.x == rect->left && org.y == rect->top, "Unexpected window origin\n");
+
+ ret = GetClipBox(hdc, &box);
+ ok(ret, "Failed to get clip box\n");
+ ok(box.left == rect->left && box.top == rect->top, "Unexpected clip box\n");
+
+ ok(GetGraphicsMode(hdc) == GM_COMPATIBLE, "wrong graphics mode\n");
+}
+
static void test_buffered_paint(void)
{
+ HDC target, src, hdc, screen_dc;
BP_PAINTPARAMS params = { 0 };
BP_BUFFERFORMAT format;
- HDC target, src, hdc;
HPAINTBUFFER buffer;
RECT rect, rect2;
RGBQUAD *bits;
+ HBITMAP hbm;
HRESULT hr;
int row;
@@ -670,6 +698,31 @@ todo_wine
hr = pGetBufferedPaintBits(NULL, NULL, &row);
ok(hr == E_POINTER, "Unexpected return code %#x\n", hr);
+ screen_dc = GetDC(0);
+
+ hdc = CreateCompatibleDC(screen_dc);
+ ok(hdc != NULL, "Failed to create a DC\n");
+ hbm = CreateCompatibleBitmap(screen_dc, 64, 64);
+ ok(hbm != NULL, "Failed to create a bitmap\n");
+ SelectObject(hdc, hbm);
+
+ ReleaseDC(0, screen_dc);
+
+ SetRect(&rect, 1, 2, 34, 56);
+
+ buffer = pBeginBufferedPaint(hdc, &rect, BPBF_COMPATIBLEBITMAP, NULL, &src);
+ test_buffer_dc_props(src, &rect);
+ hr = pEndBufferedPaint(buffer, FALSE);
+ ok(hr == S_OK, "Unexpected return code %#x\n", hr);
+
+ DeleteObject(hbm);
+ DeleteDC(hdc);
+
+ buffer = pBeginBufferedPaint(target, &rect, BPBF_COMPATIBLEBITMAP, NULL, &src);
+ test_buffer_dc_props(src, &rect);
+ hr = pEndBufferedPaint(buffer, FALSE);
+ ok(hr == S_OK, "Unexpected return code %#x\n", hr);
+
/* access buffer bits */
for (format = BPBF_COMPATIBLEBITMAP; format <= BPBF_TOPDOWNMONODIB; format++)
{
--
2.11.0
More information about the wine-patches
mailing list