diff options
author | Herb Derby <herb@google.com> | 2018-07-09 17:06:09 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-11 19:51:32 +0000 |
commit | b188da121c1575caa6b0b9755e3f80a6b5e44611 (patch) | |
tree | 3fd8ad986ffb3bf0739532b05d0df10f863e41a9 /src/core/SkGlyphRun.h | |
parent | d4998178ae6e0df3a90b9c1fa063cc97605f26af (diff) |
Use simple buffers instead of vectors
Start using simple buffers, these will be used for
multiple runs latter on.
Change-Id: I8dadbed036b7a60d708c49b84bb5e3bb3710f704
Reviewed-on: https://skia-review.googlesource.com/140578
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkGlyphRun.h')
-rw-r--r-- | src/core/SkGlyphRun.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h index 7c3a74860c..affc044f76 100644 --- a/src/core/SkGlyphRun.h +++ b/src/core/SkGlyphRun.h @@ -24,23 +24,23 @@ template <typename T> class SkSpan { public: SkSpan() : fPtr{nullptr}, fSize{0} {} - SkSpan(T* ptr, ptrdiff_t size) : fPtr{ptr}, fSize{size} { SkASSERT(size >= 0); } + SkSpan(T* ptr, size_t size) : fPtr{ptr}, fSize{size} { } template <typename U> - explicit SkSpan(std::vector<U>& v) : fPtr{v.data()}, fSize{SkTo<ptrdiff_t>(v.size())} {} + explicit SkSpan(std::vector<U>& v) : fPtr{v.data()}, fSize{v.size()} {} SkSpan(const SkSpan<T>& o) = default; SkSpan& operator=( const SkSpan& other ) = default; - T& operator [] (ptrdiff_t i) const { return fPtr[i]; } + T& operator [] (size_t i) const { return fPtr[i]; } T* begin() const { return fPtr; } T* end() const { return fPtr + fSize; } const T* cbegin() const { return fPtr; } const T* cend() const { return fPtr + fSize; } T* data() const { return fPtr; } - ptrdiff_t size() const { return fSize; } + size_t size() const { return fSize; } bool empty() const { return fSize == 0; } private: T* fPtr; - ptrdiff_t fSize; + size_t fSize; }; class SkGlyphRun { @@ -120,6 +120,8 @@ private: const SkPaint& runPaint, SkSpan<const SkGlyphID> glyphIDs, SkSpan<const SkPoint> positions, + SkSpan<const uint16_t> uniqueGlyphIDIndices, + SkSpan<const SkGlyphID> uniqueGlyphIDs, SkSpan<const char> text, SkSpan<const uint32_t> clusters); @@ -136,9 +138,10 @@ private: uint64_t fUniqueID{0}; - std::vector<uint16_t> fDenseIndex; - std::vector<SkPoint> fPositions; - std::vector<SkGlyphID> fUniqueGlyphIDs; + size_t fMaxTotalRunSize{0}; + SkAutoTMalloc<uint16_t> fUniqueGlyphIDIndices; + SkAutoTMalloc<SkPoint> fPositions; + SkAutoTMalloc<SkGlyphID> fUniqueGlyphIDs; // 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. |