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 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 // We use this color vs the SkPaint color because it has the colorfilter app
lied. | 249 // We use this color vs the SkPaint color because it has the colorfilter app
lied. |
250 void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x,
SkScalar y) { | 250 void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x,
SkScalar y) { |
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 /** |
| 260 * Consecutive calls to regenInBatch often use the same SkGlyphCache. If the
same instance of |
| 261 * this object is passed to multiple calls to regenInBatch then it can save
the cost of multiple |
| 262 * detach/attach operations of SkGlyphCache. |
| 263 */ |
| 264 class LazyGlyphCache; |
| 265 |
259 void regenInBatch(GrDrawBatch::Target* target, GrBatchFontCache* fontCache, | 266 void regenInBatch(GrDrawBatch::Target* target, GrBatchFontCache* fontCache, |
260 GrBlobRegenHelper *helper, int run, int subRun, SkGlyphCac
he** cache, | 267 GrBlobRegenHelper *helper, int run, int subRun, LazyGlyphC
ache*, |
261 SkTypeface** typeface, const SkDescriptor** desc, size_t v
ertexStride, | 268 size_t vertexStride, const SkMatrix& viewMatrix, SkScalar
x, SkScalar y, |
262 const SkMatrix& viewMatrix, SkScalar x, SkScalar y, | 269 GrColor color, void** vertices, size_t* byteCount, int* gl
yphCount); |
263 GrColor color, | |
264 void** vertices, size_t* byteCount, int* glyphCount); | |
265 | 270 |
266 const Key& key() const { return fKey; } | 271 const Key& key() const { return fKey; } |
267 | 272 |
268 ~GrAtlasTextBlob() { | 273 ~GrAtlasTextBlob() { |
269 for (int i = 0; i < fRunCount; i++) { | 274 for (int i = 0; i < fRunCount; i++) { |
270 fRuns[i].~Run(); | 275 fRuns[i].~Run(); |
271 } | 276 } |
272 } | 277 } |
273 | 278 |
274 ////////////////////////////////////////////////////////////////////////////
//////////////////// | 279 ////////////////////////////////////////////////////////////////////////////
//////////////////// |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 // will be used in place of the run's descriptor to regen texture coords | 487 // will be used in place of the run's descriptor to regen texture coords |
483 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df properties | 488 SkAutoTDelete<SkAutoDescriptor> fOverrideDescriptor; // df properties |
484 bool fInitialized; | 489 bool fInitialized; |
485 bool fDrawAsPaths; | 490 bool fDrawAsPaths; |
486 }; | 491 }; |
487 | 492 |
488 template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyph
s> | 493 template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyph
s> |
489 void regenInBatch(GrDrawBatch::Target* target, | 494 void regenInBatch(GrDrawBatch::Target* target, |
490 GrBatchFontCache* fontCache, | 495 GrBatchFontCache* fontCache, |
491 GrBlobRegenHelper* helper, | 496 GrBlobRegenHelper* helper, |
492 Run* run, Run::SubRunInfo* info, SkGlyphCache** cache, | 497 Run* run, Run::SubRunInfo* info, |
493 SkTypeface** typeface, const SkDescriptor** desc, | 498 LazyGlyphCache*, int glyphCount, |
494 int glyphCount, size_t vertexStride, | 499 size_t vertexStride, |
495 GrColor color, SkScalar transX, | 500 GrColor color, SkScalar transX, |
496 SkScalar transY) const; | 501 SkScalar transY) const; |
497 | 502 |
498 inline GrDrawBatch* createBatch(const Run::SubRunInfo& info, | 503 inline GrDrawBatch* createBatch(const Run::SubRunInfo& info, |
499 int glyphCount, int run, int subRun, | 504 int glyphCount, int run, int subRun, |
500 const SkMatrix& viewMatrix, SkScalar x, SkSc
alar y, | 505 const SkMatrix& viewMatrix, SkScalar x, SkSc
alar y, |
501 GrColor color, | 506 GrColor color, |
502 const SkPaint& skPaint, const SkSurfaceProps
& props, | 507 const SkPaint& skPaint, const SkSurfaceProps
& props, |
503 const GrDistanceFieldAdjustTable* distanceAd
justTable, | 508 const GrDistanceFieldAdjustTable* distanceAd
justTable, |
504 bool useGammaCorrectDistanceTable, | 509 bool useGammaCorrectDistanceTable, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 552 |
548 // We can reuse distance field text, but only if the new viewmatrix would no
t result in | 553 // We can reuse distance field text, but only if the new viewmatrix would no
t result in |
549 // a mip change. Because there can be multiple runs in a blob, we track the
overall | 554 // a mip change. Because there can be multiple runs in a blob, we track the
overall |
550 // maximum minimum scale, and minimum maximum scale, we can support before w
e need to regen | 555 // maximum minimum scale, and minimum maximum scale, we can support before w
e need to regen |
551 SkScalar fMaxMinScale; | 556 SkScalar fMaxMinScale; |
552 SkScalar fMinMaxScale; | 557 SkScalar fMinMaxScale; |
553 int fRunCount; | 558 int fRunCount; |
554 uint8_t fTextType; | 559 uint8_t fTextType; |
555 }; | 560 }; |
556 | 561 |
| 562 class GrAtlasTextBlob::LazyGlyphCache { |
| 563 public: |
| 564 SkGlyphCache* cache() const { return fCache.get(); } |
| 565 |
| 566 void initIfNecessary(Run*, Run::SubRunInfo*); |
| 567 private: |
| 568 SkAutoGlyphCache fCache; |
| 569 const SkTypeface* fTypeface = nullptr; |
| 570 }; |
| 571 |
557 #endif | 572 #endif |
OLD | NEW |