From 633c32b13b5d199d797be669d3dc7981d603a945 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Thu, 31 Jan 2013 15:24:24 +0000 Subject: [PATCH] optimize region::intersect when one wholly contains the other clone of https://codereview.appspot.com/7237055/ git-svn-id: http://skia.googlecode.com/svn/trunk@7491 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gyp/bench.gypi | 1 + src/core/SkRegion.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/gyp/bench.gypi b/gyp/bench.gypi index 27e307cfa1..cf5c02e6ac 100644 --- a/gyp/bench.gypi +++ b/gyp/bench.gypi @@ -36,6 +36,7 @@ '../bench/RectBench.cpp', '../bench/RefCntBench.cpp', '../bench/RegionBench.cpp', + '../bench/RegionContainBench.cpp', '../bench/RepeatTileBench.cpp', '../bench/RTreeBench.cpp', '../bench/ScalarBench.cpp', diff --git a/src/core/SkRegion.cpp b/src/core/SkRegion.cpp index dcad9eaab6..936c87e832 100644 --- a/src/core/SkRegion.cpp +++ b/src/core/SkRegion.cpp @@ -1019,6 +1019,12 @@ bool SkRegion::Oper(const SkRegion& rgnaOrig, const SkRegion& rgnbOrig, Op op, if (a_rect & b_rect) { return setRectCheck(result, bounds); } + if (a_rect && rgna->fBounds.contains(rgnb->fBounds)) { + return setRegionCheck(result, *rgnb); + } + if (b_rect && rgnb->fBounds.contains(rgna->fBounds)) { + return setRegionCheck(result, *rgna); + } break; case kUnion_Op: