diff options
author | Herb Derby <herb@google.com> | 2018-07-20 11:48:38 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-24 14:53:25 +0000 |
commit | 81ecdbb7ff36afef9091c1b524baafe67381e70d (patch) | |
tree | c9d2a2ace6fecc88bf85e1377c2eeb8d8d007a5a /src/core/SkGlyphRun.h | |
parent | ab98509717e1d20b8171a631d2923f47ce26fc0e (diff) |
Clean up bitmap path
Change-Id: If149194fd86f14bea289ad68262ea99cbbc398b6
Reviewed-on: https://skia-review.googlesource.com/142817
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkGlyphRun.h')
-rw-r--r-- | src/core/SkGlyphRun.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h index 0146b1d515..f3b4ff34e3 100644 --- a/src/core/SkGlyphRun.h +++ b/src/core/SkGlyphRun.h @@ -41,6 +41,7 @@ public: size_t size() const { return fSize; } bool empty() const { return fSize == 0; } size_t size_bytes() const { return fSize * sizeof(T); } + SkSpan<const T> toConst() const { return SkSpan<const T>{fPtr, fSize}; } private: T* fPtr; @@ -52,7 +53,7 @@ public: SkGlyphRun() = default; SkGlyphRun(SkPaint&& runPaint, SkSpan<const uint16_t> denseIndices, - SkSpan<const SkPoint> positions, + SkSpan<SkPoint> positions, SkSpan<const SkGlyphID> glyphIDs, SkSpan<const SkGlyphID> uniqueGlyphIDs, SkSpan<const char> text, @@ -61,6 +62,13 @@ public: // A function that turns an SkGlyphRun into an SkGlyphRun for each glyph. using PerGlyph = std::function<void (SkGlyphRun*, SkPaint*)>; void eachGlyphToGlyphRun(PerGlyph perGlyph); + void mapPositions(const SkMatrix& matrix); + + // The following made a ~5% speed improvement over not using a template. + //using PerGlyphPos = std::function<void (SkGlyphID glyphID, SkPoint positions)>; + template <typename PerGlyphPos> + void forEachGlyphAndPosition(PerGlyphPos perGlyph) const; + // The temporaryShunt calls are to allow inter-operating with existing code while glyph runs // are developed. @@ -70,7 +78,7 @@ public: void filloutGlyphsAndPositions(SkGlyphID* glyphIDs, SkPoint* positions); size_t runSize() const { return fGlyphIDs.size(); } - SkSpan<const SkPoint> positions() const { return fPositions; } + SkSpan<const SkPoint> positions() const { return fPositions.toConst(); } SkSpan<const SkGlyphID> shuntGlyphsIDs() const { return fGlyphIDs; } const SkPaint& paint() const { return fRunPaint; } SkPaint* mutablePaint() { return &fRunPaint; } @@ -81,7 +89,7 @@ private: // const SkSpan<const uint16_t> fUniqueGlyphIDIndices; // - const SkSpan<const SkPoint> fPositions; + const SkSpan<SkPoint> fPositions; // This is temporary while converting from the old per glyph code to the bulk code. const SkSpan<const SkGlyphID> fGlyphIDs; // The unique glyphs from fGlyphIDs. @@ -94,6 +102,14 @@ private: SkPaint fRunPaint; }; +template <typename PerGlyphPos> +inline void SkGlyphRun::forEachGlyphAndPosition(PerGlyphPos perGlyph) const { + SkPoint* ptCursor = fPositions.data(); + for (auto glyphID : fGlyphIDs) { + perGlyph(glyphID, *ptCursor++); + } +} + class SkGlyphRunList { const SkPaint* fOriginalPaint{nullptr}; // This should be deleted soon. // The text blob is needed to hookup the call back that the SkTextBlob destructor calls. It @@ -207,7 +223,7 @@ private: void makeGlyphRun( const SkPaint& runPaint, SkSpan<const SkGlyphID> glyphIDs, - SkSpan<const SkPoint> positions, + SkSpan<SkPoint> positions, SkSpan<const uint16_t> uniqueGlyphIDIndices, SkSpan<const SkGlyphID> uniqueGlyphIDs, SkSpan<const char> text, @@ -228,7 +244,7 @@ private: SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{}); size_t simplifyDrawPosText( const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs, const SkPoint* pos, - uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs, + uint16_t* uniqueGlyphIDIndices, SkGlyphID* uniqueGlyphIDs, SkPoint* positions, SkSpan<const char> text = SkSpan<const char>{}, SkSpan<const uint32_t> clusters = SkSpan<const uint32_t>{}); |