From 564b429f742138a75aeb183a1cb8fc139767de70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 12 Sep 2006 09:26:14 +0000 Subject: [PATCH] limit clipping to surface area git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41171 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/dfb/dc.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dfb/dc.cpp b/src/dfb/dc.cpp index 1b16ef396b..72b7ff8138 100644 --- a/src/dfb/dc.cpp +++ b/src/dfb/dc.cpp @@ -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;