Bug 1318625 - Part 1: Stop calculating circles around r=0 in DottedCornerFinder. r=0 in DottedCornerFinder.,jrmuizel, a=gchang
authorTooru Fujisawa <arai_a@mac.com>
Sat, 19 Nov 2016 12:10:46 +0900
changeset 358912 37a277bc59867c25bfa6750a96c8cc06c6512458
parent 358911 877a0309d8de7bbbaf58be83b8102e008b80062f
child 358913 fa3e6456dd1e35e1b0cb861d12de38fc32426e6f
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewers0, 0, gchang
bugs1318625
milestone51.0
Bug 1318625 - Part 1: Stop calculating circles around r=0 in DottedCornerFinder. r=0 in DottedCornerFinder.,jrmuizel, a=gchang
layout/base/DottedCornerFinder.cpp
--- a/layout/base/DottedCornerFinder.cpp
+++ b/layout/base/DottedCornerFinder.cpp
@@ -188,17 +188,20 @@ DottedCornerFinder::Next(void)
 
     Point C(mCenterCurveOrigin.x + mCenterCurveR * cos(phi),
             mCenterCurveOrigin.y + mCenterCurveR * sin(phi));
     return DottedCornerFinder::Result(C, mR0);
   }
 
   // Find unfilled and filled circles.
   (void)FindNext(mBestOverlap);
-  (void)FindNext(mBestOverlap);
+  if (mHasMore) {
+    (void)FindNext(mBestOverlap);
+  }
+
   return Result(mLastC, mLastR);
 }
 
 void
 DottedCornerFinder::Reset(void)
 {
   mLastC = mC0;
   mLastR = mR0;
@@ -340,16 +343,27 @@ DottedCornerFinder::FindNext(Float overl
       } else {
         break;
       }
     }
 
     circlesDist = sqrt(circlesDistSquare);
   }
 
+  if (mHasZeroBorderWidth) {
+    // When calculating circle around r=0, it may result in wrong radius that
+    // is bigger than previous circle.  Detect it and stop calculating.
+    const Float R_MARGIN = 0.1f;
+    if (mLastR < R_MARGIN && r > mLastR) {
+      mHasMore = false;
+      mLastR = 0.0f;
+      return 0.0f;
+    }
+  }
+
   mLastT = t;
   mLastC = C;
   mLastR = r;
 
   if (mHasZeroBorderWidth) {
     const Float T_MARGIN = 0.001f;
     if (mLastT >= 1.0f - T_MARGIN ||
         (mLastC - mCn).LengthSquare() < Square(mLastR)) {