Inline allocateNewGlyph
allocateNewGlyph is used in a single place.
Change-Id: Iccf06d647dddf8fb90ea888c61e9cbb77304ec1f
Reviewed-on: https://skia-review.googlesource.com/c/191665
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
diff --git a/src/core/SkStrike.cpp b/src/core/SkStrike.cpp
index 436f734..c520b07 100644
--- a/src/core/SkStrike.cpp
+++ b/src/core/SkStrike.cpp
@@ -91,32 +91,33 @@
SkGlyph* SkStrike::lookupByPackedGlyphID(SkPackedGlyphID packedGlyphID, MetricsType type) {
SkGlyph* glyphPtr = fGlyphMap.findOrNull(packedGlyphID);
- if (nullptr == glyphPtr) {
- glyphPtr = this->allocateNewGlyph(packedGlyphID, type);
+ if (glyphPtr == nullptr) {
+ // Glyph is not present in the stirke. Make a new glyph and fill it in.
+
+ fMemoryUsed += sizeof(SkGlyph);
+ glyphPtr = fAlloc.make<SkGlyph>(packedGlyphID);
+ fGlyphMap.set(glyphPtr);
+
+ switch (type) {
+ // * Nothing - is only used for raw glyphs. It is assumed that the advances, etc. are
+ // filled in by external code. This is used by the remote glyph cache to fill in glyphs.
+ case kNothing_MetricsType:
+ break;
+ case kJustAdvance_MetricsType:
+ fScalerContext->getAdvance(glyphPtr);
+ break;
+ case kFull_MetricsType:
+ fScalerContext->getMetrics(glyphPtr);
+ break;
+ }
} else {
+ // Glyph is present in strike. Make sure the glyph has the right data.
+
if (type == kFull_MetricsType && glyphPtr->isJustAdvance()) {
fScalerContext->getMetrics(glyphPtr);
}
}
- return glyphPtr;
-}
-SkGlyph* SkStrike::allocateNewGlyph(SkPackedGlyphID packedGlyphID, MetricsType mtype) {
- fMemoryUsed += sizeof(SkGlyph);
-
- SkGlyph* glyphPtr = fAlloc.make<SkGlyph>(packedGlyphID);
- fGlyphMap.set(glyphPtr);
-
- if (kNothing_MetricsType == mtype) {
- return glyphPtr;
- } else if (kJustAdvance_MetricsType == mtype) {
- fScalerContext->getAdvance(glyphPtr);
- } else {
- SkASSERT(kFull_MetricsType == mtype);
- fScalerContext->getMetrics(glyphPtr);
- }
-
- SkASSERT(glyphPtr->fID != SkPackedGlyphID());
return glyphPtr;
}
diff --git a/src/core/SkStrike.h b/src/core/SkStrike.h
index e5c3da3..7e3331a 100644
--- a/src/core/SkStrike.h
+++ b/src/core/SkStrike.h
@@ -179,13 +179,9 @@
// Return the SkGlyph* associated with MakeID. The id parameter is the
// combined glyph/x/y id generated by MakeID. If it is just a glyph id
- // then x and y are assumed to be zero.
+ // then x and y are assumed to be zero. Limit the amount of work using type.
SkGlyph* lookupByPackedGlyphID(SkPackedGlyphID packedGlyphID, MetricsType type);
- // Return a new SkGlyph for the glyph ID and subpixel position id. Limit the amount
- // of work using type.
- SkGlyph* allocateNewGlyph(SkPackedGlyphID packedGlyphID, MetricsType type);
-
static void OffsetResults(const SkGlyph::Intercept* intercept, SkScalar scale,
SkScalar xPos, SkScalar* array, int* count);
static void AddInterval(SkScalar val, SkGlyph::Intercept* intercept);