aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyphRun.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkGlyphRun.h')
-rw-r--r--src/core/SkGlyphRun.h100
1 files changed, 13 insertions, 87 deletions
diff --git a/src/core/SkGlyphRun.h b/src/core/SkGlyphRun.h
index 6f9041c443..739ad0bc38 100644
--- a/src/core/SkGlyphRun.h
+++ b/src/core/SkGlyphRun.h
@@ -16,11 +16,9 @@
#include "SkMask.h"
#include "SkPath.h"
#include "SkPoint.h"
-#include "SkTextBlob.h"
#include "SkTypes.h"
class SkBaseDevice;
-class SkDrawFilter;
template <typename T>
class SkSpan {
@@ -76,12 +74,11 @@ public:
size_t fUniqueOffset, uint16_t fUniqueSize,
SkSpan<SkGlyphID> scratchGlyphs,
SkSpan<const char> text,
- SkSpan<const uint32_t> clusters,
- SkPaint&& runPaint);
+ SkSpan<uint32_t> clusters);
// The temporaryShunt calls are to allow inter-operating with existing code while glyph runs
// are developed.
- void temporaryShuntToDrawPosText(SkBaseDevice* device, SkPoint origin);
+ void temporaryShuntToDrawPosText(const SkPaint& paint, SkBaseDevice* device);
using TemporaryShuntCallback = std::function<void(size_t, const char*, const SkScalar*)>;
void temporaryShuntToCallback(TemporaryShuntCallback callback);
@@ -93,21 +90,6 @@ public:
SkSpan<const SkGlyphID> uniqueGlyphIDs() const {
return fRunInfo.uniqueGlyphIDs(fUniqueOffset, fUniqueSize);
}
- SkSpan<SkGlyphID> shuntGlyphsIDs() const {
- return fTemporaryShuntGlyphIDs;
- }
-
- const SkPaint& paint() const {
- return fRunPaint;
- }
-
- SkSpan<const uint32_t> clusters() const {
- return fClusters;
- }
-
- SkSpan<const char> text() const {
- return fText;
- }
private:
const SkIndexedRunInfo& fRunInfo;
@@ -121,39 +103,18 @@ private:
// Original text from SkTextBlob if present. Will be empty of not present.
const SkSpan<const char> fText;
// Original clusters from SkTextBlob if present. Will be empty if not present.
- const SkSpan<const uint32_t> fClusters;
- // Paint for this run modified to have glyph encoding and left alignment.
- const SkPaint fRunPaint;
+ const SkSpan<uint32_t> fClusters;
};
class SkGlyphRunList {
+ const uint64_t fUniqueID{0};
SkSpan<SkGlyphRun> fGlyphRuns;
- SkPoint fOrigin = {0, 0};
-
- // The text blob is needed to hookup the call back that the SkTextBlob destructor calls. It
- // should be used for nothing else
- const SkTextBlob* fTemporaryTextBlobShunt{nullptr};
public:
SkGlyphRunList() = default;
- // Blob maybe null.
- SkGlyphRunList(SkSpan<SkGlyphRun> glyphRuns, SkPoint origin, const SkTextBlob* blob);
-
- uint64_t uniqueID() const;
- bool anyRunsLCD() const;
- void temporaryShuntBlobnotifyAddedToCache(uint32_t cacheID) const;
-
- bool canCache() const { return fTemporaryTextBlobShunt != nullptr; }
- ptrdiff_t runCount() const { return fGlyphRuns.size(); }
- size_t totalGlyphCount() const {
- size_t glyphCount = 0;
- for(const auto& run : fGlyphRuns) {
- glyphCount += run.runSize();
- }
- return glyphCount;
- }
+ SkGlyphRunList(SkSpan<SkGlyphRun> glyphRuns, uint64_t uniqueID);
- SkPoint origin() const { return fOrigin; }
+ uint64_t uniqueID() const { return fUniqueID; }
auto begin() -> decltype(fGlyphRuns.begin()) { return fGlyphRuns.begin(); }
auto end() -> decltype(fGlyphRuns.end()) { return fGlyphRuns.end(); }
@@ -161,30 +122,6 @@ public:
auto operator [] (ptrdiff_t i) -> decltype(fGlyphRuns[i]) { return fGlyphRuns[i]; }
};
-class SkGlyphRunListIterator {
-public:
- explicit SkGlyphRunListIterator(SkGlyphRunList* list) : fList{*list} {}
-
- bool done() const { return fIndex == fList.size(); }
- void next() { fIndex += 1;}
- uint32_t glyphCount() const { return fList[fIndex].runSize(); }
- const uint16_t* glyphs() const { return fList[fIndex].shuntGlyphsIDs().data(); }
- const SkScalar* pos() const { return (const SkScalar*)fList[fIndex].positions().data(); }
- const SkPoint& offset() const { return fZero; }
- void applyFontToPaint(SkPaint* paint) const { *paint = fList[fIndex].paint(); }
- SkTextBlob::GlyphPositioning positioning() const { return SkTextBlob::kFull_Positioning; }
- const uint32_t* clusters() const { return fList[fIndex].clusters().data(); }
- uint32_t textSize() const { return fList[fIndex].text().size(); }
- const char* text() const { return fList[fIndex].text().data(); }
-
- bool isLCD() const { return fList[fIndex].paint().isLCDRenderText(); }
-
-private:
- static constexpr SkPoint fZero{0,0};
- ptrdiff_t fIndex{0};
- SkGlyphRunList& fList;
-};
-
// 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
@@ -217,14 +154,10 @@ 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, SkDrawFilter* filter);
+ void prepareTextBlob(const SkPaint& paint, const SkTextBlob& blob, SkPoint origin);
- void draw(SkBaseDevice* device);
-
- // Public for testing only.
- SkGlyphRun* useGlyphRun();
SkGlyphRunList* useGlyphRunList();
+ SkGlyphRun* useGlyphRun();
private:
size_t runSize() const;
@@ -232,27 +165,20 @@ private:
void initialize();
SkGlyphID* addDenseAndUnique(const SkPaint& paint, const void* bytes, size_t byteLength);
void addGlyphRunToList(
- const SkPaint& runPaint,
- SkGlyphID* temporaryShuntGlyphIDs,
- SkSpan<const char> text,
- SkSpan<const uint32_t> clusters);
+ SkGlyphID* temporaryShuntGlyphIDs, SkSpan<const char> text, SkSpan<uint32_t> clusters);
void drawText(
const SkPaint& paint, const void* bytes, size_t byteLength, SkPoint origin,
- SkSpan<const char> text, SkSpan<const uint32_t> clusters);
+ SkSpan<const char> text, SkSpan<uint32_t> clusters);
void drawPosTextH(
const SkPaint& paint, const void* bytes, size_t byteLength,
const SkScalar* xpos, SkScalar constY,
- SkSpan<const char> text, SkSpan<const uint32_t> clusters);
+ SkSpan<const char> text, SkSpan<uint32_t> clusters);
void drawPosText(
const SkPaint& paint, const void* bytes, size_t byteLength, const SkPoint* pos,
- SkSpan<const char> text, SkSpan<const uint32_t> clusters);
-
- const SkTextBlob* fTemporaryTextBlobShunt{nullptr};
+ SkSpan<const char> text, SkSpan<uint32_t> clusters);
- // The point passed into drawTextBlob. This allows the GPU back end to detect and adjust for
- // translations.
- SkPoint fOrigin;
+ uint64_t fUniqueID{0};
std::vector<uint16_t> fDenseIndex;
std::vector<SkPoint> fPositions;