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 GrTextBlobCache_DEFINED | 8 #ifndef GrTextBlobCache_DEFINED |
9 #define GrTextBlobCache_DEFINED | 9 #define GrTextBlobCache_DEFINED |
10 | 10 |
11 #include "GrAtlasTextContext.h" | 11 #include "GrAtlasTextContext.h" |
12 #include "SkTDynamicHash.h" | 12 #include "SkTDynamicHash.h" |
13 #include "SkTextBlob.h" | 13 #include "SkTextBlob.h" |
14 | 14 |
15 class GrTextBlobCache { | 15 class GrTextBlobCache { |
16 public: | 16 public: |
17 typedef GrAtlasTextContext::BitmapTextBlob BitmapTextBlob; | 17 typedef GrAtlasTextContext::BitmapTextBlob BitmapTextBlob; |
18 | 18 |
19 GrTextBlobCache() : fPool(kPreAllocSize, kMinGrowthSize) {} | 19 GrTextBlobCache() : fPool(kPreAllocSize, kMinGrowthSize) {} |
20 ~GrTextBlobCache(); | 20 ~GrTextBlobCache(); |
21 | 21 |
22 // creates an uncached blob | 22 // creates an uncached blob |
23 BitmapTextBlob* createBlob(int glyphCount, int runCount, size_t maxVASize); | 23 BitmapTextBlob* createBlob(int glyphCount, int runCount, size_t maxVASize); |
| 24 BitmapTextBlob* createBlob(const SkTextBlob* blob, size_t maxVAStride) { |
| 25 int glyphCount = 0; |
| 26 int runCount = 0; |
| 27 BlobGlyphCount(&glyphCount, &runCount, blob); |
| 28 BitmapTextBlob* cacheBlob = this->createBlob(glyphCount, runCount, maxVA
Stride); |
| 29 return cacheBlob; |
| 30 } |
24 | 31 |
25 BitmapTextBlob* createCachedBlob(const SkTextBlob* blob, size_t maxVAStride)
{ | 32 BitmapTextBlob* createCachedBlob(const SkTextBlob* blob, size_t maxVAStride)
{ |
26 int glyphCount = 0; | 33 int glyphCount = 0; |
27 int runCount = 0; | 34 int runCount = 0; |
28 BlobGlyphCount(&glyphCount, &runCount, blob); | 35 BlobGlyphCount(&glyphCount, &runCount, blob); |
29 BitmapTextBlob* cacheBlob = this->createBlob(glyphCount, runCount, maxVA
Stride); | 36 BitmapTextBlob* cacheBlob = this->createBlob(glyphCount, runCount, maxVA
Stride); |
30 cacheBlob->fUniqueID = blob->uniqueID(); | 37 cacheBlob->fUniqueID = blob->uniqueID(); |
31 this->add(cacheBlob); | 38 this->add(cacheBlob); |
32 return cacheBlob; | 39 return cacheBlob; |
33 } | 40 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // based off of the largest cached textblob I have seen in the skps(a couple
of kilobytes). | 92 // based off of the largest cached textblob I have seen in the skps(a couple
of kilobytes). |
86 static const int kPreAllocSize = 1 << 17; | 93 static const int kPreAllocSize = 1 << 17; |
87 static const int kMinGrowthSize = 1 << 17; | 94 static const int kMinGrowthSize = 1 << 17; |
88 static const int kBudget = 1 << 20; | 95 static const int kBudget = 1 << 20; |
89 BitmapBlobList fBlobList; | 96 BitmapBlobList fBlobList; |
90 SkTDynamicHash<BitmapTextBlob, uint32_t> fCache; | 97 SkTDynamicHash<BitmapTextBlob, uint32_t> fCache; |
91 GrMemoryPool fPool; | 98 GrMemoryPool fPool; |
92 }; | 99 }; |
93 | 100 |
94 #endif | 101 #endif |
OLD | NEW |