Don't draw strikes that are too small

This may fix a fuzzer bug that trips an
assert for empty rectangles. I could not reproduce
the fuzzer problem.

Bug: chromium:1029831
Change-Id: I88befb7c27d9ddc357e0a9e494e68125f8252f43
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257676
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2019-12-03 13:04:10 -05:00 committed by Skia Commit-Bot
parent c10a8321f8
commit c694627157
2 changed files with 33 additions and 26 deletions

View File

@ -209,17 +209,19 @@ void SkGlyphRunListPainter::processGlyphRunList(const SkGlyphRunList& glyphRunLi
std::tie(strikeSpec, minScale, maxScale) = std::tie(strikeSpec, minScale, maxScale) =
SkStrikeSpec::MakeSDFT(runFont, runPaint, fDeviceProps, viewMatrix, options); SkStrikeSpec::MakeSDFT(runFont, runPaint, fDeviceProps, viewMatrix, options);
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); if (!strikeSpec.isEmpty()) {
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startSource(fRejects.source(), origin); fDrawable.startSource(fRejects.source(), origin);
strike->prepareForSDFTDrawing(&fDrawable, &fRejects); strike->prepareForSDFTDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource(); fRejects.flipRejectsToSource();
if (process) { if (process) {
// processSourceSDFT must be called even if there are no glyphs to make sure runs // processSourceSDFT must be called even if there are no glyphs to make sure
// are set correctly. // runs are set correctly.
process->processSourceSDFT( process->processSourceSDFT(
fDrawable.drawable(), strikeSpec, runFont, minScale, maxScale); fDrawable.drawable(), strikeSpec, runFont, minScale, maxScale);
}
} }
} }
@ -232,18 +234,20 @@ void SkGlyphRunListPainter::processGlyphRunList(const SkGlyphRunList& glyphRunLi
SkStrikeSpec strikeSpec = SkStrikeSpec::MakePath( SkStrikeSpec strikeSpec = SkStrikeSpec::MakePath(
runFont, runPaint, fDeviceProps, fScalerContextFlags); runFont, runPaint, fDeviceProps, fScalerContextFlags);
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); if (!strikeSpec.isEmpty()) {
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startSource(fRejects.source(), origin); fDrawable.startSource(fRejects.source(), origin);
strike->prepareForPathDrawing(&fDrawable, &fRejects); strike->prepareForPathDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource(); fRejects.flipRejectsToSource();
maxDimensionInSourceSpace = maxDimensionInSourceSpace =
fRejects.rejectedMaxDimension() * strikeSpec.strikeToSourceRatio(); fRejects.rejectedMaxDimension() * strikeSpec.strikeToSourceRatio();
if (process) { if (process) {
// processSourcePaths must be called even if there are no glyphs to make sure runs // processSourcePaths must be called even if there are no glyphs to make sure
// are set correctly. // runs are set correctly.
process->processSourcePaths(fDrawable.drawable(), runFont, strikeSpec); process->processSourcePaths(fDrawable.drawable(), runFont, strikeSpec);
}
} }
} }
@ -315,15 +319,17 @@ void SkGlyphRunListPainter::processGlyphRunList(const SkGlyphRunList& glyphRunLi
runFont, runPaint, fDeviceProps, runFont, runPaint, fDeviceProps,
fScalerContextFlags, maxDimensionInSourceSpace); fScalerContextFlags, maxDimensionInSourceSpace);
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); if (!strikeSpec.isEmpty()) {
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startSource(fRejects.source(), origin); fDrawable.startSource(fRejects.source(), origin);
strike->prepareForMaskDrawing(&fDrawable, &fRejects); strike->prepareForMaskDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource(); fRejects.flipRejectsToSource();
SkASSERT(fRejects.source().empty()); SkASSERT(fRejects.source().empty());
if (process) { if (process) {
process->processSourceMasks(fDrawable.drawable(), strikeSpec); process->processSourceMasks(fDrawable.drawable(), strikeSpec);
}
} }
} }
} }

View File

@ -78,6 +78,7 @@ public:
SkStrikeCache* cache = SkStrikeCache::GlobalStrikeCache()) const; SkStrikeCache* cache = SkStrikeCache::GlobalStrikeCache()) const;
SkScalar strikeToSourceRatio() const { return fStrikeToSourceRatio; } SkScalar strikeToSourceRatio() const { return fStrikeToSourceRatio; }
bool isEmpty() const { return SkScalarNearlyZero(fStrikeToSourceRatio); }
const SkDescriptor& descriptor() const { return *fAutoDescriptor.getDesc(); } const SkDescriptor& descriptor() const { return *fAutoDescriptor.getDesc(); }
static bool ShouldDrawAsPath(const SkPaint& paint, const SkFont& font, const SkMatrix& matrix); static bool ShouldDrawAsPath(const SkPaint& paint, const SkFont& font, const SkMatrix& matrix);