diff options
author | Herb Derby <herb@google.com> | 2018-07-10 22:59:23 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-10 22:59:26 +0000 |
commit | 83a355d698abcc85420cad2cb32003dda86c1201 (patch) | |
tree | 39a8d5d4209b89d61bbc1fcca77b631c27fea536 /src/core/SkGlyphRun.h | |
parent | 819f73c23cfd8471e1cbc77ee7c14d8150457765 (diff) |
Revert "Use new SkGlyphIDSet"
This reverts commit 819f73c23cfd8471e1cbc77ee7c14d8150457765.
Reason for revert: uninitialized memory - this is expected but
Original change's description:
> Use new SkGlyphIDSet
>
> Change-Id: I6b8080393a22a56577528f66630ad39372edf712
> Reviewed-on: https://skia-review.googlesource.com/140243
> Commit-Queue: Herb Derby <herb@google.com>
> Reviewed-by: Mike Klein <mtklein@google.com>
TBR=mtklein@google.com,herb@google.com
Change-Id: I43e204520710738e9e8c84b0eb00260ca06fe6a2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/140384
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkGlyphRun.h')
-rw-r--r-- | src/core/SkGlyphRun.h | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h index 7c3a74860c..7788376c70 100644 --- a/src/core/SkGlyphRun.h +++ b/src/core/SkGlyphRun.h @@ -83,14 +83,26 @@ private: const SkPaint fRunPaint; }; -class SkGlyphIDSet { +// A faster set implementation that does not need any initialization, and reading the set items +// is order the number of items, and not the size of the universe. +// This implementation is based on the paper by Briggs and Torczon, "An Efficient Representation +// for Sparse Sets" +// +// This implementation assumes that the unique glyphs added are appended to a vector that may +// already have unique glyph from a previous computation. This allows the packing of multiple +// UniqueID sequences in a single vector. +class SkGlyphSet { public: - SkSpan<const SkGlyphID> uniquifyGlyphIDs( - uint32_t universeSize, SkSpan<const SkGlyphID> glyphIDs, - SkGlyphID* uniqueGlyphIDs, uint16_t* denseindices); + SkGlyphSet() = default; + uint16_t add(SkGlyphID glyphID); + void reuse(uint32_t glyphUniverseSize, std::vector<SkGlyphID>* uniqueGlyphIDs); + private: - size_t fUniverseToUniqueSize{0}; - SkAutoTMalloc<uint16_t> fUniverseToUnique; + uint32_t uniqueSize(); + uint32_t fUniverseSize{0}; + size_t fStartOfUniqueIDs{0}; + std::vector<uint16_t> fIndices; + std::vector<SkGlyphID>* fUniqueGlyphIDs{nullptr}; }; class SkGlyphRunBuilder { @@ -103,35 +115,25 @@ public: const SkScalar xpos[], SkScalar constY); void prepareDrawPosText( const SkPaint& paint, const void* bytes, size_t byteLength, const SkPoint pos[]); + void prepareTextBlob(const SkPaint& paint, const SkTextBlob& blob, SkPoint origin); SkGlyphRun* useGlyphRun(); private: - void initialize(size_t totalRunSize); - SkSpan<const SkGlyphID> textToGlyphIDs( - const SkPaint& paint, const void* bytes, size_t byteLength); - - // Returns the span of unique glyph IDs. - SkSpan<const SkGlyphID> addDenseAndUnique( - const SkPaint& paint, - SkSpan<const SkGlyphID> glyphIDs); - + void initialize(); + void addDenseAndUnique(const SkPaint& paint, const void* bytes, size_t byteLength); void makeGlyphRun( - const SkPaint& runPaint, - SkSpan<const SkGlyphID> glyphIDs, - SkSpan<const SkPoint> positions, - SkSpan<const char> text, - SkSpan<const uint32_t> clusters); + const SkPaint& runPaint, SkSpan<const char> text, SkSpan<const uint32_t> clusters); void drawText( - const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs, SkPoint origin, + const SkPaint& paint, const void* bytes, size_t byteLength, SkPoint origin, SkSpan<const char> text, SkSpan<const uint32_t> clusters); void drawPosTextH( - const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs, + const SkPaint& paint, const void* bytes, size_t byteLength, const SkScalar* xpos, SkScalar constY, SkSpan<const char> text, SkSpan<const uint32_t> clusters); void drawPosText( - const SkPaint& paint, SkSpan<const SkGlyphID> glyphIDs, const SkPoint* pos, + const SkPaint& paint, const void* bytes, size_t byteLength, const SkPoint* pos, SkSpan<const char> text, SkSpan<const uint32_t> clusters); uint64_t fUniqueID{0}; @@ -139,6 +141,7 @@ private: std::vector<uint16_t> fDenseIndex; std::vector<SkPoint> fPositions; std::vector<SkGlyphID> fUniqueGlyphIDs; + SkGlyphID* fGlyphIDs{nullptr}; // Used as a temporary for preparing using utfN text. This implies that only one run of // glyph ids will ever be needed because blobs are already glyph based. @@ -152,7 +155,7 @@ private: SkGlyphRun fScratchGlyphRun; // Used for collecting the set of unique glyphs. - SkGlyphIDSet fGlyphIDSet; + SkGlyphSet fGlyphSet; }; #endif // SkGlyphRunInfo_DEFINED |