From dafc865d49f583cc8b9c29d41b9b85ca7edffa43 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Thu, 1 Sep 2016 21:24:35 +0200 Subject: [PATCH] Optimize wxDCImpl::DoSetClippingRegion Do intersection operations directly on the final wxRect containing clip box. --- src/common/dcbase.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 1c47eb598c..9b896c30e2 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -371,15 +371,14 @@ void wxDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) wxASSERT_MSG( w >= 0 && h >= 0, wxS("Clipping box size values cannot be negative") ); - wxRect newRegion(x, y, w, h); + wxRect clipRegion(x, y, w, h); - wxRect clipRegion; if ( m_clipping ) { // New clipping box is an intersection // of required clipping box and the current one. wxRect curRegion(m_clipX1, m_clipY1, m_clipX2 - m_clipX1, m_clipY2 - m_clipY1); - clipRegion = curRegion.Intersect(newRegion); + clipRegion.Intersect(curRegion); } else { @@ -389,7 +388,7 @@ void wxDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h) DoGetSize(&dcWidth, &dcHeight); wxRect dcRect(DeviceToLogicalX(0), DeviceToLogicalY(0), DeviceToLogicalXRel(dcWidth), DeviceToLogicalYRel(dcHeight)); - clipRegion = dcRect.Intersect(newRegion); + clipRegion.Intersect(dcRect); m_clipping = true; }