]> git.saurik.com Git - wxWidgets.git/commitdiff
Avoid creating rect with negative size while clipping to DC size.
authorPaul Cornett <paulcor@bullseye.com>
Tue, 16 Aug 2011 07:02:37 +0000 (07:02 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Tue, 16 Aug 2011 07:02:37 +0000 (07:02 +0000)
Also, don't convert result of wxDC::GetSize() to device coords, it's already device coords.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68717 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/dcgraph.cpp

index a06cd25382a4ec19db041675f1a142b9e1fb23bf..1f7295a12ec61804252379364e95f12f54f0fee9 100644 (file)
@@ -896,6 +896,17 @@ bool wxGCDCImpl::DoStretchBlit(
         return false;
     }
 
         return false;
     }
 
+    wxRect subrect(source->LogicalToDeviceX(xsrc),
+                   source->LogicalToDeviceY(ysrc),
+                   source->LogicalToDeviceXRel(srcWidth),
+                   source->LogicalToDeviceYRel(srcHeight));
+    // clip the subrect down to the size of the source DC
+    wxRect clip;
+    source->GetSize(&clip.width, &clip.height);
+    subrect.Intersect(clip);
+    if (subrect.width == 0)
+        return true;
+
     bool retval = true;
 
     wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
     bool retval = true;
 
     wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
@@ -913,21 +924,6 @@ bool wxGCDCImpl::DoStretchBlit(
             ysrcMask = ysrc;
         }
 
             ysrcMask = ysrc;
         }
 
-        wxRect subrect(source->LogicalToDeviceX(xsrc),
-                       source->LogicalToDeviceY(ysrc),
-                       source->LogicalToDeviceXRel(srcWidth),
-                       source->LogicalToDeviceYRel(srcHeight));
-
-        // if needed clip the subrect down to the size of the source DC
-        wxCoord sw, sh;
-        source->GetSize(&sw, &sh);
-        sw = source->LogicalToDeviceXRel(sw);
-        sh = source->LogicalToDeviceYRel(sh);
-        if (subrect.x + subrect.width > sw)
-            subrect.width = sw - subrect.x;
-        if (subrect.y + subrect.height > sh)
-            subrect.height = sh - subrect.y;
-
         wxBitmap blit = source->GetAsBitmap( &subrect );
 
         if ( blit.IsOk() )
         wxBitmap blit = source->GetAsBitmap( &subrect );
 
         if ( blit.IsOk() )