OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 GrTextureStripAtlas_DEFINED | 8 #ifndef GrTextureStripAtlas_DEFINED |
9 #define GrTextureStripAtlas_DEFINED | 9 #define GrTextureStripAtlas_DEFINED |
10 | 10 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 #endif | 129 #endif |
130 | 130 |
131 /** | 131 /** |
132 * Clean up callback registered with GrContext. Allows this class to | 132 * Clean up callback registered with GrContext. Allows this class to |
133 * free up any allocated AtlasEntry and GrTextureStripAtlas objects | 133 * free up any allocated AtlasEntry and GrTextureStripAtlas objects |
134 */ | 134 */ |
135 static void CleanUp(const GrContext* context, void* info); | 135 static void CleanUp(const GrContext* context, void* info); |
136 | 136 |
137 // Hash table entry for atlases | 137 // Hash table entry for atlases |
138 class AtlasEntry; | 138 class AtlasEntry; |
139 typedef GrTBinHashKey<AtlasEntry, sizeof(GrTextureStripAtlas::Desc)> AtlasHa shKey; | 139 class AtlasHashKey : public GrBinHashKey<sizeof(GrTextureStripAtlas::Desc)> { |
140 public: | |
141 static bool equals(const AtlasEntry& entry, const AtlasHashKey& key); | |
bsalomon
2013/11/27 14:46:01
I prefer the new names as well. But static functio
Kimmo Kinnunen
2013/11/28 07:38:34
Done.
| |
142 static bool lessThan(const AtlasEntry& entry, const AtlasHashKey& key); | |
143 }; | |
140 class AtlasEntry : public ::SkNoncopyable { | 144 class AtlasEntry : public ::SkNoncopyable { |
141 public: | 145 public: |
142 AtlasEntry() : fAtlas(NULL) {} | 146 AtlasEntry() : fAtlas(NULL) {} |
143 ~AtlasEntry() { SkDELETE(fAtlas); } | 147 ~AtlasEntry() { SkDELETE(fAtlas); } |
144 int compare(const AtlasHashKey& key) const { return fKey.compare(key); } | |
145 AtlasHashKey fKey; | 148 AtlasHashKey fKey; |
146 GrTextureStripAtlas* fAtlas; | 149 GrTextureStripAtlas* fAtlas; |
147 }; | 150 }; |
148 | 151 |
149 static GrTHashTable<AtlasEntry, AtlasHashKey, 8>* gAtlasCache; | 152 static GrTHashTable<AtlasEntry, AtlasHashKey, 8>* gAtlasCache; |
150 | 153 |
151 static GrTHashTable<AtlasEntry, AtlasHashKey, 8>* GetCache(); | 154 static GrTHashTable<AtlasEntry, AtlasHashKey, 8>* GetCache(); |
152 | 155 |
153 // We increment gCacheCount for each atlas | 156 // We increment gCacheCount for each atlas |
154 static int32_t gCacheCount; | 157 static int32_t gCacheCount; |
(...skipping 16 matching lines...) Expand all Loading... | |
171 | 174 |
172 // Head and tail for linked list of least-recently-used rows (front = least recently used). | 175 // Head and tail for linked list of least-recently-used rows (front = least recently used). |
173 // Note that when a texture is locked, it gets removed from this list until it is unlocked. | 176 // Note that when a texture is locked, it gets removed from this list until it is unlocked. |
174 AtlasRow* fLRUFront; | 177 AtlasRow* fLRUFront; |
175 AtlasRow* fLRUBack; | 178 AtlasRow* fLRUBack; |
176 | 179 |
177 // A list of pointers to AtlasRows that currently contain cached images, sor ted by key | 180 // A list of pointers to AtlasRows that currently contain cached images, sor ted by key |
178 SkTDArray<AtlasRow*> fKeyTable; | 181 SkTDArray<AtlasRow*> fKeyTable; |
179 }; | 182 }; |
180 | 183 |
184 inline bool GrTextureStripAtlas::AtlasHashKey::equals(const AtlasEntry& entry, c onst AtlasHashKey& key) { | |
mtklein
2013/11/27 14:36:54
Wrap these guys to 100 columns?
Kimmo Kinnunen
2013/11/28 07:38:34
Done.
| |
185 return entry.fKey == key; | |
186 } | |
187 | |
188 inline bool GrTextureStripAtlas::AtlasHashKey::lessThan(const AtlasEntry& entry, const AtlasHashKey& key) { | |
189 return entry.fKey < key; | |
190 } | |
191 | |
181 #endif | 192 #endif |
OLD | NEW |