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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 typedef SkTInternalLList<GrAtlasTextBlob> BitmapBlobList; | 113 typedef SkTInternalLList<GrAtlasTextBlob> BitmapBlobList; |
114 | 114 |
115 void checkPurge(GrAtlasTextBlob* blob = NULL) { | 115 void checkPurge(GrAtlasTextBlob* blob = NULL) { |
116 // If we are overbudget, then unref until we are below budget again | 116 // If we are overbudget, then unref until we are below budget again |
117 if (fPool.size() > fBudget) { | 117 if (fPool.size() > fBudget) { |
118 BitmapBlobList::Iter iter; | 118 BitmapBlobList::Iter iter; |
119 iter.init(fBlobList, BitmapBlobList::Iter::kTail_IterStart); | 119 iter.init(fBlobList, BitmapBlobList::Iter::kTail_IterStart); |
120 GrAtlasTextBlob* lruBlob = iter.get(); | 120 GrAtlasTextBlob* lruBlob = NULL; |
121 SkASSERT(lruBlob); | |
122 while (fPool.size() > fBudget && (lruBlob = iter.get()) && lruBlob !
= blob) { | 121 while (fPool.size() > fBudget && (lruBlob = iter.get()) && lruBlob !
= blob) { |
123 fCache.remove(lruBlob->fKey); | 122 fCache.remove(lruBlob->fKey); |
124 | 123 |
125 // Backup the iterator before removing and unrefing the blob | 124 // Backup the iterator before removing and unrefing the blob |
126 iter.prev(); | 125 iter.prev(); |
127 fBlobList.remove(lruBlob); | 126 fBlobList.remove(lruBlob); |
128 lruBlob->unref(); | 127 lruBlob->unref(); |
129 } | 128 } |
130 | 129 |
131 // If we break out of the loop with lruBlob == blob, then we haven't
purged enough | 130 // If we break out of the loop with lruBlob == blob, then we haven't
purged enough |
(...skipping 18 matching lines...) Expand all Loading... |
150 static const int kDefaultBudget = 1 << 22; | 149 static const int kDefaultBudget = 1 << 22; |
151 BitmapBlobList fBlobList; | 150 BitmapBlobList fBlobList; |
152 SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key> fCache; | 151 SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key> fCache; |
153 GrMemoryPool fPool; | 152 GrMemoryPool fPool; |
154 PFOverBudgetCB fCallback; | 153 PFOverBudgetCB fCallback; |
155 void* fData; | 154 void* fData; |
156 size_t fBudget; | 155 size_t fBudget; |
157 }; | 156 }; |
158 | 157 |
159 #endif | 158 #endif |
OLD | NEW |