Plumb strike through the common code.
Plump the strike calculated in the calling code through
drawGlyphRunAsBMPWithPathFallback. This is in anticipation
of calculating the cache in drawGlyphRunAsBMPWithPathFallback.
* Add getDescriptor to SkStrikeInterface.
Change-Id: I904cdb51f60443cabc9dc41ac246b1fe0c725c85
Reviewed-on: https://skia-review.googlesource.com/c/191285
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp
index 651b74d..7a26a62 100644
--- a/src/core/SkGlyphRunPainter.cpp
+++ b/src/core/SkGlyphRunPainter.cpp
@@ -372,7 +372,7 @@
template <typename EmptiesT, typename MasksT, typename PathsT>
void SkGlyphRunListPainter::drawGlyphRunAsBMPWithPathFallback(
- SkStrikeInterface* cache, const SkGlyphRun& glyphRun,
+ SkStrikeInterface* strike, const SkGlyphRun& glyphRun,
SkPoint origin, const SkMatrix& deviceMatrix,
EmptiesT&& processEmpties, MasksT&& processMasks, PathsT&& processPaths) {
ScopedBuffers _ = this->ensureBuffers(glyphRun);
@@ -383,7 +383,7 @@
SkMatrix mapping = deviceMatrix;
mapping.preTranslate(origin.x(), origin.y());
- SkVector rounding = cache->rounding();
+ SkVector rounding = strike->rounding();
mapping.postTranslate(rounding.x(), rounding.y());
mapping.mapPoints(fPositions, glyphRun.positions().data(), glyphRun.runSize());
@@ -397,11 +397,11 @@
}
if (SkScalarsAreFinite(mappedPt.x(), mappedPt.y())) {
- const SkGlyph& glyph = cache->getGlyphMetrics(glyphID, mappedPt);
+ const SkGlyph& glyph = strike->getGlyphMetrics(glyphID, mappedPt);
if (glyph.isEmpty()) {
emptyGlyphs.push_back(&glyph);
} else if (SkStrikeCommon::GlyphTooBigForAtlas(glyph)) {
- if (cache->decideCouldDrawFromPath(glyph)) {
+ if (strike->decideCouldDrawFromPath(glyph)) {
fPaths.push_back({&glyph, mappedPt});
} else {
// This happens when a bitmap-only font is forced to scale very large. This
@@ -420,7 +420,7 @@
}
if (glyphCount > 0) {
mapping.mapPoints(fPositions, glyphCount);
- processMasks(SkSpan<const GlyphAndPos>{fMasks, SkTo<size_t>(glyphCount)});
+ processMasks(SkSpan<const GlyphAndPos>{fMasks, SkTo<size_t>(glyphCount)}, strike);
}
if (!fPaths.empty()) {
processPaths(SkSpan<const GlyphAndPos>{fPaths});
@@ -833,9 +833,10 @@
auto processEmpties = [](SkSpan<const SkGlyph*>glyphs) {};
auto processMasks =
- [run, cache{cache.get()}, glyphCache]
- (SkSpan<const SkGlyphRunListPainter::GlyphAndPos> masks) {
- sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache->getDescriptor());
+ [run, glyphCache]
+ (SkSpan<const SkGlyphRunListPainter::GlyphAndPos> masks,
+ SkStrikeInterface* strike) {
+ sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(strike->getDescriptor());
for (const auto& mask : masks) {
SkPoint pt{SkScalarFloorToScalar(mask.position.fX),
SkScalarFloorToScalar(mask.position.fY)};
@@ -943,7 +944,8 @@
auto processEmpties = [] (SkSpan<const SkGlyph*>glyphs) { };
- auto processMasks = [] (SkSpan<const SkGlyphRunListPainter::GlyphAndPos> masks) { };
+ auto processMasks = [] (
+ SkSpan<const SkGlyphRunListPainter::GlyphAndPos> masks, SkStrikeInterface*) { };
auto processPaths = [] (SkSpan<const SkGlyphRunListPainter::GlyphAndPos> paths) { };
diff --git a/src/core/SkGlyphRunPainter.h b/src/core/SkGlyphRunPainter.h
index eb85c39..7b3d8fe 100644
--- a/src/core/SkGlyphRunPainter.h
+++ b/src/core/SkGlyphRunPainter.h
@@ -23,6 +23,7 @@
public:
virtual ~SkStrikeInterface() = default;
virtual SkVector rounding() const = 0;
+ virtual const SkDescriptor& getDescriptor() const = 0;
virtual const SkGlyph& getGlyphMetrics(SkGlyphID glyphID, SkPoint position) = 0;
virtual bool decideCouldDrawFromPath(const SkGlyph& glyph) = 0;
};
diff --git a/src/core/SkRemoteGlyphCacheImpl.h b/src/core/SkRemoteGlyphCacheImpl.h
index ccb1235..789f611 100644
--- a/src/core/SkRemoteGlyphCacheImpl.h
+++ b/src/core/SkRemoteGlyphCacheImpl.h
@@ -29,7 +29,7 @@
bool isSubpixel() const { return fIsSubpixel; }
SkAxisAlignment axisAlignmentForHText() const { return fAxisAlignmentForHText; }
- const SkDescriptor& getDescriptor() {
+ const SkDescriptor& getDescriptor() const override {
return *fDescriptor.getDesc();
}
diff --git a/src/core/SkStrike.h b/src/core/SkStrike.h
index c490beb..d01b9a9 100644
--- a/src/core/SkStrike.h
+++ b/src/core/SkStrike.h
@@ -38,8 +38,6 @@
std::unique_ptr<SkScalerContext> scaler,
const SkFontMetrics&);
- const SkDescriptor& getDescriptor() const;
-
/** Return true if glyph is cached. */
bool isGlyphCached(SkGlyphID glyphID, SkFixed x, SkFixed y) const;
@@ -129,6 +127,9 @@
bool decideCouldDrawFromPath(const SkGlyph& glyph) override;
+ const SkDescriptor& getDescriptor() const override;
+
+
/** Return the approx RAM usage for this cache. */
size_t getMemoryUsed() const { return fMemoryUsed; }
diff --git a/src/core/SkStrikeCache.cpp b/src/core/SkStrikeCache.cpp
index f1d6e34..6d94740 100644
--- a/src/core/SkStrikeCache.cpp
+++ b/src/core/SkStrikeCache.cpp
@@ -40,6 +40,10 @@
return fCache.decideCouldDrawFromPath(glyph);
}
+ const SkDescriptor& getDescriptor() const override {
+ return fCache.getDescriptor();
+ }
+
SkStrikeCache* const fStrikeCache;
Node* fNext{nullptr};
Node* fPrev{nullptr};