Bug 1287515 - fix android crashtest bustage. r=me
authorLee Salzman <lsalzman@mozilla.com>
Thu, 21 Jul 2016 02:02:08 -0400
changeset 305958 00833f7ba1348a0aefd3147ef9941978393f0703
parent 305957 59e9f5b2c2469df928fda147e70709613d21b80e
child 305959 fab0848f52e72b34ce47303ee8146c3efad6b8b7
push id79728
push userlsalzman@mozilla.com
push dateThu, 21 Jul 2016 06:02:49 +0000
treeherdermozilla-inbound@00833f7ba134 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1287515
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1287515 - fix android crashtest bustage. r=me
gfx/skia/skia/src/effects/SkDashPathEffect.cpp
gfx/skia/skia/src/utils/SkDashPath.cpp
gfx/skia/skia/src/utils/SkDashPathPriv.h
--- a/gfx/skia/skia/src/effects/SkDashPathEffect.cpp
+++ b/gfx/skia/skia/src/effects/SkDashPathEffect.cpp
@@ -246,19 +246,18 @@ bool SkDashPathEffect::asPoints(PointDat
                 }
             } else {
                 len2 -= clampedInitialDashLength; // skip initial partial empty
             }
         }
         // Too many midpoints can cause results->fNumPoints to overflow or
         // otherwise cause the results->fPoints allocation below to OOM.
         // Cap it to a sane value.
-        static const SkScalar kMaxPoints = 1000000;
         SkScalar numIntervals = len2 / fIntervalLength;
-        if (!SkScalarIsFinite(numIntervals) || numIntervals > kMaxPoints) {
+        if (!SkScalarIsFinite(numIntervals) || numIntervals > SkDashPath::kMaxDashCount) {
             return false;
         }
         int numMidPoints = SkScalarFloorToInt(numIntervals);
         results->fNumPoints += numMidPoints;
         len2 -= numMidPoints * fIntervalLength;
         bool partialLast = false;
         if (len2 > 0) {
             if (len2 < fIntervals[0]) {
--- a/gfx/skia/skia/src/utils/SkDashPath.cpp
+++ b/gfx/skia/skia/src/utils/SkDashPath.cpp
@@ -171,16 +171,17 @@ public:
 
         // now estimate how many quads will be added to the path
         //     resulting segments = pathLen * intervalCount / intervalLen
         //     resulting points = 4 * segments
 
         SkScalar ptCount = SkScalarMulDiv(pathLength,
                                           SkIntToScalar(intervalCount),
                                           intervalLength);
+        ptCount = SkTMin(ptCount, SkDashPath::kMaxDashCount);
         int n = SkScalarCeilToInt(ptCount) << 2;
         dst->incReserve(n);
 
         // we will take care of the stroking
         rec->setFillStyle();
         return true;
     }
 
@@ -247,17 +248,16 @@ bool SkDashPath::InternalFilter(SkPath* 
         // Since the path length / dash length ratio may be arbitrarily large, we can exert
         // significant memory pressure while attempting to build the filtered path. To avoid this,
         // we simply give up dashing beyond a certain threshold.
         //
         // The original bug report (http://crbug.com/165432) is based on a path yielding more than
         // 90 million dash segments and crashing the memory allocator. A limit of 1 million
         // segments seems reasonable: at 2 verbs per segment * 9 bytes per verb, this caps the
         // maximum dash memory overhead at roughly 17MB per path.
-        static const SkScalar kMaxDashCount = 1000000;
         dashCount += length * (count >> 1) / intervalLength;
         if (dashCount > kMaxDashCount) {
             dst->reset();
             return false;
         }
 
         // Using double precision to avoid looping indefinitely due to single precision rounding
         // (for extreme path_length/dash_length ratios). See test_infinite_dash() unittest.
--- a/gfx/skia/skia/src/utils/SkDashPathPriv.h
+++ b/gfx/skia/skia/src/utils/SkDashPathPriv.h
@@ -21,16 +21,18 @@ namespace SkDashPath {
      */
     void CalcDashParameters(SkScalar phase, const SkScalar intervals[], int32_t count,
                             SkScalar* initialDashLength, int32_t* initialDashIndex,
                             SkScalar* intervalLength, SkScalar* adjustedPhase = nullptr);
 
     bool FilterDashPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*,
                         const SkPathEffect::DashInfo& info);
 
+    const SkScalar kMaxDashCount = 1000000;
+
     /*
      * Caller should have already used ValidDashPath to exclude invalid data.
      */
     bool InternalFilter(SkPath* dst, const SkPath& src, SkStrokeRec* rec,
                         const SkRect* cullRect, const SkScalar aIntervals[],
                         int32_t count, SkScalar initialDashLength, int32_t initialDashIndex,
                         SkScalar intervalLength);