aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyphRun.h
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-06-18 16:25:52 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 19:56:25 +0000
commit9d85d63468eede1324c88b6e174834eb096113fe (patch)
treeb08d9d455cb2323aadea851abc10cf6d40d2a458 /src/core/SkGlyphRun.h
parent91e260f4dbcb4006c3b177c2eba7ed0dc1af3e3d (diff)
Use SkGlyphRun instead of builder
Move from passing builder down the stack to passing the object we really want to be the interface down the stack. Move code that shunts from glyph run style to drawTextPos to the SkGlyphRun from the builder. Change-Id: Iefaca69104737ce46c06fbb26dc99996784b2bdb Reviewed-on: https://skia-review.googlesource.com/135620 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
Diffstat (limited to 'src/core/SkGlyphRun.h')
-rw-r--r--src/core/SkGlyphRun.h47
1 files changed, 31 insertions, 16 deletions
diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h
index eeb9c2924e..243d5d121c 100644
--- a/src/core/SkGlyphRun.h
+++ b/src/core/SkGlyphRun.h
@@ -23,13 +23,17 @@ class SkBaseDevice;
template <typename T>
class SkSpan {
public:
- SkSpan() = default;
+ SkSpan() : fPtr{nullptr}, fSize{0} {}
SkSpan(const T* ptr, size_t size) : fPtr{ptr}, fSize{size} {}
explicit SkSpan(const std::vector<T>& v) : fPtr{v.data()}, fSize{v.size()} {}
const T& operator [] (ptrdiff_t i) const { return fPtr[i]; }
- const T* begin() const { return fPtr; }
- const T* end() const { return fPtr + fSize; }
+ T* begin() const { return fPtr; }
+ T* end() const { return fPtr + fSize; }
+ const T* cbegin() const { return fPtr; }
+ const T* cend() const { return fPtr + fSize; }
+ const T* data() const { return fPtr; }
ptrdiff_t size() const { return fSize; }
+ bool empty() const { return fSize == 0; }
private:
const T* fPtr;
@@ -39,20 +43,37 @@ private:
class SkGlyphRun {
public:
SkGlyphRun() = default;
- SkGlyphRun(SkSpan<uint16_t> denseIndex, SkSpan<SkPoint> positions,
+ SkGlyphRun(SkSpan<uint16_t> denseIndex,
+ SkSpan<SkPoint> positions,
+ SkSpan<SkGlyphID> scratchGlyphs,
SkSpan<SkGlyphID> uniqueGlyphIDs)
: fDenseIndex{denseIndex}
, fPositions{positions}
- , fUniqueGlyphIDs{uniqueGlyphIDs} {}
+ , fTemporaryShuntGlyphIDs{scratchGlyphs}
+ , fUniqueGlyphIDs{uniqueGlyphIDs} {
+ SkASSERT(denseIndex.size() == positions.size());
+ SkASSERT(denseIndex.size() == scratchGlyphs.size());
+ }
+
+ // The temporaryShunt calls are to allow inter-operating with existing code while glyph runs
+ // are developed.
+ void temporaryShuntToDrawPosText(const SkPaint& paint, SkBaseDevice* device);
+ using TemporaryShuntCallback = std::function<void(size_t, const char*, const SkScalar*)>;
+ void temporaryShuntToCallback(TemporaryShuntCallback callback);
size_t runSize() const { return fDenseIndex.size(); }
uint16_t uniqueSize() const { return fUniqueGlyphIDs.size(); }
SkSpan<SkPoint> positions() const { return SkSpan<SkPoint>(fPositions); }
private:
- SkSpan<uint16_t> fDenseIndex;
- SkSpan<SkPoint> fPositions;
- SkSpan<SkGlyphID> fUniqueGlyphIDs;
+ // Indices into the unique glyph IDs. On for each original glyph.
+ const SkSpan<uint16_t> fDenseIndex;
+ // The base line position of all the glyphs in source space.
+ const SkSpan<SkPoint> fPositions;
+ // This is temporary while converting from the old per glyph code to the bulk code.
+ const SkSpan<SkGlyphID> fTemporaryShuntGlyphIDs;
+ // The set of unique glyphs in the run.
+ const SkSpan<SkGlyphID> fUniqueGlyphIDs;
};
// A faster set implementation that does not need any initialization, and reading the set items
@@ -89,13 +110,7 @@ public:
size_t runSize() const {return fDenseIndex.size();}
size_t uniqueSize() const {return fUniqueGlyphs.size();}
- const SkGlyphRun& useGlyphRun() const;
-
- // The temporaryShunt calls are to allow inter-operating with existing code while glyph runs
- // are developed.
- void temporaryShuntToDrawPosText(const SkPaint& paint, SkBaseDevice* device);
- using TemporaryShuntCallback = std::function<void(size_t, const char*, const SkScalar*)>;
- void temporaryShuntToCallback(TemporaryShuntCallback callback);
+ SkGlyphRun* useGlyphRun();
private:
void initializeDenseAndUnique(const SkPaint& paint, const void* bytes, size_t byteLength);
@@ -119,7 +134,7 @@ private:
const SkGlyphID* fTemporaryShuntGlyphIDs{nullptr};
// Used for collecting the set of unique glyphs.
- SkGlyphSet fGlyphSet;
+ SkGlyphSet fGlyphSet;
};
#endif // SkGlyphRunInfo_DEFINED