Remove uses of the glyph cache
Because the empty checks have been hoisted to the common code,
glyph cache is not needed by the painter closures.
Unify on the name textScale for all the code.
Capture run pointers by value.
Change-Id: I18be54fce7f52f336ae293d8897544393faca125
Reviewed-on: https://skia-review.googlesource.com/c/173645
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkGlyph.cpp b/src/core/SkGlyph.cpp
index c5c2a78..0206afc 100644
--- a/src/core/SkGlyph.cpp
+++ b/src/core/SkGlyph.cpp
@@ -128,6 +128,6 @@
}
}
}
- return fPathData ? fPathData->fPath.get() : nullptr;
+ return this->path();
}
diff --git a/src/core/SkGlyph.h b/src/core/SkGlyph.h
index 484b817..7ce0a7c 100644
--- a/src/core/SkGlyph.h
+++ b/src/core/SkGlyph.h
@@ -166,6 +166,10 @@
SkPath* addPath(SkScalerContext*, SkArenaAlloc*);
+ SkPath* path() const {
+ return fPathData ? fPathData->fPath.get() : nullptr;
+ }
+
// Returns the size allocated on the arena.
size_t copyImageData(const SkGlyph& from, SkArenaAlloc* alloc);
diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp
index 44337a8..00a4f6c 100644
--- a/src/core/SkGlyphRunPainter.cpp
+++ b/src/core/SkGlyphRunPainter.cpp
@@ -717,11 +717,11 @@
|| options.fDistanceFieldVerticesAlwaysHaveW;
// Setup distance field runPaint and text ratio
- SkScalar textRatio;
+ SkScalar textScale;
SkPaint distanceFieldPaint{runPaint};
SkScalerContextFlags flags;
GrTextContext::InitDistanceFieldPaint(this, &distanceFieldPaint, viewMatrix,
- options, &textRatio, &flags);
+ options, &textScale, &flags);
this->setHasDistanceField();
run->setSubRunHasDistanceFields(runPaint.isLCDRenderText(),
runPaint.isAntiAlias(), hasWCoord);
@@ -734,19 +734,20 @@
auto perEmpty = [](const SkGlyph&, SkPoint) {};
auto perSDF =
- [this, &run, &currStrike, &filteredColor, cache{cache.get()}, textRatio]
+ [this, run, &currStrike, &filteredColor, cache{cache.get()}, textScale]
(const SkGlyph& glyph, SkPoint position) {
run->appendGlyph(this, currStrike,
glyph, GrGlyph::kDistance_MaskStyle, position,
filteredColor,
- cache, textRatio, true);
+ cache, textScale, true);
};
auto perPath =
- [&run, textRatio, cache{cache.get()}]
+ [run, textScale]
(const SkGlyph& glyph, SkPoint position) {
- if (const SkPath* glyphPath = cache->findPath(glyph)) {
- run->appendPathGlyph(*glyphPath, position, textRatio, false);
+ // TODO: path should always be set. Remove when proven.
+ if (const SkPath* glyphPath = glyph.path()) {
+ run->appendPathGlyph(*glyphPath, position, textScale, false);
}
};
@@ -754,7 +755,7 @@
glyphCache, filteredColor};
glyphPainter->drawGlyphRunAsSDFWithARGBFallback(
- cache.get(), glyphRun, origin, viewMatrix, textRatio,
+ cache.get(), glyphRun, origin, viewMatrix, textScale,
std::move(perEmpty), std::move(perSDF), std::move(perPath),
std::move(argbFallback));
}
@@ -776,11 +777,11 @@
scalerContextFlags, SkMatrix::I());
// Given a glyph that is not ARGB, draw it.
- auto perPath = [textScale, &run, &pathCache]
+ auto perPath = [textScale, run]
(const SkGlyph& glyph, SkPoint position) {
- const SkPath* path = pathCache->findPath(glyph);
- if (path != nullptr) {
- run->appendPathGlyph(*path, position, textScale, false);
+ // TODO: path should always be set. Remove when proven.
+ if (const SkPath* glyphPath = glyph.path()) {
+ run->appendPathGlyph(*glyphPath, position, textScale, false);
}
};
@@ -801,7 +802,7 @@
auto perEmpty = [](const SkGlyph&, SkPoint) {};
auto perGlyph =
- [this, &run, &currStrike, &filteredColor, cache{cache.get()}]
+ [this, run, &currStrike, &filteredColor, cache{cache.get()}]
(const SkGlyph& glyph, SkPoint mappedPt) {
SkPoint pt{SkScalarFloorToScalar(mappedPt.fX),
SkScalarFloorToScalar(mappedPt.fY)};
@@ -811,12 +812,14 @@
};
auto perPath =
- [&run, cache{cache.get()}]
+ [run]
(const SkGlyph& glyph, SkPoint position) {
- const SkPath* glyphPath = cache->findPath(glyph);
SkPoint pt{SkScalarFloorToScalar(position.fX),
SkScalarFloorToScalar(position.fY)};
- run->appendPathGlyph(*glyphPath, pt, SK_Scalar1, true);
+ // TODO: path should always be set. Remove when proven.
+ if (const SkPath* glyphPath = glyph.path()) {
+ run->appendPathGlyph(*glyphPath, pt, SK_Scalar1, true);
+ }
};
glyphPainter->drawGlyphRunAsBMPWithPathFallback(