OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrAtlasTextBlob_DEFINED | 8 #ifndef GrAtlasTextBlob_DEFINED |
9 #define GrAtlasTextBlob_DEFINED | 9 #define GrAtlasTextBlob_DEFINED |
10 | 10 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 , fAtlasGeneration(that.fAtlasGeneration) | 86 , fAtlasGeneration(that.fAtlasGeneration) |
87 , fVertexStartIndex(that.fVertexStartIndex) | 87 , fVertexStartIndex(that.fVertexStartIndex) |
88 , fVertexEndIndex(that.fVertexEndIndex) | 88 , fVertexEndIndex(that.fVertexEndIndex) |
89 , fGlyphStartIndex(that.fGlyphStartIndex) | 89 , fGlyphStartIndex(that.fGlyphStartIndex) |
90 , fGlyphEndIndex(that.fGlyphEndIndex) | 90 , fGlyphEndIndex(that.fGlyphEndIndex) |
91 , fMaskFormat(that.fMaskFormat) | 91 , fMaskFormat(that.fMaskFormat) |
92 , fDrawAsDistanceFields(that.fDrawAsDistanceFields) | 92 , fDrawAsDistanceFields(that.fDrawAsDistanceFields) |
93 , fUseLCDText(that.fUseLCDText) { | 93 , fUseLCDText(that.fUseLCDText) { |
94 } | 94 } |
95 | 95 |
| 96 // TODO when this object is more internal, drop the privacy |
96 void resetBulkUseToken() { fBulkUseToken.reset(); } | 97 void resetBulkUseToken() { fBulkUseToken.reset(); } |
97 GrBatchAtlas::BulkUseTokenUpdater* bulkUseToken() { return &fBulkUse
Token; } | 98 GrBatchAtlas::BulkUseTokenUpdater* bulkUseToken() { return &fBulkUse
Token; } |
98 void setStrike(GrBatchTextStrike* strike) { fStrike.reset(SkRef(stri
ke)); } | 99 void setStrike(GrBatchTextStrike* strike) { fStrike.reset(SkRef(stri
ke)); } |
99 GrBatchTextStrike* strike() const { return fStrike.get(); } | 100 GrBatchTextStrike* strike() const { return fStrike.get(); } |
100 | 101 |
101 void setAtlasGeneration(uint64_t atlasGeneration) { fAtlasGeneration
= atlasGeneration;} | 102 void setAtlasGeneration(uint64_t atlasGeneration) { fAtlasGeneration
= atlasGeneration;} |
102 uint64_t atlasGeneration() const { return fAtlasGeneration; } | 103 uint64_t atlasGeneration() const { return fAtlasGeneration; } |
103 | 104 |
104 size_t byteCount() const { return fVertexEndIndex - fVertexStartInde
x; } | 105 size_t byteCount() const { return fVertexEndIndex - fVertexStartInde
x; } |
105 void setVertexStartIndex(size_t vertStartIndex) { fVertexStartIndex
= vertStartIndex;} | |
106 size_t vertexStartIndex() const { return fVertexStartIndex; } | 106 size_t vertexStartIndex() const { return fVertexStartIndex; } |
107 void setVertexEndIndex(size_t vertEndIndex) { fVertexEndIndex = vert
EndIndex; } | |
108 size_t vertexEndIndex() const { return fVertexEndIndex; } | 107 size_t vertexEndIndex() const { return fVertexEndIndex; } |
109 void appendVertices(size_t vertexStride) { | 108 void appendVertices(size_t vertexStride) { |
110 fVertexEndIndex += vertexStride * kVerticesPerGlyph; | 109 fVertexEndIndex += vertexStride * kVerticesPerGlyph; |
111 } | 110 } |
112 | 111 |
113 uint32_t glyphCount() const { return fGlyphEndIndex - fGlyphStartInd
ex; } | 112 uint32_t glyphCount() const { return fGlyphEndIndex - fGlyphStartInd
ex; } |
114 void setGlyphStartIndex(uint32_t glyphStartIndex) { fGlyphStartIndex
= glyphStartIndex;} | |
115 uint32_t glyphStartIndex() const { return fGlyphStartIndex; } | 113 uint32_t glyphStartIndex() const { return fGlyphStartIndex; } |
116 void setGlyphEndIndex(uint32_t glyphEndIndex) { fGlyphEndIndex = gly
phEndIndex; } | |
117 uint32_t glyphEndIndex() const { return fGlyphEndIndex; } | 114 uint32_t glyphEndIndex() const { return fGlyphEndIndex; } |
118 void glyphAppended() { fGlyphEndIndex++; } | 115 void glyphAppended() { fGlyphEndIndex++; } |
119 void setMaskFormat(GrMaskFormat format) { fMaskFormat = format; } | 116 void setMaskFormat(GrMaskFormat format) { fMaskFormat = format; } |
120 GrMaskFormat maskFormat() const { return fMaskFormat; } | 117 GrMaskFormat maskFormat() const { return fMaskFormat; } |
121 | 118 |
| 119 void setAsSuccessor(const SubRunInfo& prev) { |
| 120 fGlyphStartIndex = prev.glyphEndIndex(); |
| 121 fGlyphEndIndex = prev.glyphEndIndex(); |
| 122 |
| 123 fVertexStartIndex = prev.vertexEndIndex(); |
| 124 fVertexEndIndex = prev.vertexEndIndex(); |
| 125 } |
| 126 |
122 // df properties | 127 // df properties |
123 void setUseLCDText(bool useLCDText) { fUseLCDText = useLCDText; } | 128 void setUseLCDText(bool useLCDText) { fUseLCDText = useLCDText; } |
124 bool hasUseLCDText() const { return fUseLCDText; } | 129 bool hasUseLCDText() const { return fUseLCDText; } |
125 void setDrawAsDistanceFields() { fDrawAsDistanceFields = true; } | 130 void setDrawAsDistanceFields() { fDrawAsDistanceFields = true; } |
126 bool drawAsDistanceFields() const { return fDrawAsDistanceFields; } | 131 bool drawAsDistanceFields() const { return fDrawAsDistanceFields; } |
127 | 132 |
128 private: | 133 private: |
129 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; | 134 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; |
130 SkAutoTUnref<GrBatchTextStrike> fStrike; | 135 SkAutoTUnref<GrBatchTextStrike> fStrike; |
131 uint64_t fAtlasGeneration; | 136 uint64_t fAtlasGeneration; |
132 size_t fVertexStartIndex; | 137 size_t fVertexStartIndex; |
133 size_t fVertexEndIndex; | 138 size_t fVertexEndIndex; |
134 uint32_t fGlyphStartIndex; | 139 uint32_t fGlyphStartIndex; |
135 uint32_t fGlyphEndIndex; | 140 uint32_t fGlyphEndIndex; |
136 GrMaskFormat fMaskFormat; | 141 GrMaskFormat fMaskFormat; |
137 bool fDrawAsDistanceFields; // df property | 142 bool fDrawAsDistanceFields; // df property |
138 bool fUseLCDText; // df property | 143 bool fUseLCDText; // df property |
139 }; | 144 }; |
140 | 145 |
141 SubRunInfo& push_back() { | 146 SubRunInfo& push_back() { |
142 // Forward glyph / vertex information to seed the new sub run | 147 // Forward glyph / vertex information to seed the new sub run |
143 SubRunInfo& newSubRun = fSubRunInfo.push_back(); | 148 SubRunInfo& newSubRun = fSubRunInfo.push_back(); |
144 SubRunInfo& prevSubRun = fSubRunInfo.fromBack(1); | 149 const SubRunInfo& prevSubRun = fSubRunInfo.fromBack(1); |
145 | 150 |
146 newSubRun.setGlyphStartIndex(prevSubRun.glyphEndIndex()); | 151 newSubRun.setAsSuccessor(prevSubRun); |
147 newSubRun.setGlyphEndIndex(prevSubRun.glyphEndIndex()); | |
148 | |
149 newSubRun.setVertexStartIndex(prevSubRun.vertexEndIndex()); | |
150 newSubRun.setVertexEndIndex(prevSubRun.vertexEndIndex()); | |
151 return newSubRun; | 152 return newSubRun; |
152 } | 153 } |
153 static const int kMinSubRuns = 1; | 154 static const int kMinSubRuns = 1; |
154 SkAutoTUnref<SkTypeface> fTypeface; | 155 SkAutoTUnref<SkTypeface> fTypeface; |
155 SkRect fVertexBounds; | 156 SkRect fVertexBounds; |
156 SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo; | 157 SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo; |
157 SkAutoDescriptor fDescriptor; | 158 SkAutoDescriptor fDescriptor; |
158 | 159 |
159 // Distance field text cannot draw coloremoji, and so has to fall back.
However, | 160 // Distance field text cannot draw coloremoji, and so has to fall back.
However, |
160 // though the distance field text and the coloremoji may share the same
run, they | 161 // though the distance field text and the coloremoji may share the same
run, they |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 263 |
263 void* operator new(size_t, void* p) { return p; } | 264 void* operator new(size_t, void* p) { return p; } |
264 void operator delete(void* target, void* placement) { | 265 void operator delete(void* target, void* placement) { |
265 ::operator delete(target, placement); | 266 ::operator delete(target, placement); |
266 } | 267 } |
267 | 268 |
268 bool hasDistanceField() const { return SkToBool(fTextType & kHasDistanceFiel
d_TextType); } | 269 bool hasDistanceField() const { return SkToBool(fTextType & kHasDistanceFiel
d_TextType); } |
269 bool hasBitmap() const { return SkToBool(fTextType & kHasBitmap_TextType); } | 270 bool hasBitmap() const { return SkToBool(fTextType & kHasBitmap_TextType); } |
270 void setHasDistanceField() { fTextType |= kHasDistanceField_TextType; } | 271 void setHasDistanceField() { fTextType |= kHasDistanceField_TextType; } |
271 void setHasBitmap() { fTextType |= kHasBitmap_TextType; } | 272 void setHasBitmap() { fTextType |= kHasBitmap_TextType; } |
272 void appendGlyph(Run::SubRunInfo* subrun, GrGlyph* glyph) { | 273 |
273 this->fGlyphs[subrun->glyphEndIndex()] = glyph; | 274 void push_back_run(int currRun) { |
274 subrun->glyphAppended(); | 275 SkASSERT(currRun < fRunCount); |
| 276 if (currRun > 0) { |
| 277 Run::SubRunInfo& newRun = fRuns[currRun].fSubRunInfo.back(); |
| 278 Run::SubRunInfo& lastRun = fRuns[currRun - 1].fSubRunInfo.back(); |
| 279 newRun.setAsSuccessor(lastRun); |
| 280 } |
275 } | 281 } |
276 | 282 |
| 283 void appendGlyph(Run* run, |
| 284 Run::SubRunInfo* subRun, |
| 285 const SkRect& positions, GrColor color, |
| 286 size_t vertexStride, bool useVertexColor, |
| 287 GrGlyph* glyph); |
| 288 |
277 static const int kVerticesPerGlyph = 4; | 289 static const int kVerticesPerGlyph = 4; |
278 | 290 |
279 #ifdef CACHE_SANITY_CHECK | 291 #ifdef CACHE_SANITY_CHECK |
280 static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); | 292 static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); |
281 size_t fSize; | 293 size_t fSize; |
282 #endif | 294 #endif |
283 }; | 295 }; |
284 | 296 |
285 #endif | 297 #endif |
OLD | NEW |