Zhiyi Zhang : uxtheme: Do not resize source image even if destination is smaller than sizing margins.

Alexandre Julliard julliard at winehq.org
Tue Jan 25 15:41:16 CST 2022


Module: wine
Branch: master
Commit: 7bc708df3522d35f0bfd507a67b4e2abfc76b5ce
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7bc708df3522d35f0bfd507a67b4e2abfc76b5ce

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Tue Jan 25 16:00:23 2022 +0800

uxtheme: Do not resize source image even if destination is smaller than sizing margins.

This partially reverts 2b650fa, which resizes source image if destination is smaller than its sizing
margins. Resizing the source image may result in the destination image missing some edges because
of StretchBlt() calls. Same StretchBlt() calls also produce similar results on Windows. So it seems
that Windows don't resize the source image and only resize the margins to try to keep the edges
crisp.

Fix scroll bar thumb missing edges when it's too small.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/uxtheme/draw.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/dlls/uxtheme/draw.c b/dlls/uxtheme/draw.c
index 709cf522d00..75db466967c 100644
--- a/dlls/uxtheme/draw.c
+++ b/dlls/uxtheme/draw.c
@@ -711,9 +711,9 @@ static HRESULT UXTHEME_DrawImageBackground(HTHEME hTheme, HDC hdc, int iPartId,
                                     const DTBGOPTS *pOptions)
 {
     HRESULT hr = S_OK;
-    HBITMAP bmpSrc, bmpSrcResized = NULL;
+    HBITMAP bmpSrc;
     HGDIOBJ oldSrc;
-    HDC hdcSrc, hdcOrigSrc = NULL;
+    HDC hdcSrc;
     RECT rcSrc;
     RECT rcDst;
     POINT dstSize;
@@ -777,33 +777,17 @@ static HRESULT UXTHEME_DrawImageBackground(HTHEME hTheme, HDC hdc, int iPartId,
 
         GetThemeMargins(hTheme, hdc, iPartId, iStateId, TMT_SIZINGMARGINS, NULL, &sm);
 
-        /* Resize source image if destination smaller than margins */
+        /* Resize sizing margins if destination is smaller */
         if (sm.cyTopHeight + sm.cyBottomHeight > dstSize.y || sm.cxLeftWidth + sm.cxRightWidth > dstSize.x) {
             if (sm.cyTopHeight + sm.cyBottomHeight > dstSize.y) {
                 sm.cyTopHeight = MulDiv(sm.cyTopHeight, dstSize.y, srcSize.y);
                 sm.cyBottomHeight = dstSize.y - sm.cyTopHeight;
-                srcSize.y = dstSize.y;
             }
 
             if (sm.cxLeftWidth + sm.cxRightWidth > dstSize.x) {
                 sm.cxLeftWidth = MulDiv(sm.cxLeftWidth, dstSize.x, srcSize.x);
                 sm.cxRightWidth = dstSize.x - sm.cxLeftWidth;
-                srcSize.x = dstSize.x;
             }
-
-            hdcOrigSrc = hdcSrc;
-            hdcSrc = CreateCompatibleDC(NULL);
-            bmpSrcResized = CreateBitmap(srcSize.x, srcSize.y, 1, 32, NULL);
-            SelectObject(hdcSrc, bmpSrcResized);
-
-            /* Use ALPHABLEND_NONE because the image is getting resized, rather than blended with the target */
-            UXTHEME_StretchBlt(hdcSrc, 0, 0, srcSize.x, srcSize.y, hdcOrigSrc, rcSrc.left, rcSrc.top,
-                               rcSrc.right - rcSrc.left, rcSrc.bottom - rcSrc.top, ALPHABLEND_NONE, 0);
-
-            rcSrc.left = 0;
-            rcSrc.top = 0;
-            rcSrc.right = srcSize.x;
-            rcSrc.bottom = srcSize.y;
         }
 
         hdcDst = hdc;
@@ -910,8 +894,6 @@ draw_error:
     }
     SelectObject(hdcSrc, oldSrc);
     DeleteDC(hdcSrc);
-    if (bmpSrcResized) DeleteObject(bmpSrcResized);
-    if (hdcOrigSrc) DeleteDC(hdcOrigSrc);
     *pRect = rcDst;
     return hr;
 }




More information about the wine-cvs mailing list