]> git.saurik.com Git - wxWidgets.git/commitdiff
limit clipping to surface area
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 12 Sep 2006 09:26:14 +0000 (09:26 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 12 Sep 2006 09:26:14 +0000 (09:26 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41171 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/dfb/dc.cpp

index 1b16ef396b1485edc4ae5fd63170d3a8318058db..72b7ff8138041bf83ab881e1a09f2f56dd6c1c1a 100644 (file)
@@ -92,11 +92,16 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
 {
     wxCHECK_RET( Ok(), wxT("invalid dc") );
 
+    wxSize size(GetSize());
+
+    // NB: We intersect the clipping rectangle with surface's area here because
+    //     DirectFB will return an error if you try to set clipping rectangle
+    //     that is partially outside of the surface.
     DFBRegion r;
-    r.x1 = XLOG2DEV(cx);
-    r.y1 = YLOG2DEV(cy);
-    r.x2 = r.x1 + XLOG2DEVREL(cw) - 1;
-    r.y2 = r.y1 + YLOG2DEVREL(ch) - 1;
+    r.x1 = wxMax(0, XLOG2DEV(cx));
+    r.y1 = wxMax(0, YLOG2DEV(cy));
+    r.x2 = wxMin(r.x1 + XLOG2DEVREL(cw), size.x) - 1;
+    r.y2 = wxMin(r.y1 + YLOG2DEVREL(ch), size.y) - 1;
 
     if ( !m_surface->SetClip(&r) )
         return;