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 |
11 #include "GrBatchAtlas.h" | 11 #include "GrBatchAtlas.h" |
12 #include "GrBatchFontCache.h" | 12 #include "GrBatchFontCache.h" |
13 #include "GrColor.h" | 13 #include "GrColor.h" |
14 #include "GrMemoryPool.h" | 14 #include "GrMemoryPool.h" |
15 #include "SkDescriptor.h" | 15 #include "SkDescriptor.h" |
16 #include "SkMaskFilter.h" | 16 #include "SkMaskFilter.h" |
17 #include "SkSurfaceProps.h" | 17 #include "SkSurfaceProps.h" |
18 #include "SkTInternalLList.h" | 18 #include "SkTInternalLList.h" |
19 | 19 |
20 struct GrDistanceFieldAdjustTable; | 20 struct GrDistanceFieldAdjustTable; |
21 class GrTextContext; | 21 class GrTextContext; |
22 class SkDrawFilter; | 22 class SkDrawFilter; |
23 class SkTextBlob; | 23 class SkTextBlob; |
24 class SkTextBlobRunIterator; | 24 class SkTextBlobRunIterator; |
25 | 25 |
26 // With this flag enabled, the GrAtlasTextContext will, as a sanity check, regen
erate every blob | 26 // With this flag enabled, the GrAtlasTextContext will, as a sanity check, regen
erate every blob |
27 // that comes in to verify the integrity of its cache | 27 // that comes in to verify the integrity of its cache |
28 //#define CACHE_SANITY_CHECK // VERY SLOW | 28 #define CACHE_SANITY_CHECK 0 |
29 | 29 |
30 /* | 30 /* |
31 * A GrAtlasTextBlob contains a fully processed SkTextBlob, suitable for nearly
immediate drawing | 31 * A GrAtlasTextBlob contains a fully processed SkTextBlob, suitable for nearly
immediate drawing |
32 * on the GPU. These are initially created with valid positions and colors, but
invalid | 32 * on the GPU. These are initially created with valid positions and colors, but
invalid |
33 * texture coordinates. The GrAtlasTextBlob itself has a few Blob-wide properti
es, and also | 33 * texture coordinates. The GrAtlasTextBlob itself has a few Blob-wide properti
es, and also |
34 * consists of a number of runs. Runs inside a blob are flushed individually so
they can be | 34 * consists of a number of runs. Runs inside a blob are flushed individually so
they can be |
35 * reordered. | 35 * reordered. |
36 * | 36 * |
37 * The only thing(aside from a memcopy) required to flush a GrAtlasTextBlob is t
o ensure that | 37 * The only thing(aside from a memcopy) required to flush a GrAtlasTextBlob is t
o ensure that |
38 * the GrAtlas will not evict anything the Blob needs. | 38 * the GrAtlas will not evict anything the Blob needs. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 const GrPaint& grPaint, | 193 const GrPaint& grPaint, |
194 const GrClip& clip, | 194 const GrClip& clip, |
195 const SkIRect& clipBounds); | 195 const SkIRect& clipBounds); |
196 | 196 |
197 // position + local coord | 197 // position + local coord |
198 static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16); | 198 static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16); |
199 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + si
zeof(SkIPoint16); | 199 static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + si
zeof(SkIPoint16); |
200 static const size_t kLCDTextVASize = kGrayTextVASize; | 200 static const size_t kLCDTextVASize = kGrayTextVASize; |
201 static const int kVerticesPerGlyph = 4; | 201 static const int kVerticesPerGlyph = 4; |
202 | 202 |
203 #ifdef CACHE_SANITY_CHECK | |
204 static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); | 203 static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); |
205 size_t fSize; | |
206 #endif | |
207 | 204 |
208 // The color here is the GrPaint color, and it is used to determine whether
we | 205 // The color here is the GrPaint color, and it is used to determine whether
we |
209 // have to regenerate LCD text blobs. | 206 // have to regenerate LCD text blobs. |
210 // We use this color vs the SkPaint color because it has the colorfilter app
lied. | 207 // We use this color vs the SkPaint color because it has the colorfilter app
lied. |
211 void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x,
SkScalar y) { | 208 void initReusableBlob(GrColor color, const SkMatrix& viewMatrix, SkScalar x,
SkScalar y) { |
212 fPaintColor = color; | 209 fPaintColor = color; |
213 this->setupViewMatrix(viewMatrix, x, y); | 210 this->setupViewMatrix(viewMatrix, x, y); |
214 } | 211 } |
215 | 212 |
216 void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { | 213 void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 unsigned char* fVertices; | 433 unsigned char* fVertices; |
437 GrGlyph** fGlyphs; | 434 GrGlyph** fGlyphs; |
438 Run* fRuns; | 435 Run* fRuns; |
439 GrMemoryPool* fPool; | 436 GrMemoryPool* fPool; |
440 SkMaskFilter::BlurRec fBlurRec; | 437 SkMaskFilter::BlurRec fBlurRec; |
441 StrokeInfo fStrokeInfo; | 438 StrokeInfo fStrokeInfo; |
442 SkTArray<BigGlyph> fBigGlyphs; | 439 SkTArray<BigGlyph> fBigGlyphs; |
443 Key fKey; | 440 Key fKey; |
444 SkMatrix fViewMatrix; | 441 SkMatrix fViewMatrix; |
445 SkMatrix fInitialViewMatrixInverse; | 442 SkMatrix fInitialViewMatrixInverse; |
| 443 size_t fSize; |
446 GrColor fPaintColor; | 444 GrColor fPaintColor; |
447 SkScalar fInitialX; | 445 SkScalar fInitialX; |
448 SkScalar fInitialY; | 446 SkScalar fInitialY; |
449 SkScalar fX; | 447 SkScalar fX; |
450 SkScalar fY; | 448 SkScalar fY; |
451 | 449 |
452 // We can reuse distance field text, but only if the new viewmatrix would no
t result in | 450 // We can reuse distance field text, but only if the new viewmatrix would no
t result in |
453 // a mip change. Because there can be multiple runs in a blob, we track the
overall | 451 // a mip change. Because there can be multiple runs in a blob, we track the
overall |
454 // maximum minimum scale, and minimum maximum scale, we can support before w
e need to regen | 452 // maximum minimum scale, and minimum maximum scale, we can support before w
e need to regen |
455 SkScalar fMaxMinScale; | 453 SkScalar fMaxMinScale; |
456 SkScalar fMinMaxScale; | 454 SkScalar fMinMaxScale; |
457 int fRunCount; | 455 int fRunCount; |
458 uint8_t fTextType; | 456 uint8_t fTextType; |
459 | 457 |
460 friend class GrAtlasTextBatch; // We might be able to get rid of this friend
ing | 458 friend class GrAtlasTextBatch; // We might be able to get rid of this friend
ing |
461 friend class GrTextBlobCache; // Needs to access the key | 459 friend class GrTextBlobCache; // Needs to access the key |
462 }; | 460 }; |
463 | 461 |
464 #endif | 462 #endif |
OLD | NEW |