inline drawingType facilitating future refactoring

Inline the control back into this code to facilitate future refactoring
to make size calculation more precise.

Bug: chromium: 1280180

Change-Id: If66174ab1d28571a7b84d4ab4bd7fa09ce86c3af
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/491043
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2022-01-04 12:35:28 -05:00 committed by SkCQ
parent 1afa5fb64b
commit 61d0fbbca7
2 changed files with 48 additions and 51 deletions

View File

@ -250,65 +250,69 @@ void SkGlyphRunListPainter::processGlyphRun(const SkGlyphRun& glyphRun,
fRejects.setSource(glyphRun.source());
const SkFont& runFont = glyphRun.font();
GrSDFTControl::DrawingType drawingType = control.drawingType(runFont, runPaint, drawMatrix);
if (drawingType == GrSDFTControl::kSDFT) {
// Process SDFT - This should be the .009% case.
const auto& [strikeSpec, strikeToSourceScale, minScale, maxScale] =
SkStrikeSpec::MakeSDFT(runFont, runPaint, fDeviceProps, drawMatrix, control);
// Only consider using direct or SDFT drawing if not drawing hairlines and not perspective.
if ((runPaint.getStyle() != SkPaint::kStroke_Style || runPaint.getStrokeWidth() != 0)
&& !drawMatrix.hasPerspective()) {
GrSDFTControl::DrawingType drawingType = control.drawingType(runFont, runPaint, drawMatrix);
if (drawingType == GrSDFTControl::kSDFT) {
// Process SDFT - This should be the .009% case.
const auto& [strikeSpec, strikeToSourceScale, minScale, maxScale] =
SkStrikeSpec::MakeSDFT(runFont, runPaint, fDeviceProps, drawMatrix, control);
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" SDFT case:\n%s", strikeSpec.dump().c_str());
#endif
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" SDFT case:\n%s", strikeSpec.dump().c_str());
#endif
if (!SkScalarNearlyZero(strikeToSourceScale)) {
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startSource(fRejects.source());
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" glyphs:(x,y):\n %s\n", fDrawable.dumpInput().c_str());
#endif
strike->prepareForSDFTDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource();
if (process && !fDrawable.drawableIsEmpty()) {
// processSourceSDFT must be called even if there are no glyphs to make sure
// runs are set correctly.
process->processSourceSDFT(fDrawable.drawable(),
strike->getUnderlyingStrike(),
strikeToSourceScale,
runFont,
minScale, maxScale);
}
}
}
if (drawingType != GrSDFTControl::kPath && !fRejects.source().empty()) {
// Process masks including ARGB - this should be the 99.99% case.
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeMask(
runFont, runPaint, fDeviceProps, fScalerContextFlags, drawMatrix);
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" Mask case:\n%s", strikeSpec.dump().c_str());
#endif
if (!SkScalarNearlyZero(strikeToSourceScale)) {
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startSource(fRejects.source());
fDrawable.startGPUDevice(fRejects.source(), drawMatrix, strike->roundingSpec());
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" glyphs:(x,y):\n %s\n", fDrawable.dumpInput().c_str());
#endif
strike->prepareForSDFTDrawing(&fDrawable, &fRejects);
strike->prepareForMaskDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource();
if (process && !fDrawable.drawableIsEmpty()) {
// processSourceSDFT must be called even if there are no glyphs to make sure
// runs are set correctly.
process->processSourceSDFT(fDrawable.drawable(),
strike->getUnderlyingStrike(),
strikeToSourceScale,
runFont,
minScale, maxScale);
// processDeviceMasks must be called even if there are no glyphs to make sure runs
// are set correctly.
process->processDeviceMasks(fDrawable.drawable(), strike->getUnderlyingStrike());
}
}
}
if (drawingType != GrSDFTControl::kPath && !fRejects.source().empty()) {
// Process masks including ARGB - this should be the 99.99% case.
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeMask(
runFont, runPaint, fDeviceProps, fScalerContextFlags, drawMatrix);
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" Mask case:\n%s", strikeSpec.dump().c_str());
#endif
SkScopedStrikeForGPU strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
fDrawable.startGPUDevice(fRejects.source(), drawMatrix, strike->roundingSpec());
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
msg.appendf(" glyphs:(x,y):\n %s\n", fDrawable.dumpInput().c_str());
#endif
strike->prepareForMaskDrawing(&fDrawable, &fRejects);
fRejects.flipRejectsToSource();
if (process && !fDrawable.drawableIsEmpty()) {
// processDeviceMasks must be called even if there are no glyphs to make sure runs
// are set correctly.
process->processDeviceMasks(fDrawable.drawable(), strike->getUnderlyingStrike());
}
}
// Glyphs are generated in different scales relative to the source space. Masks are drawn
// in device space, and SDFT and Paths are draw in a fixed constant space. The
// maxDimensionInSourceSpace is used to calculate the factor from strike space to source

View File

@ -47,13 +47,6 @@ GrSDFTControl::GrSDFTControl(
auto GrSDFTControl::drawingType(
const SkFont& font, const SkPaint& paint, const SkMatrix& viewMatrix) const -> DrawingType {
// Use paths as the first choice for hairlines and perspective.
if ((paint.getStyle() == SkPaint::kStroke_Style && paint.getStrokeWidth() == 0)
|| viewMatrix.hasPerspective()) {
return kPath;
}
SkScalar maxScale = viewMatrix.getMaxScale();
SkScalar scaledTextSize = maxScale * font.getSize();