summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2014-08-05 16:11:21 +0000
committerCaolán McNamara <caolanm@redhat.com>2014-08-07 20:34:49 +0100
commit1ca06ce59b7d3cea873d2dc109a2acaec0a80759 (patch)
treeda06b4ef1f3bc6c1b547cefe970b2a5b81fcf507 /basegfx
parentbb182b47ca7362b05c03d583d3547643d9a99562 (diff)
Related: #i125349# moved clip enhancements to base clipping functionality
(cherry picked from commit 7c5e9b9b3c5c899d63bf171ee1c9050db860337e) Change-Id: I570e92c78196895bef329eb308eeb68ffc5e23d3
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/source/polygon/b2dpolygonclipper.cxx67
1 files changed, 67 insertions, 0 deletions
diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx b/basegfx/source/polygon/b2dpolygonclipper.cxx
index b8d4a04bed30..e73c388044e9 100644
--- a/basegfx/source/polygon/b2dpolygonclipper.cxx
+++ b/basegfx/source/polygon/b2dpolygonclipper.cxx
@@ -341,6 +341,73 @@ namespace basegfx
if(rCandidate.count() && rClip.count())
{
+ // #125349# detect if both given PolyPolygons are indeed ranges
+ bool bBothRectangle(false);
+
+ if(basegfx::tools::isRectangle(rCandidate))
+ {
+ if(basegfx::tools::isRectangle(rClip))
+ {
+ // both are ranges
+ bBothRectangle = true;
+ }
+ else
+ {
+ // rCandidate is rectangle -> clip rClip on rRectangle, use the much
+ // cheaper and numerically more stable clipping against a range
+ // This simplification (exchanging content and clip) is valid
+ // since we do a logical AND operation
+ return clipPolyPolygonOnRange(rClip, rCandidate.getB2DRange(), bInside, bStroke);
+ }
+ }
+ else if(basegfx::tools::isRectangle(rClip))
+ {
+ if(basegfx::tools::isRectangle(rCandidate))
+ {
+ // both are ranges
+ bBothRectangle = true;
+ }
+ else
+ {
+ // rClip is rectangle -> clip rCandidate on rRectangle, use the much
+ // cheaper and numerically more stable clipping against a range
+ return clipPolyPolygonOnRange(rCandidate, rClip.getB2DRange(), bInside, bStroke);
+ }
+ }
+
+ if(bBothRectangle)
+ {
+ // both are rectangle
+ if(rCandidate.getB2DRange().equal(rClip.getB2DRange()))
+ {
+ // if both are equal -> no change
+ return rCandidate;
+ }
+ else
+ {
+ // not equal -> create new intersection from both ranges,
+ // but much cheaper based on the ranges
+ basegfx::B2DRange aIntersectionRange(rCandidate.getB2DRange());
+
+ aIntersectionRange.intersect(rClip.getB2DRange());
+
+ if(aIntersectionRange.isEmpty())
+ {
+ // no common IntersectionRange -> the clip will be empty
+ return B2DPolyPolygon();
+ }
+ else
+ {
+ // use common aIntersectionRange as result, convert
+ // to expected PolyPolygon form
+ return basegfx::B2DPolyPolygon(
+ basegfx::tools::createPolygonFromRect(aIntersectionRange));
+ }
+ }
+ }
+
+ // one or both are no rectangle - go the hard way and clip PolyPolygon
+ // against PolyPolygon...
if(bStroke)
{
// line clipping, create line snippets by first adding all cut points and