From 54aefc74103a5c1810a7cc074746915c78ab3132 Mon Sep 17 00:00:00 2001 From: Yuqian Li Date: Wed, 11 Apr 2018 11:31:36 -0400 Subject: [PATCH] Add private fIsBadForDAA bit to SkPath Bug: chromium:821353 Change-Id: Ic6585e76df692bb1853d0990d75f0e8d1dee22f4 Reviewed-on: https://skia-review.googlesource.com/120201 Commit-Queue: Yuqian Li Reviewed-by: Mike Reed --- include/core/SkPath.h | 1 + src/core/SkDraw.cpp | 2 ++ src/core/SkPath.cpp | 2 ++ src/core/SkPathPriv.h | 4 ++++ src/core/SkScalerContext.cpp | 2 ++ src/core/SkScan_AntiPath.cpp | 3 ++- 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/core/SkPath.h b/include/core/SkPath.h index 895cf1ff75..3f1cb97fe9 100644 --- a/include/core/SkPath.h +++ b/include/core/SkPath.h @@ -1626,6 +1626,7 @@ private: mutable SkAtomic fConvexity; mutable SkAtomic fFirstDirection;// SkPathPriv::FirstDirection SkBool8 fIsVolatile; + SkBool8 fIsBadForDAA = false; /** Resets all fields other than fPathRef to their initial 'empty' values. * Assumes the caller has already emptied fPathRef. diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 62b84d804c..ccfd5b9991 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -22,6 +22,7 @@ #include "SkMatrixUtils.h" #include "SkPaint.h" #include "SkPathEffect.h" +#include "SkPathPriv.h" #include "SkRasterClip.h" #include "SkRectPriv.h" #include "SkRRect.h" @@ -1069,6 +1070,7 @@ void SkDraw::drawPath(const SkPath& origSrcPath, const SkPaint& origPaint, tmpPath = iData->fAlloc->make(); } tmpPath->setIsVolatile(true); + SkPathPriv::SetIsBadForDAA(*tmpPath, SkPathPriv::IsBadForDAA(origSrcPath)); if (prePathMatrix) { if (origPaint.getPathEffect() || origPaint.getStyle() != SkPaint::kFill_Style) { diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 284a6a716c..3fb91a38df 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -140,6 +140,7 @@ SkPath::SkPath() : fPathRef(SkPathRef::CreateEmpty()) { this->resetFields(); fIsVolatile = false; + fIsBadForDAA = false; } void SkPath::resetFields() { @@ -179,6 +180,7 @@ void SkPath::copyFields(const SkPath& that) { fLastMoveToIndex = that.fLastMoveToIndex; fFillType = that.fFillType; fIsVolatile = that.fIsVolatile; + fIsBadForDAA = that.fIsBadForDAA; // Non-atomic assignment of atomic values. fConvexity .store(that.fConvexity .load()); diff --git a/src/core/SkPathPriv.h b/src/core/SkPathPriv.h index 49977b10fd..506c5e181a 100644 --- a/src/core/SkPathPriv.h +++ b/src/core/SkPathPriv.h @@ -211,6 +211,10 @@ public: } return result; } + + // For crbug.com/821353 and skbug.com/6886 + static bool IsBadForDAA(const SkPath& path) { return path.fIsBadForDAA; } + static void SetIsBadForDAA(SkPath& path, bool isBadForDAA) { path.fIsBadForDAA = isBadForDAA; } }; #endif diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 600163910a..6e5fbe5635 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -21,6 +21,7 @@ #include "SkMatrix22.h" #include "SkPaintPriv.h" #include "SkPathEffect.h" +#include "SkPathPriv.h" #include "SkRasterClip.h" #include "SkReadBuffer.h" #include "SkStroke.h" @@ -444,6 +445,7 @@ void SkScalerContext::getImage(const SkGlyph& origGlyph) { } else { SkASSERT(SkMask::kARGB32_Format != origGlyph.fMaskFormat); SkASSERT(SkMask::kARGB32_Format != mask.fFormat); + SkPathPriv::SetIsBadForDAA(devPath, true); // crbug.com/821353 generateMask(mask, devPath, fPreBlend); } } diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp index ab86b4e7d9..45bc2e2ea6 100644 --- a/src/core/SkScan_AntiPath.cpp +++ b/src/core/SkScan_AntiPath.cpp @@ -8,6 +8,7 @@ #include "SkScanPriv.h" #include "SkPath.h" +#include "SkPathPriv.h" #include "SkMatrix.h" #include "SkBlitter.h" #include "SkRegion.h" @@ -601,7 +602,7 @@ static bool ShouldUseDAA(const SkPath& path) { if (gSkForceDeltaAA) { return true; } - if (!gSkUseDeltaAA) { + if (!gSkUseDeltaAA || SkPathPriv::IsBadForDAA(path)) { return false; }