[2/2] msvfw32: Make it clear why a DrawDibBegin call is required

Bruno Jesus 00cpxxx at gmail.com
Sat Oct 31 12:22:54 CDT 2015


Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>

While studying bug 9032 it was important to determine which was the
cause to call DrawDibBegin so I split the condition ir order to make
it easy for future problems.

Also add a final TRACE as a bonus.
-------------- next part --------------

---
 dlls/msvfw32/drawdib.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/dlls/msvfw32/drawdib.c b/dlls/msvfw32/drawdib.c
index e96b0f2..27ac3b5 100644
--- a/dlls/msvfw32/drawdib.c
+++ b/dlls/msvfw32/drawdib.c
@@ -313,7 +313,8 @@ BOOL VFWAPI DrawDibDraw(HDRAWDIB hdd, HDC hdc,
                         UINT wFlags)
 {
     WINE_HDD *whdd;
-    BOOL ret = TRUE;
+    BOOL ret;
+    int reopen = 0;
 
     TRACE("(%p,%p,%d,%d,%d,%d,%p,%p,%d,%d,%d,%d,0x%08x)\n",
           hdd, hdc, xDst, yDst, dxDst, dyDst, lpbi, lpBits, xSrc, ySrc, dxSrc, dySrc, wFlags);
@@ -335,11 +336,25 @@ BOOL VFWAPI DrawDibDraw(HDRAWDIB hdd, HDC hdc,
 
 #define CHANGED(x) (whdd->x != x)
 
-    if ((!whdd->begun) || 
-        (!(wFlags & DDF_SAME_HDC) && CHANGED(hdc)) || 
-        (!(wFlags & DDF_SAME_DRAW) && (CHANGED(lpbi) || CHANGED(dxSrc) || CHANGED(dySrc) || CHANGED(dxDst) || CHANGED(dyDst)))) 
+    /* Check if anything changed from the parameters passed and our struct.
+     * If anything changed we need to run DrawDibBegin again to ensure we
+     * can support the changes.
+     */
+    if (!whdd->begun)
+        reopen = 1;
+    else if (!(wFlags & DDF_SAME_HDC) && CHANGED(hdc))
+        reopen = 2;
+    else if (!(wFlags & DDF_SAME_DRAW))
     {
-        TRACE("Something changed!\n");
+        if (CHANGED(lpbi) && memcmp(lpbi, whdd->lpbi, sizeof(*lpbi))) reopen = 3;
+        else if (CHANGED(dxSrc)) reopen = 4;
+        else if (CHANGED(dySrc)) reopen = 5;
+        else if (CHANGED(dxDst)) reopen = 6;
+        else if (CHANGED(dyDst)) reopen = 7;
+    }
+    if (reopen)
+    {
+        TRACE("Something changed (reason %d)!\n", reopen);
         ret = DrawDibBegin(hdd, hdc, dxDst, dyDst, lpbi, dxSrc, dySrc, 0);
         if (!ret)
             return ret;
@@ -388,9 +403,10 @@ BOOL VFWAPI DrawDibDraw(HDRAWDIB hdd, HDC hdc,
          SelectPalette(hdc, whdd->hpal, FALSE);
     }
 
-    if (!(StretchBlt(whdd->hdc, xDst, yDst, dxDst, dyDst, whdd->hMemDC, xSrc, ySrc, dxSrc, dySrc, SRCCOPY)))
-        ret = FALSE;
-    
+    ret = StretchBlt(whdd->hdc, xDst, yDst, dxDst, dyDst, whdd->hMemDC, xSrc, ySrc, dxSrc, dySrc, SRCCOPY);
+    TRACE("Painting %dx%d at %d,%d from %dx%d at %d,%d -> %d\n",
+          dxDst, dyDst, xDst, yDst, dxSrc, dySrc, xSrc, ySrc, ret);
+
     return ret;
 }
 
-- 
2.1.4



More information about the wine-patches mailing list