From a4a76f3f4f4d76c689281687c98415564ba6bf21 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Fri, 15 Mar 2019 15:42:55 -0400 Subject: [PATCH] Clean up some types in SkFont Bug: skia: Change-Id: Ie0a3cc61f16e07619e69ff2d5dac566457572e80 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/201681 Auto-Submit: Kevin Lubick Reviewed-by: Ben Wagner Reviewed-by: Mike Reed Commit-Queue: Kevin Lubick --- include/core/SkFont.h | 18 +++++++++--------- src/core/SkFont.cpp | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/core/SkFont.h b/include/core/SkFont.h index 3d734a6795..74b7df57c7 100644 --- a/include/core/SkFont.h +++ b/include/core/SkFont.h @@ -361,12 +361,12 @@ public: @param widths returns text advances for each glyph; may be nullptr @param bounds returns bounds for each glyph relative to (0, 0); may be nullptr */ - void getWidths(const uint16_t glyphs[], int count, SkScalar widths[], SkRect bounds[]) const { + void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[]) const { this->getWidthsBounds(glyphs, count, widths, bounds, nullptr); } // DEPRECATED - void getWidths(const uint16_t glyphs[], int count, SkScalar widths[], std::nullptr_t) const { + void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[], std::nullptr_t) const { this->getWidths(glyphs, count, widths); } @@ -379,7 +379,7 @@ public: @param count number of glyphs @param widths returns text advances for each glyph */ - void getWidths(const uint16_t glyphs[], int count, SkScalar widths[]) const { + void getWidths(const SkGlyphID glyphs[], int count, SkScalar widths[]) const { this->getWidthsBounds(glyphs, count, widths, nullptr, nullptr); } @@ -394,7 +394,7 @@ public: @param bounds returns bounds for each glyph relative to (0, 0); may be nullptr @param paint optional, specifies stroking, SkPathEffect and SkMaskFilter */ - void getWidthsBounds(const uint16_t glyphs[], int count, SkScalar widths[], SkRect bounds[], + void getWidthsBounds(const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[], const SkPaint* paint) const; @@ -407,7 +407,7 @@ public: @param bounds returns bounds for each glyph relative to (0, 0); may be nullptr @param paint optional, specifies stroking, SkPathEffect, and SkMaskFilter */ - void getBounds(const uint16_t glyphs[], int count, SkRect bounds[], + void getBounds(const SkGlyphID glyphs[], int count, SkRect bounds[], const SkPaint* paint) const { this->getWidthsBounds(glyphs, count, nullptr, bounds, paint); } @@ -420,7 +420,7 @@ public: @param pos returns glyphs positions @param origin location of the first glyph. Defaults to {0, 0}. */ - void getPos(const uint16_t glyphs[], int count, SkPoint pos[], SkPoint origin = {0, 0}) const; + void getPos(const SkGlyphID glyphs[], int count, SkPoint pos[], SkPoint origin = {0, 0}) const; /** Retrieves the x-positions for each glyph, beginning at the specified origin. The caller must allocated at least count number of elements in the xpos[] array. @@ -430,7 +430,7 @@ public: @param xpos returns glyphs x-positions @param origin x-position of the first glyph. Defaults to 0. */ - void getXPos(const uint16_t glyphs[], int count, SkScalar xpos[], SkScalar origin = 0) const; + void getXPos(const SkGlyphID glyphs[], int count, SkScalar xpos[], SkScalar origin = 0) const; /** Returns path corresponding to glyph outline. If glyph has an outline, copies outline to path and returns true. @@ -441,7 +441,7 @@ public: @param path pointer to existing SkPath @return true if glyphID is described by path */ - bool getPath(uint16_t glyphID, SkPath* path) const; + bool getPath(SkGlyphID glyphID, SkPath* path) const; /** Returns path corresponding to glyph array. @@ -450,7 +450,7 @@ public: @param glyphPathProc function returning one glyph description as path @param ctx function context */ - void getPaths(const uint16_t glyphIDs[], int count, + void getPaths(const SkGlyphID glyphIDs[], int count, void (*glyphPathProc)(const SkPath* pathOrNull, const SkMatrix& mx, void* ctx), void* ctx) const; diff --git a/src/core/SkFont.cpp b/src/core/SkFont.cpp index 0ac4b496ea..5ab8447035 100644 --- a/src/core/SkFont.cpp +++ b/src/core/SkFont.cpp @@ -171,7 +171,7 @@ SkGlyphID SkFont::unicharToGlyph(SkUnichar uni) const { } int SkFont::textToGlyphs(const void* text, size_t byteLength, SkTextEncoding encoding, - uint16_t glyphs[], int maxGlyphCount) const { + SkGlyphID glyphs[], int maxGlyphCount) const { if (0 == byteLength) { return 0; } @@ -250,7 +250,7 @@ SkScalar SkFont::measureText(const void* text, size_t length, SkTextEncoding enc } return 0; } - const uint16_t* glyphs = atg.glyphs(); + const SkGlyphID* glyphs = atg.glyphs(); auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(font, canon.getPaint()); @@ -293,7 +293,7 @@ static SkRect make_bounds(const SkGlyph& g, SkScalar scale) { } template -void VisitGlyphs(const SkFont& origFont, const SkPaint* paint, const uint16_t glyphs[], int count, +void VisitGlyphs(const SkFont& origFont, const SkPaint* paint, const SkGlyphID glyphs[], int count, HANDLER handler) { if (count <= 0) { return; @@ -310,10 +310,10 @@ void VisitGlyphs(const SkFont& origFont, const SkPaint* paint, const uint16_t gl handler(cache.get(), glyphs, count, scale); } -void SkFont::getWidthsBounds(const uint16_t glyphs[], int count, SkScalar widths[], SkRect bounds[], +void SkFont::getWidthsBounds(const SkGlyphID glyphs[], int count, SkScalar widths[], SkRect bounds[], const SkPaint* paint) const { VisitGlyphs(*this, paint, glyphs, count, [widths, bounds] - (SkStrike* cache, const uint16_t glyphs[], int count, SkScalar scale) { + (SkStrike* cache, const SkGlyphID glyphs[], int count, SkScalar scale) { for (int i = 0; i < count; ++i) { const SkGlyph* g; if (bounds) { @@ -329,9 +329,9 @@ void SkFont::getWidthsBounds(const uint16_t glyphs[], int count, SkScalar widths }); } -void SkFont::getPos(const uint16_t glyphs[], int count, SkPoint pos[], SkPoint origin) const { +void SkFont::getPos(const SkGlyphID glyphs[], int count, SkPoint pos[], SkPoint origin) const { VisitGlyphs(*this, nullptr, glyphs, count, [pos, origin] - (SkStrike* cache, const uint16_t glyphs[], int count, SkScalar scale) { + (SkStrike* cache, const SkGlyphID glyphs[], int count, SkScalar scale) { SkPoint loc = origin; for (int i = 0; i < count; ++i) { pos[i] = loc; @@ -340,9 +340,9 @@ void SkFont::getPos(const uint16_t glyphs[], int count, SkPoint pos[], SkPoint o }); } -void SkFont::getXPos(const uint16_t glyphs[], int count, SkScalar xpos[], SkScalar origin) const { +void SkFont::getXPos(const SkGlyphID glyphs[], int count, SkScalar xpos[], SkScalar origin) const { VisitGlyphs(*this, nullptr, glyphs, count, [xpos, origin] - (SkStrike* cache, const uint16_t glyphs[], int count, SkScalar scale) { + (SkStrike* cache, const SkGlyphID glyphs[], int count, SkScalar scale) { SkScalar x = origin; for (int i = 0; i < count; ++i) { xpos[i] = x; @@ -351,7 +351,7 @@ void SkFont::getXPos(const uint16_t glyphs[], int count, SkScalar xpos[], SkScal }); } -void SkFont::getPaths(const uint16_t glyphs[], int count, +void SkFont::getPaths(const SkGlyphID glyphs[], int count, void (*proc)(const SkPath*, const SkMatrix&, void*), void* ctx) const { SkFont font(*this); SkScalar scale = font.setupForAsPaths(nullptr); @@ -368,7 +368,7 @@ void SkFont::getPaths(const uint16_t glyphs[], int count, } } -bool SkFont::getPath(uint16_t glyphID, SkPath* path) const { +bool SkFont::getPath(SkGlyphID glyphID, SkPath* path) const { struct Pair { SkPath* fPath; bool fWasSet; @@ -458,7 +458,7 @@ int SkFontPriv::CountTextElements(const void* text, size_t byteLength, SkTextEnc return 0; } -void SkFontPriv::GlyphsToUnichars(const SkFont& font, const uint16_t glyphs[], int count, +void SkFontPriv::GlyphsToUnichars(const SkFont& font, const SkGlyphID glyphs[], int count, SkUnichar uni[]) { font.glyphsToUnichars(glyphs, count, uni); }