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 |
11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
12 #include "SkChecksum.h" | 12 #include "SkOpts.h" |
13 #include "SkGr.h" | 13 #include "SkGr.h" |
14 #include "SkTDArray.h" | 14 #include "SkTDArray.h" |
15 #include "SkTDynamicHash.h" | 15 #include "SkTDynamicHash.h" |
16 #include "SkTypes.h" | 16 #include "SkTypes.h" |
17 | 17 |
18 /** | 18 /** |
19 * Maintains a single large texture whose rows store many textures of a small fi
xed height, | 19 * Maintains a single large texture whose rows store many textures of a small fi
xed height, |
20 * stored in rows across the x-axis such that we can safely wrap/repeat them hor
izontally. | 20 * stored in rows across the x-axis such that we can safely wrap/repeat them hor
izontally. |
21 */ | 21 */ |
22 class GrTextureStripAtlas { | 22 class GrTextureStripAtlas { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 * Clean up callback registered with GrContext. Allows this class to | 135 * Clean up callback registered with GrContext. Allows this class to |
136 * free up any allocated AtlasEntry and GrTextureStripAtlas objects | 136 * free up any allocated AtlasEntry and GrTextureStripAtlas objects |
137 */ | 137 */ |
138 static void CleanUp(const GrContext* context, void* info); | 138 static void CleanUp(const GrContext* context, void* info); |
139 | 139 |
140 // Hash table entry for atlases | 140 // Hash table entry for atlases |
141 class AtlasEntry : public ::SkNoncopyable { | 141 class AtlasEntry : public ::SkNoncopyable { |
142 public: | 142 public: |
143 // for SkTDynamicHash | 143 // for SkTDynamicHash |
144 static const Desc& GetKey(const AtlasEntry& entry) { return entry.fDesc;
} | 144 static const Desc& GetKey(const AtlasEntry& entry) { return entry.fDesc;
} |
145 static uint32_t Hash(const Desc& desc) { return SkChecksum::Murmur3(&des
c, sizeof(Desc)); } | 145 static uint32_t Hash(const Desc& desc) { return SkOpts::hash(&desc, size
of(Desc)); } |
146 | 146 |
147 // AtlasEntry proper | 147 // AtlasEntry proper |
148 AtlasEntry() : fAtlas(nullptr) {} | 148 AtlasEntry() : fAtlas(nullptr) {} |
149 ~AtlasEntry() { delete fAtlas; } | 149 ~AtlasEntry() { delete fAtlas; } |
150 Desc fDesc; | 150 Desc fDesc; |
151 GrTextureStripAtlas* fAtlas; | 151 GrTextureStripAtlas* fAtlas; |
152 }; | 152 }; |
153 | 153 |
154 class Hash; | 154 class Hash; |
155 static Hash* gAtlasCache; | 155 static Hash* gAtlasCache; |
(...skipping 24 matching lines...) Expand all Loading... |
180 // Head and tail for linked list of least-recently-used rows (front = least
recently used). | 180 // Head and tail for linked list of least-recently-used rows (front = least
recently used). |
181 // Note that when a texture is locked, it gets removed from this list until
it is unlocked. | 181 // Note that when a texture is locked, it gets removed from this list until
it is unlocked. |
182 AtlasRow* fLRUFront; | 182 AtlasRow* fLRUFront; |
183 AtlasRow* fLRUBack; | 183 AtlasRow* fLRUBack; |
184 | 184 |
185 // A list of pointers to AtlasRows that currently contain cached images, sor
ted by key | 185 // A list of pointers to AtlasRows that currently contain cached images, sor
ted by key |
186 SkTDArray<AtlasRow*> fKeyTable; | 186 SkTDArray<AtlasRow*> fKeyTable; |
187 }; | 187 }; |
188 | 188 |
189 #endif | 189 #endif |
OLD | NEW |