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

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

Issue 1116943004: Move instanced index buffer creation to flush time (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix missing assignment of keys to index buffers 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"
13 #include "SkTemplates.h" 14 #include "SkTemplates.h"
14 15
15 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size); 16 uint32_t GrResourceKeyHash(const uint32_t* data, size_t size);
16 17
17 /** 18 /**
18 * Base class for all GrGpuResource cache keys. There are two types of cache key s. Refer to the 19 * Base class for all GrGpuResource cache keys. There are two types of cache key s. Refer to the
19 * comments for each key type below. 20 * comments for each key type below.
20 */ 21 */
21 class GrResourceKey { 22 class GrResourceKey {
22 public: 23 public:
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 260 }
260 261
261 private: 262 private:
262 static int Data32CntForInnerKey(const GrUniqueKey& innerKey) { 263 static int Data32CntForInnerKey(const GrUniqueKey& innerKey) {
263 // key data + domain 264 // key data + domain
264 return SkToInt((innerKey.dataSize() >> 2) + 1); 265 return SkToInt((innerKey.dataSize() >> 2) + 1);
265 } 266 }
266 }; 267 };
267 }; 268 };
268 269
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
269 // The cache listens for these messages to purge junk resources proactively. 288 // The cache listens for these messages to purge junk resources proactively.
270 class GrUniqueKeyInvalidatedMessage { 289 class GrUniqueKeyInvalidatedMessage {
271 public: 290 public:
272 explicit GrUniqueKeyInvalidatedMessage(const GrUniqueKey& key) : fKey(key) { } 291 explicit GrUniqueKeyInvalidatedMessage(const GrUniqueKey& key) : fKey(key) { }
273 292
274 GrUniqueKeyInvalidatedMessage(const GrUniqueKeyInvalidatedMessage& that) : f Key(that.fKey) {} 293 GrUniqueKeyInvalidatedMessage(const GrUniqueKeyInvalidatedMessage& that) : f Key(that.fKey) {}
275 294
276 GrUniqueKeyInvalidatedMessage& operator=(const GrUniqueKeyInvalidatedMessage & that) { 295 GrUniqueKeyInvalidatedMessage& operator=(const GrUniqueKeyInvalidatedMessage & that) {
277 fKey = that.fKey; 296 fKey = that.fKey;
278 return *this; 297 return *this;
279 } 298 }
280 299
281 const GrUniqueKey& key() const { return fKey; } 300 const GrUniqueKey& key() const { return fKey; }
282 301
283 private: 302 private:
284 GrUniqueKey fKey; 303 GrUniqueKey fKey;
285 }; 304 };
286 #endif 305 #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