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

Side by Side Diff: include/gpu/GrResourceKey.h

Issue 1126613003: Revert of Move instanced index buffer creation to flush time (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 months 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
« no previous file with comments | « include/gpu/GrContext.h ('k') | include/gpu/GrTextureProvider.h » ('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 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #ifndef GrResourceKey_DEFINED 9 #ifndef GrResourceKey_DEFINED
10 #define GrResourceKey_DEFINED 10 #define GrResourceKey_DEFINED
11 11
12 #include "GrTypes.h" 12 #include "GrTypes.h"
13 #include "SkOnce.h"
14 #include "SkTemplates.h" 13 #include "SkTemplates.h"
15 14
16 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size); 15 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size);
17 16
18 /** 17 /**
19 * Base class for all GrGpuResource cache keys. There are two types of cache key s. Refer to the 18 * Base class for all GrGpuResource cache keys. There are two types of cache key s. Refer to the
20 * comments for each key type below. 19 * comments for each key type below.
21 */ 20 */
22 class GrResourceKey { 21 class GrResourceKey {
23 public: 22 public:
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 259 }
261 260
262 private: 261 private:
263 static int Data32CntForInnerKey(const GrUniqueKey& innerKey) { 262 static int Data32CntForInnerKey(const GrUniqueKey& innerKey) {
264 // key data + domain 263 // key data + domain
265 return SkToInt((innerKey.dataSize() >> 2) + 1); 264 return SkToInt((innerKey.dataSize() >> 2) + 1);
266 } 265 }
267 }; 266 };
268 }; 267 };
269 268
270 /**
271 * It is common to need a frequently reused GrUniqueKey where the only requireme nt is that the key
272 * is unique. These macros create such a key in a thread safe manner so the key can be truly global
273 * and only constructed once.
274 */
275
276 /** Place outside of function/class definitions. */
277 #define GR_DECLARE_STATIC_UNIQUE_KEY(name) SK_DECLARE_STATIC_ONCE(name##_once)
278
279 /** Place inside function where the key is used. */
280 #define GR_DEFINE_STATIC_UNIQUE_KEY(name) \
281 static GrUniqueKey name; \
282 SkOnce(&name##_once, gr_init_static_unique_key_once, &name)
283
284 static inline void gr_init_static_unique_key_once(GrUniqueKey* key) {
285 GrUniqueKey::Builder builder(key, GrUniqueKey::GenerateDomain(), 0);
286 }
287
288 // The cache listens for these messages to purge junk resources proactively. 269 // The cache listens for these messages to purge junk resources proactively.
289 class GrUniqueKeyInvalidatedMessage { 270 class GrUniqueKeyInvalidatedMessage {
290 public: 271 public:
291 explicit GrUniqueKeyInvalidatedMessage(const GrUniqueKey& key) : fKey(key) { } 272 explicit GrUniqueKeyInvalidatedMessage(const GrUniqueKey& key) : fKey(key) { }
292 273
293 GrUniqueKeyInvalidatedMessage(const GrUniqueKeyInvalidatedMessage& that) : f Key(that.fKey) {} 274 GrUniqueKeyInvalidatedMessage(const GrUniqueKeyInvalidatedMessage& that) : f Key(that.fKey) {}
294 275
295 GrUniqueKeyInvalidatedMessage& operator=(const GrUniqueKeyInvalidatedMessage & that) { 276 GrUniqueKeyInvalidatedMessage& operator=(const GrUniqueKeyInvalidatedMessage & that) {
296 fKey = that.fKey; 277 fKey = that.fKey;
297 return *this; 278 return *this;
298 } 279 }
299 280
300 const GrUniqueKey& key() const { return fKey; } 281 const GrUniqueKey& key() const { return fKey; }
301 282
302 private: 283 private:
303 GrUniqueKey fKey; 284 GrUniqueKey fKey;
304 }; 285 };
305 #endif 286 #endif
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | include/gpu/GrTextureProvider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698