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 "SkTextBlobRunIterator.h" |
14 | 14 |
15 class GrTextBlobCache { | 15 class GrTextBlobCache { |
16 public: | 16 public: |
17 /** | 17 /** |
18 * The callback function used by the cache when it is still over budget afte
r a purge. The | 18 * The callback function used by the cache when it is still over budget afte
r a purge. The |
19 * passed in 'data' is the same 'data' handed to setOverbudgetCallback. | 19 * passed in 'data' is the same 'data' handed to setOverbudgetCallback. |
20 */ | 20 */ |
21 typedef void (*PFOverBudgetCB)(void* data); | 21 typedef void (*PFOverBudgetCB)(void* data); |
22 | 22 |
23 GrTextBlobCache(PFOverBudgetCB cb, void* data) | 23 GrTextBlobCache(PFOverBudgetCB cb, void* data) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 91 } |
92 | 92 |
93 fBlobList.remove(blob); | 93 fBlobList.remove(blob); |
94 fBlobList.addToHead(blob); | 94 fBlobList.addToHead(blob); |
95 } | 95 } |
96 | 96 |
97 void freeAll(); | 97 void freeAll(); |
98 | 98 |
99 // TODO move to SkTextBlob | 99 // TODO move to SkTextBlob |
100 static void BlobGlyphCount(int* glyphCount, int* runCount, const SkTextBlob*
blob) { | 100 static void BlobGlyphCount(int* glyphCount, int* runCount, const SkTextBlob*
blob) { |
101 SkTextBlob::RunIterator itCounter(blob); | 101 SkTextBlobRunIterator itCounter(blob); |
102 for (; !itCounter.done(); itCounter.next(), (*runCount)++) { | 102 for (; !itCounter.done(); itCounter.next(), (*runCount)++) { |
103 *glyphCount += itCounter.glyphCount(); | 103 *glyphCount += itCounter.glyphCount(); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 void setBudget(size_t budget) { | 107 void setBudget(size_t budget) { |
108 fBudget = budget; | 108 fBudget = budget; |
109 this->checkPurge(); | 109 this->checkPurge(); |
110 } | 110 } |
111 | 111 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 static const int kDefaultBudget = 1 << 22; | 149 static const int kDefaultBudget = 1 << 22; |
150 BitmapBlobList fBlobList; | 150 BitmapBlobList fBlobList; |
151 SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key> fCache; | 151 SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key> fCache; |
152 GrMemoryPool fPool; | 152 GrMemoryPool fPool; |
153 PFOverBudgetCB fCallback; | 153 PFOverBudgetCB fCallback; |
154 void* fData; | 154 void* fData; |
155 size_t fBudget; | 155 size_t fBudget; |
156 }; | 156 }; |
157 | 157 |
158 #endif | 158 #endif |
OLD | NEW |