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 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 void makeMRU(BitmapTextBlob* blob) { | 109 void makeMRU(BitmapTextBlob* blob) { |
110 if (fBlobList.head() == blob) { | 110 if (fBlobList.head() == blob) { |
111 return; | 111 return; |
112 } | 112 } |
113 | 113 |
114 fBlobList.remove(blob); | 114 fBlobList.remove(blob); |
115 fBlobList.addToHead(blob); | 115 fBlobList.addToHead(blob); |
116 } | 116 } |
117 | 117 |
| 118 void freeAll(); |
| 119 |
118 private: | 120 private: |
119 // TODO move to SkTextBlob | 121 // TODO move to SkTextBlob |
120 void BlobGlyphCount(int* glyphCount, int* runCount, const SkTextBlob* blob)
{ | 122 void BlobGlyphCount(int* glyphCount, int* runCount, const SkTextBlob* blob)
{ |
121 SkTextBlob::RunIterator itCounter(blob); | 123 SkTextBlob::RunIterator itCounter(blob); |
122 for (; !itCounter.done(); itCounter.next(), (*runCount)++) { | 124 for (; !itCounter.done(); itCounter.next(), (*runCount)++) { |
123 *glyphCount += itCounter.glyphCount(); | 125 *glyphCount += itCounter.glyphCount(); |
124 } | 126 } |
125 } | 127 } |
126 | 128 |
127 typedef SkTInternalLList<BitmapTextBlob> BitmapBlobList; | 129 typedef SkTInternalLList<BitmapTextBlob> BitmapBlobList; |
128 | 130 |
129 // Budget was chosen to be ~4 megabytes. The min alloc and pre alloc sizes
in the pool are | 131 // Budget was chosen to be ~4 megabytes. The min alloc and pre alloc sizes
in the pool are |
130 // based off of the largest cached textblob I have seen in the skps(a couple
of kilobytes). | 132 // based off of the largest cached textblob I have seen in the skps(a couple
of kilobytes). |
131 static const int kPreAllocSize = 1 << 17; | 133 static const int kPreAllocSize = 1 << 17; |
132 static const int kMinGrowthSize = 1 << 17; | 134 static const int kMinGrowthSize = 1 << 17; |
133 static const int kBudget = 1 << 22; | 135 static const int kBudget = 1 << 22; |
134 BitmapBlobList fBlobList; | 136 BitmapBlobList fBlobList; |
135 SkTDynamicHash<BitmapTextBlob, BitmapTextBlob::Key> fCache; | 137 SkTDynamicHash<BitmapTextBlob, BitmapTextBlob::Key> fCache; |
136 GrMemoryPool fPool; | 138 GrMemoryPool fPool; |
137 PFOverBudgetCB fCallback; | 139 PFOverBudgetCB fCallback; |
138 void* fData; | 140 void* fData; |
139 }; | 141 }; |
140 | 142 |
141 #endif | 143 #endif |
OLD | NEW |