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

View File

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