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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 const SkPaint& skPaint, | 153 const SkPaint& skPaint, |
154 const SkMatrix* viewMatrix); | 154 const SkMatrix* viewMatrix); |
155 | 155 |
156 // Appends a glyph to the blob. If the glyph is too large, the glyph will b
e appended | 156 // Appends a glyph to the blob. If the glyph is too large, the glyph will b
e appended |
157 // as a path. | 157 // as a path. |
158 void appendGlyph(int runIndex, | 158 void appendGlyph(int runIndex, |
159 const SkRect& positions, | 159 const SkRect& positions, |
160 GrColor color, | 160 GrColor color, |
161 GrBatchTextStrike* strike, | 161 GrBatchTextStrike* strike, |
162 GrGlyph* glyph, | 162 GrGlyph* glyph, |
163 GrFontScaler* scaler, const SkGlyph& skGlyph, | 163 SkGlyphCache*, const SkGlyph& skGlyph, |
164 SkScalar x, SkScalar y, SkScalar scale, bool applyVM); | 164 SkScalar x, SkScalar y, SkScalar scale, bool applyVM); |
165 | 165 |
166 static size_t GetVertexStride(GrMaskFormat maskFormat) { | 166 static size_t GetVertexStride(GrMaskFormat maskFormat) { |
167 switch (maskFormat) { | 167 switch (maskFormat) { |
168 case kA8_GrMaskFormat: | 168 case kA8_GrMaskFormat: |
169 return kGrayTextVASize; | 169 return kGrayTextVASize; |
170 case kARGB_GrMaskFormat: | 170 case kARGB_GrMaskFormat: |
171 return kColorTextVASize; | 171 return kColorTextVASize; |
172 default: | 172 default: |
173 return kLCDTextVASize; | 173 return kLCDTextVASize; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 fPaintColor = color; | 251 fPaintColor = color; |
252 this->setupViewMatrix(viewMatrix, x, y); | 252 this->setupViewMatrix(viewMatrix, x, y); |
253 } | 253 } |
254 | 254 |
255 void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { | 255 void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
256 this->setupViewMatrix(viewMatrix, x, y); | 256 this->setupViewMatrix(viewMatrix, x, y); |
257 } | 257 } |
258 | 258 |
259 void regenInBatch(GrDrawBatch::Target* target, GrBatchFontCache* fontCache, | 259 void regenInBatch(GrDrawBatch::Target* target, GrBatchFontCache* fontCache, |
260 GrBlobRegenHelper *helper, int run, int subRun, SkGlyphCac
he** cache, | 260 GrBlobRegenHelper *helper, int run, int subRun, SkGlyphCac
he** cache, |
261 SkTypeface** typeface, GrFontScaler** scaler, | 261 SkTypeface** typeface, const SkDescriptor** desc, size_t v
ertexStride, |
262 const SkDescriptor** desc, size_t vertexStride, | |
263 const SkMatrix& viewMatrix, SkScalar x, SkScalar y, | 262 const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
264 GrColor color, | 263 GrColor color, |
265 void** vertices, size_t* byteCount, int* glyphCount); | 264 void** vertices, size_t* byteCount, int* glyphCount); |
266 | 265 |
267 const Key& key() const { return fKey; } | 266 const Key& key() const { return fKey; } |
268 | 267 |
269 ~GrAtlasTextBlob() { | 268 ~GrAtlasTextBlob() { |
270 for (int i = 0; i < fRunCount; i++) { | 269 for (int i = 0; i < fRunCount; i++) { |
271 fRuns[i].~Run(); | 270 fRuns[i].~Run(); |
272 } | 271 } |
273 } | 272 } |
274 | 273 |
275 ////////////////////////////////////////////////////////////////////////////
//////////////////// | 274 ////////////////////////////////////////////////////////////////////////////
//////////////////// |
276 // Internal test methods | 275 // Internal test methods |
277 GrDrawBatch* test_createBatch(int glyphCount, int run, int subRun, | 276 GrDrawBatch* test_createBatch(int glyphCount, int run, int subRun, |
278 const SkMatrix& viewMatrix, SkScalar x, SkScal
ar y, GrColor color, | 277 const SkMatrix& viewMatrix, SkScalar x, SkScal
ar y, GrColor color, |
279 const SkPaint& skPaint, const SkSurfaceProps&
props, | 278 const SkPaint& skPaint, const SkSurfaceProps&
props, |
280 const GrDistanceFieldAdjustTable* distanceAdju
stTable, | 279 const GrDistanceFieldAdjustTable* distanceAdju
stTable, |
281 GrBatchFontCache* cache); | 280 GrBatchFontCache* cache); |
282 | 281 |
283 private: | 282 private: |
284 GrAtlasTextBlob() | 283 GrAtlasTextBlob() |
285 : fMaxMinScale(-SK_ScalarMax) | 284 : fMaxMinScale(-SK_ScalarMax) |
286 , fMinMaxScale(SK_ScalarMax) | 285 , fMinMaxScale(SK_ScalarMax) |
287 , fTextType(0) {} | 286 , fTextType(0) {} |
288 | 287 |
289 void appendLargeGlyph(GrGlyph* glyph, GrFontScaler* scaler, const SkGlyph& s
kGlyph, | 288 void appendLargeGlyph(GrGlyph* glyph, SkGlyphCache* cache, const SkGlyph& sk
Glyph, |
290 SkScalar x, SkScalar y, SkScalar scale, bool applyVM); | 289 SkScalar x, SkScalar y, SkScalar scale, bool applyVM); |
291 | 290 |
292 inline void flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder,
const GrClip&, | 291 inline void flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBuilder,
const GrClip&, |
293 int run, const SkMatrix& viewMatrix, SkScalar x, SkScal
ar y, GrColor color, | 292 int run, const SkMatrix& viewMatrix, SkScalar x, SkScal
ar y, GrColor color, |
294 const SkPaint& skPaint, const SkSurfaceProps& props, | 293 const SkPaint& skPaint, const SkSurfaceProps& props, |
295 const GrDistanceFieldAdjustTable* distanceAdjustTable, | 294 const GrDistanceFieldAdjustTable* distanceAdjustTable, |
296 GrBatchFontCache* cache); | 295 GrBatchFontCache* cache); |
297 | 296 |
298 void flushBigGlyphs(GrContext* context, GrDrawContext* dc, | 297 void flushBigGlyphs(GrContext* context, GrDrawContext* dc, |
299 const GrClip& clip, const SkPaint& skPaint, | 298 const GrClip& clip, const SkPaint& skPaint, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df properties | 483 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df properties |
485 bool fInitialized; | 484 bool fInitialized; |
486 bool fDrawAsPaths; | 485 bool fDrawAsPaths; |
487 }; | 486 }; |
488 | 487 |
489 template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyph
s> | 488 template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyph
s> |
490 void regenInBatch(GrDrawBatch::Target* target, | 489 void regenInBatch(GrDrawBatch::Target* target, |
491 GrBatchFontCache* fontCache, | 490 GrBatchFontCache* fontCache, |
492 GrBlobRegenHelper* helper, | 491 GrBlobRegenHelper* helper, |
493 Run* run, Run::SubRunInfo* info, SkGlyphCache** cache, | 492 Run* run, Run::SubRunInfo* info, SkGlyphCache** cache, |
494 SkTypeface** typeface, GrFontScaler** scaler, | 493 SkTypeface** typeface, const SkDescriptor** desc, |
495 const SkDescriptor** desc, | |
496 int glyphCount, size_t vertexStride, | 494 int glyphCount, size_t vertexStride, |
497 GrColor color, SkScalar transX, | 495 GrColor color, SkScalar transX, |
498 SkScalar transY) const; | 496 SkScalar transY) const; |
499 | 497 |
500 inline GrDrawBatch* createBatch(const Run::SubRunInfo& info, | 498 inline GrDrawBatch* createBatch(const Run::SubRunInfo& info, |
501 int glyphCount, int run, int subRun, | 499 int glyphCount, int run, int subRun, |
502 const SkMatrix& viewMatrix, SkScalar x, SkSc
alar y, | 500 const SkMatrix& viewMatrix, SkScalar x, SkSc
alar y, |
503 GrColor color, | 501 GrColor color, |
504 const SkPaint& skPaint, const SkSurfaceProps
& props, | 502 const SkPaint& skPaint, const SkSurfaceProps
& props, |
505 const GrDistanceFieldAdjustTable* distanceAd
justTable, | 503 const GrDistanceFieldAdjustTable* distanceAd
justTable, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 // We can reuse distance field text, but only if the new viewmatrix would no
t result in | 548 // We can reuse distance field text, but only if the new viewmatrix would no
t result in |
551 // a mip change. Because there can be multiple runs in a blob, we track the
overall | 549 // a mip change. Because there can be multiple runs in a blob, we track the
overall |
552 // maximum minimum scale, and minimum maximum scale, we can support before w
e need to regen | 550 // maximum minimum scale, and minimum maximum scale, we can support before w
e need to regen |
553 SkScalar fMaxMinScale; | 551 SkScalar fMaxMinScale; |
554 SkScalar fMinMaxScale; | 552 SkScalar fMinMaxScale; |
555 int fRunCount; | 553 int fRunCount; |
556 uint8_t fTextType; | 554 uint8_t fTextType; |
557 }; | 555 }; |
558 | 556 |
559 #endif | 557 #endif |
OLD | NEW |