diff options
-rw-r--r-- | src/core/SkCoverageDelta.cpp | 4 | ||||
-rw-r--r-- | src/core/SkScan_AntiPath.cpp | 51 |
2 files changed, 14 insertions, 41 deletions
diff --git a/src/core/SkCoverageDelta.cpp b/src/core/SkCoverageDelta.cpp index defdcf2b7b..a6bb1dd5f9 100644 --- a/src/core/SkCoverageDelta.cpp +++ b/src/core/SkCoverageDelta.cpp @@ -46,10 +46,6 @@ int SkCoverageDeltaMask::ExpandWidth(int width) { } bool SkCoverageDeltaMask::CanHandle(const SkIRect& bounds) { - // Return early if either width or height is very large because width * height might overflow. - if (bounds.width() >= MAX_MASK_SIZE || bounds.height() >= MAX_MASK_SIZE) { - return false; - } // Expand width so we don't have to worry about the boundary return ExpandWidth(bounds.width()) * bounds.height() + PADDING * 2 < MAX_MASK_SIZE; } diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp index 2eaa89ed8a..ad181a77f8 100644 --- a/src/core/SkScan_AntiPath.cpp +++ b/src/core/SkScan_AntiPath.cpp @@ -12,7 +12,6 @@ #include "SkBlitter.h" #include "SkRegion.h" #include "SkAntiRun.h" -#include "SkCoverageDelta.h" #define SHIFT SK_SUPERSAMPLE_SHIFT #define SCALE (1 << SHIFT) @@ -584,19 +583,6 @@ void MaskSuperBlitter::blitH(int x, int y, int width) { /////////////////////////////////////////////////////////////////////////////// -static SkIRect safeRoundOut(const SkRect& src) { - // roundOut will pin huge floats to max/min int - SkIRect dst = src.roundOut(); - - // intersect with a smaller huge rect, so the rect will not be considered empty for being - // too large. e.g. { -SK_MaxS32 ... SK_MaxS32 } is considered empty because its width - // exceeds signed 32bit. - const int32_t limit = SK_MaxS32 >> SK_SUPERSAMPLE_SHIFT; - (void)dst.intersect({ -limit, -limit, limit, limit}); - - return dst; -} - static bool ShouldUseDAA(const SkPath& path) { if (gSkForceDeltaAA) { return true; @@ -611,18 +597,12 @@ static bool ShouldUseDAA(const SkPath& path) { #else constexpr int kSampleSize = 8; constexpr SkScalar kComplexityThreshold = 0.25; - constexpr SkScalar kSmallCubicThreshold = 16; int n = path.countPoints(); if (path.isConvex() || n < kSampleSize) { return false; } - // DAA is fast with mask - if (SkCoverageDeltaMask::CanHandle(safeRoundOut(path.getBounds()))) { - return true; - } - SkScalar sumLength = 0; SkPoint lastPoint = path.getPoint(0); for(int i = 1; i < kSampleSize; ++i) { @@ -630,27 +610,11 @@ static bool ShouldUseDAA(const SkPath& path) { sumLength += SkPoint::Distance(lastPoint, point); lastPoint = point; } - SkScalar avgLength = sumLength / (kSampleSize - 1); - - // DAA is much faster in small cubics (since we don't have to chop them). - // If there are many cubics, and the average length if small, use DAA. - if (avgLength < kSmallCubicThreshold) { - uint8_t sampleVerbs[kSampleSize]; - int verbCount = SkTMin(kSampleSize, path.getVerbs(sampleVerbs, kSampleSize)); - int cubicCount = 0; - for(int i = 0; i < verbCount; ++i) { - cubicCount += (sampleVerbs[i] == SkPath::kCubic_Verb); - } - if (cubicCount * 2 >= verbCount) { - return true; - } - } - SkScalar diagonal = SkPoint::Length(path.getBounds().width(), path.getBounds().height()); // On average, what's the distance between two consecutive points; the number is normalized // to a range of [0, 1] where 1 corresponds to the maximum length of the diagonal. - SkScalar sampleSpan = avgLength / diagonal; + SkScalar sampleSpan = sumLength / (kSampleSize - 1) / diagonal; // If the path is consist of random line segments, the number of intersections should be @@ -723,6 +687,19 @@ static int rect_overflows_short_shift(SkIRect rect, int shift) { overflows_short_shift(rect.fBottom, shift); } +static SkIRect safeRoundOut(const SkRect& src) { + // roundOut will pin huge floats to max/min int + SkIRect dst = src.roundOut(); + + // intersect with a smaller huge rect, so the rect will not be considered empty for being + // too large. e.g. { -SK_MaxS32 ... SK_MaxS32 } is considered empty because its width + // exceeds signed 32bit. + const int32_t limit = SK_MaxS32 >> SK_SUPERSAMPLE_SHIFT; + (void)dst.intersect({ -limit, -limit, limit, limit}); + + return dst; +} + void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip, SkBlitter* blitter, bool forceRLE, SkDAARecord* daaRecord) { if (origClip.isEmpty()) { |