Early-out for subtracting a non-intersecting region
authordanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 May 2012 09:15:11 +0000 (09:15 +0000)
committerdanakj@chromium.org <danakj@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 May 2012 09:15:11 +0000 (09:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85258

Reviewed by Hajime Morita.

Given regions A and B, if the bounds of the regions do not intersect,
then the regions themselves do not intersect. If the intersection of
A and B is empty, then A subtract B == A.

* platform/graphics/Region.cpp:
(WebCore::Region::subtract):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115716 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Region.cpp

index a8845be..1877440 100644 (file)
@@ -1,3 +1,17 @@
+2012-05-01  Dana Jansens  <danakj@chromium.org>
+
+        Early-out for subtracting a non-intersecting region
+        https://bugs.webkit.org/show_bug.cgi?id=85258
+
+        Reviewed by Hajime Morita.
+
+        Given regions A and B, if the bounds of the regions do not intersect,
+        then the regions themselves do not intersect. If the intersection of
+        A and B is empty, then A subtract B == A.
+
+        * platform/graphics/Region.cpp:
+        (WebCore::Region::subtract):
+
 2012-04-30  Kent Tamura  <tkent@chromium.org>
 
         [Chromium/Windows] Add LocalizedDateWin
index 5f29de7..c4d2f56 100644 (file)
@@ -505,6 +505,8 @@ void Region::subtract(const Region& region)
 {
     if (region.isEmpty())
         return;
+    if (!m_bounds.intersects(region.m_bounds))
+        return;
 
     Shape subtractedShape = Shape::subtractShapes(m_shape, region.m_shape);