diff options
author | Yuqian Li <liyuqian@google.com> | 2018-03-01 16:53:27 -0800 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-05 14:58:54 +0000 |
commit | a445fdd6e95f9409914ad41416a40bb39e198d94 (patch) | |
tree | ce563289e04dbb7ea00c66c27ed02ae33a80f97d /src/core | |
parent | 4be123fb6c04b366dc0b931c16340d29f2ce2f04 (diff) |
Set SkDAARecord to empty type if the scan converter returns early
Otherwise,
./out/Debug/dm --config t8888 -m bug583299
will crash at SkASSERT(record->fType != SkDAARecord::Type::kToBeComputed)
Bug: skia:
Change-Id: Ie93221bd6ea7ab9bc9f3d79fd7fe02b315e6a089
Reviewed-on: https://skia-review.googlesource.com/111680
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkCoverageDelta.h | 16 | ||||
-rw-r--r-- | src/core/SkScan_AntiPath.cpp | 7 | ||||
-rw-r--r-- | src/core/SkScan_DAAPath.cpp | 1 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/core/SkCoverageDelta.h b/src/core/SkCoverageDelta.h index cfbee5ed3e..e0a50f4f3b 100644 --- a/src/core/SkCoverageDelta.h +++ b/src/core/SkCoverageDelta.h @@ -186,7 +186,8 @@ struct SkDAARecord { enum class Type { kToBeComputed, kMask, - kList + kList, + kEmpty } fType; SkMask fMask; @@ -194,6 +195,19 @@ struct SkDAARecord { SkArenaAlloc* fAlloc; SkDAARecord(SkArenaAlloc* alloc) : fType(Type::kToBeComputed), fAlloc(alloc) {} + + // When the scan converter returns early (e.g., the path is completely out of the clip), we set + // the type to empty to signal that the record has been computed and it's empty. This is + // required only for DEBUG where we check that the type must not be kToBeComputed after + // init-once. + void setEmpty() { fType = Type::kEmpty; } + static inline void SetEmpty(SkDAARecord* record) { // record may be nullptr +#ifdef SK_DEBUG + if (record) { + record->setEmpty(); + } +#endif + } }; template<typename T> diff --git a/src/core/SkScan_AntiPath.cpp b/src/core/SkScan_AntiPath.cpp index 43ef09abbf..4be24efd6e 100644 --- a/src/core/SkScan_AntiPath.cpp +++ b/src/core/SkScan_AntiPath.cpp @@ -669,6 +669,7 @@ static SkIRect safeRoundOut(const SkRect& src) { void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip, SkBlitter* blitter, bool forceRLE, SkDAARecord* daaRecord) { if (origClip.isEmpty()) { + SkDAARecord::SetEmpty(daaRecord); return; } @@ -678,6 +679,7 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip, if (isInverse) { blitter->blitRegion(origClip); } + SkDAARecord::SetEmpty(daaRecord); return; } @@ -691,10 +693,11 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip, clippedIR = origClip.getBounds(); } else { if (!clippedIR.intersect(ir, origClip.getBounds())) { + SkDAARecord::SetEmpty(daaRecord); return; } } - if (rect_overflows_short_shift(clippedIR, SHIFT)) { + if (!daaRecord && rect_overflows_short_shift(clippedIR, SHIFT)) { SkScan::FillPath(path, origClip, blitter); return; } @@ -724,6 +727,7 @@ void SkScan::AntiFillPath(const SkPath& path, const SkRegion& origClip, if (isInverse) { blitter->blitRegion(*clipRgn); } + SkDAARecord::SetEmpty(daaRecord); return; } @@ -776,6 +780,7 @@ void SkScan::FillPath(const SkPath& path, const SkRasterClip& clip, SkBlitter* b void SkScan::AntiFillPath(const SkPath& path, const SkRasterClip& clip, SkBlitter* blitter, SkDAARecord* daaRecord) { if (clip.isEmpty() || !path.isFinite()) { + SkDAARecord::SetEmpty(daaRecord); return; } diff --git a/src/core/SkScan_DAAPath.cpp b/src/core/SkScan_DAAPath.cpp index 9eb7c14cfa..343c4c73f1 100644 --- a/src/core/SkScan_DAAPath.cpp +++ b/src/core/SkScan_DAAPath.cpp @@ -330,6 +330,7 @@ void SkScan::DAAFillPath(const SkPath& path, SkBlitter* blitter, const SkIRect& // The overhead of even constructing SkCoverageDeltaList/Mask is too big. // So TryBlitFatAntiRect and return if it's successful. if (!isInverse && TryBlitFatAntiRect(blitter, path, clipBounds)) { + SkDAARecord::SetEmpty(record); return; } |