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 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; | |
jvanverth1
2015/04/17 17:07:16
A suggestion to investigate for the future is to c
| |
117 }; | 122 }; |
118 | 123 |
119 class SubRunInfoArray { | 124 class SubRunInfoArray { |
120 public: | 125 public: |
121 SubRunInfoArray() | 126 SubRunInfoArray() |
122 : fSubRunCount(0) | 127 : fSubRunCount(0) |
123 , fSubRunAllocation(kMinSubRuns) { | 128 , fSubRunAllocation(kMinSubRuns) { |
129 SK_COMPILE_ASSERT(kMinSubRuns > 0, insufficient_subrun_alloc ation); | |
130 // We always seed with one here, so we can assume a valid su brun during | |
131 // push_back | |
124 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get()); | 132 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get()); |
125 this->push_back(); | 133 SkNEW_PLACEMENT(&fPtr[fSubRunCount++], SubRunInfo); |
134 } | |
135 ~SubRunInfoArray() { | |
136 for (int i = 0; i < fSubRunCount; i++) { | |
137 fPtr[i].~SubRunInfo(); | |
138 } | |
126 } | 139 } |
127 | 140 |
128 int count() const { return fSubRunCount; } | 141 int count() const { return fSubRunCount; } |
129 SubRunInfo& back() { return fPtr[fSubRunCount - 1]; } | 142 SubRunInfo& back() { return fPtr[fSubRunCount - 1]; } |
130 SubRunInfo& push_back() { | 143 SubRunInfo& push_back() { |
131 if (fSubRunCount >= fSubRunAllocation) { | 144 if (fSubRunCount >= fSubRunAllocation) { |
132 fSubRunAllocation = fSubRunAllocation << 1; | 145 fSubRunAllocation = fSubRunAllocation << 1; |
133 fSubRunStorage.realloc(fSubRunAllocation * sizeof(SubRun Info)); | 146 fSubRunStorage.realloc(fSubRunAllocation * sizeof(SubRun Info)); |
134 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get( )); | 147 fPtr = reinterpret_cast<SubRunInfo*>(fSubRunStorage.get( )); |
135 } | 148 } |
136 SkNEW_PLACEMENT(&fPtr[fSubRunCount], SubRunInfo); | 149 SkNEW_PLACEMENT(&fPtr[fSubRunCount], SubRunInfo); |
150 | |
151 // Forward glyph / vertex information to seed the new sub ru n | |
152 SubRunInfo& newSubRun = fPtr[fSubRunCount]; | |
153 SubRunInfo& prevSubRun = fPtr[fSubRunCount - 1]; | |
154 newSubRun.fGlyphStartIndex = prevSubRun.fGlyphEndIndex; | |
155 newSubRun.fGlyphEndIndex = prevSubRun.fGlyphEndIndex; | |
156 | |
157 newSubRun.fVertexStartIndex = prevSubRun.fVertexEndIndex; | |
158 newSubRun.fVertexEndIndex = prevSubRun.fVertexEndIndex; | |
137 return fPtr[fSubRunCount++]; | 159 return fPtr[fSubRunCount++]; |
138 } | 160 } |
139 SubRunInfo& operator[](int index) { | 161 SubRunInfo& operator[](int index) { |
140 return fPtr[index]; | 162 return fPtr[index]; |
141 } | 163 } |
142 const SubRunInfo& operator[](int index) const { | 164 const SubRunInfo& operator[](int index) const { |
143 return fPtr[index]; | 165 return fPtr[index]; |
144 } | 166 } |
145 | 167 |
146 private: | 168 private: |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 SkScalar transX, SkScalar transY); | 283 SkScalar transX, SkScalar transY); |
262 | 284 |
263 // We have to flush SkTextBlobs differently from drawText / drawPosText | 285 // We have to flush SkTextBlobs differently from drawText / drawPosText |
264 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget *, const SkPaint&, | 286 void flush(GrDrawTarget*, const SkTextBlob*, BitmapTextBlob*, GrRenderTarget *, const SkPaint&, |
265 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie wMatrix, | 287 const GrPaint&, SkDrawFilter*, const GrClip&, const SkMatrix& vie wMatrix, |
266 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans X, SkScalar transY); | 288 const SkIRect& clipBounds, SkScalar x, SkScalar y, SkScalar trans X, SkScalar transY); |
267 void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, | 289 void flush(GrDrawTarget*, BitmapTextBlob*, GrRenderTarget*, const SkPaint&, |
268 const GrPaint&, const GrClip&); | 290 const GrPaint&, const GrClip&); |
269 | 291 |
270 // A helper for drawing BitmapText in a run of distance fields | 292 // A helper for drawing BitmapText in a run of distance fields |
271 inline void fallbackDrawPosText(GrRenderTarget*, const GrClip&, | 293 inline void fallbackDrawPosText(BitmapTextBlob*, GrRenderTarget*, const GrCl ip&, |
272 const GrPaint&, | 294 const GrPaint&, |
273 const SkPaint&, const SkMatrix& viewMatrix, | 295 const SkPaint&, const SkMatrix& viewMatrix, |
274 const SkTDArray<char>& fallbackTxt, | 296 const SkTDArray<char>& fallbackTxt, |
275 const SkTDArray<SkScalar>& fallbackPos, | 297 const SkTDArray<SkScalar>& fallbackPos, |
276 int scalarsPerPosition, | 298 int scalarsPerPosition, |
277 const SkPoint& offset, | 299 const SkPoint& offset, |
278 const SkIRect& clipRect); | 300 const SkIRect& clipRect); |
279 | 301 |
280 void internalDrawBMPText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const SkPaint&, | 302 void internalDrawBMPText(BitmapTextBlob*, int runIndex, SkGlyphCache*, const SkPaint&, |
281 GrColor color, const SkMatrix& viewMatrix, | 303 GrColor color, const SkMatrix& viewMatrix, |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 bool fEnableDFRendering; | 365 bool fEnableDFRendering; |
344 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; | 366 SkAutoTUnref<DistanceAdjustTable> fDistanceAdjustTable; |
345 | 367 |
346 friend class GrTextBlobCache; | 368 friend class GrTextBlobCache; |
347 friend class BitmapTextBatch; | 369 friend class BitmapTextBatch; |
348 | 370 |
349 typedef GrTextContext INHERITED; | 371 typedef GrTextContext INHERITED; |
350 }; | 372 }; |
351 | 373 |
352 #endif | 374 #endif |
OLD | NEW |