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 GrAtlasTextContext_DEFINED | 8 #ifndef GrAtlasTextContext_DEFINED |
9 #define GrAtlasTextContext_DEFINED | 9 #define GrAtlasTextContext_DEFINED |
10 | 10 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 uint64_t fAtlasGeneration; | 107 uint64_t fAtlasGeneration; |
108 uint32_t fGlyphStartIndex; | 108 uint32_t fGlyphStartIndex; |
109 uint32_t fGlyphEndIndex; | 109 uint32_t fGlyphEndIndex; |
110 size_t fVertexStartIndex; | 110 size_t fVertexStartIndex; |
111 size_t fVertexEndIndex; | 111 size_t fVertexEndIndex; |
112 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; | 112 GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken; |
113 | 113 |
114 // distance field properties | 114 // distance field properties |
115 bool fDrawAsDistanceFields; | 115 bool fDrawAsDistanceFields; |
116 bool fUseLCDText; | 116 bool fUseLCDText; |
| 117 // Distance field text cannot draw coloremoji, and so has to fal
l back. However, |
| 118 // though the distance field text and the coloremoji may share t
he same run, they |
| 119 // will have different descriptors. If fOverrideDescriptor is n
on-NULL, then it |
| 120 // will be used in place of the run's descriptor to regen textur
e coords |
| 121 // TODO we could have a descriptor cache, it would reduce the si
ze of these blobs |
| 122 // significantly, and then the subrun could just have a refed po
inter to the |
| 123 // correct descriptor. |
| 124 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; |
117 }; | 125 }; |
118 | 126 |
119 class SubRunInfoArray { | 127 class SubRunInfoArray { |
120 public: | 128 public: |
121 SubRunInfoArray() | 129 SubRunInfoArray() |
122 : fSubRunCount(0) | 130 : fSubRunCount(0) |
123 , fSubRunAllocation(kMinSubRuns) { | 131 , fSubRunAllocation(kMinSubRuns) { |
| 132 SK_COMPILE_ASSERT(kMinSubRuns > 0, insufficient_subrun_alloc
ation); |
| 133 // We always seed with one here, so we can assume a valid su
brun during |
| 134 // push_back |
124 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get()); | 135 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get()); |
125 this->push_back(); | 136 SkNEW_PLACEMENT(&fPtr[fSubRunCount++], SubRunInfo); |
| 137 } |
| 138 ~SubRunInfoArray() { |
| 139 for (int i = 0; i < fSubRunCount; i++) { |
| 140 fPtr[i].~SubRunInfo(); |
| 141 } |
126 } | 142 } |
127 | 143 |
128 int count() const { return fSubRunCount; } | 144 int count() const { return fSubRunCount; } |
129 SubRunInfo& back() { return fPtr[fSubRunCount - 1]; } | 145 SubRunInfo& back() { return fPtr[fSubRunCount - 1]; } |
130 SubRunInfo& push_back() { | 146 SubRunInfo& push_back() { |
131 if (fSubRunCount >= fSubRunAllocation) { | 147 if (fSubRunCount >= fSubRunAllocation) { |
132 fSubRunAllocation = fSubRunAllocation << 1; | 148 fSubRunAllocation = fSubRunAllocation << 1; |
133 fSubRunStorage.realloc(fSubRunAllocation * sizeof(SubRun
Info)); | 149 fSubRunStorage.realloc(fSubRunAllocation * sizeof(SubRun
Info)); |
134 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get(
)); | 150 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get(
)); |
135 } | 151 } |
136 SkNEW_PLACEMENT(&fPtr[fSubRunCount], SubRunInfo); | 152 SkNEW_PLACEMENT(&fPtr[fSubRunCount], SubRunInfo); |
| 153 |
| 154 // Forward glyph / vertex information to seed the new sub ru
n |
| 155 SubRunInfo& newSubRun = fPtr[fSubRunCount]; |
| 156 SubRunInfo& prevSubRun = fPtr[fSubRunCount - 1]; |
| 157 newSubRun.fGlyphStartIndex = prevSubRun.fGlyphEndIndex; |
| 158 newSubRun.fGlyphEndIndex = prevSubRun.fGlyphEndIndex; |
| 159 |
| 160 newSubRun.fVertexStartIndex = prevSubRun.fVertexEndIndex; |
| 161 newSubRun.fVertexEndIndex = prevSubRun.fVertexEndIndex; |
137 return fPtr[fSubRunCount++]; | 162 return fPtr[fSubRunCount++]; |
138 } | 163 } |
139 SubRunInfo& operator[](int index) { | 164 SubRunInfo& operator[](int index) { |
140 return fPtr[index]; | 165 return fPtr[index]; |
141 } | 166 } |
142 const SubRunInfo& operator[](int index) const { | 167 const SubRunInfo& operator[](int index) const { |
143 return fPtr[index]; | 168 return fPtr[index]; |
144 } | 169 } |
145 | 170 |
146 private: | 171 private: |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 SkScalar transX, SkScalar transY); | 286 SkScalar transX, SkScalar transY); |
262 | 287 |
263 // We have to flush SkTextBlobs differently from drawText / drawPosText | 288 // We have to flush SkTextBlobs differently from drawText / drawPosText |
264 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget
*, const SkPaint&, | 289 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget
*, const SkPaint&, |
265 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie
wMatrix, | 290 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie
wMatrix, |
266 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans
X, SkScalar transY); | 291 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans
X, SkScalar transY); |
267 void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, | 292 void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, |
268 const GrPaint&, const GrClip&); | 293 const GrPaint&, const GrClip&); |
269 | 294 |
270 // A helper for drawing BitmapText in a run of distance fields | 295 // A helper for drawing BitmapText in a run of distance fields |
271 inline void fallbackDrawPosText(GrRenderTarget*, const GrClip&, | 296 inline void fallbackDrawPosText(BitmapTextBlob*, GrRenderTarget*, const GrCl
ip&, |
272 const GrPaint&, | 297 const GrPaint&, |
273 const SkPaint&, const SkMatrix& viewMatrix, | 298 const SkPaint&, const SkMatrix& viewMatrix, |
274 const SkTDArray<char>& fallbackTxt, | 299 const SkTDArray<char>& fallbackTxt, |
275 const SkTDArray<SkScalar>& fallbackPos, | 300 const SkTDArray<SkScalar>& fallbackPos, |
276 int scalarsPerPosition, | 301 int scalarsPerPosition, |
277 const SkPoint& offset, | 302 const SkPoint& offset, |
278 const SkIRect& clipRect); | 303 const SkIRect& clipRect); |
279 | 304 |
280 void internalDrawBMPText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const
SkPaint&, | 305 void internalDrawBMPText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const
SkPaint&, |
281 GrColor color, const SkMatrix& viewMatrix, | 306 GrColor color, const SkMatrix& viewMatrix, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 bool fEnableDFRendering; | 368 bool fEnableDFRendering; |
344 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; | 369 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; |
345 | 370 |
346 friend class GrTextBlobCache; | 371 friend class GrTextBlobCache; |
347 friend class BitmapTextBatch; | 372 friend class BitmapTextBatch; |
348 | 373 |
349 typedef GrTextContext INHERITED; | 374 typedef GrTextContext INHERITED; |
350 }; | 375 }; |
351 | 376 |
352 #endif | 377 #endif |
OLD | NEW |