Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: src/gpu/effects/GrTextureStripAtlas.h

Issue 88113002: Speed up GrResourceCache lookup by inlining GrBinHashKey comparisons (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments (capitalized statics) Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrTextStrike_impl.h ('k') | src/gpu/gr_unittests.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
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
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,
185 const AtlasHashKey& key) {
186 return entry.fKey == key;
187 }
188
189 inline bool GrTextureStripAtlas::AtlasHashKey::LessThan(const AtlasEntry& entry,
190 const AtlasHashKey& key) {
191 return entry.fKey < key;
192 }
193
181 #endif 194 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrTextStrike_impl.h ('k') | src/gpu/gr_unittests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698