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 352554 e3fb37a9876c95b1d97202b1b910de6f78a6e526
parent 352553 0532e792808ce33b366fc04f9eb7afd5a1ea4492
child 352555 c538edad135a485319c98da4ff86c1debaa93062
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewers0, 0, gchang
bugs1318625
milestone52.0a2
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)) {