diff options
author | bsalomon <bsalomon@google.com> | 2015-05-04 10:36:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-04 10:36:43 -0700 |
commit | ed0bcad9c8147fd37c23bdda00ec27ec9ef8d66b (patch) | |
tree | 5eba6a70d867c2e7124f06a9670088afe9cd0d99 /include/gpu/GrResourceKey.h | |
parent | d8ed1b64a6c85a8364c23e825164b7bebb43a3a0 (diff) |
Move instanced index buffer creation to flush time
Committed: https://skia.googlesource.com/skia/+/ab622c7b8cc8c39f0a594e4392b9e31b7e1ddb26
Review URL: https://codereview.chromium.org/1116943004
Diffstat (limited to 'include/gpu/GrResourceKey.h')
-rw-r--r-- | include/gpu/GrResourceKey.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/gpu/GrResourceKey.h b/include/gpu/GrResourceKey.h index aecdc70c0b..50a7145929 100644 --- a/include/gpu/GrResourceKey.h +++ b/include/gpu/GrResourceKey.h @@ -10,6 +10,7 @@ #define GrResourceKey_DEFINED #include "GrTypes.h" +#include "SkOnce.h" #include "SkTemplates.h" uint32_t GrResourceKeyHash(const uint32_t* data, size_t size); @@ -266,6 +267,24 @@ public: }; }; +/** + * It is common to need a frequently reused GrUniqueKey where the only requirement is that the key + * is unique. These macros create such a key in a thread safe manner so the key can be truly global + * and only constructed once. + */ + +/** Place outside of function/class definitions. */ +#define GR_DECLARE_STATIC_UNIQUE_KEY(name) SK_DECLARE_STATIC_ONCE(name##_once) + +/** Place inside function where the key is used. */ +#define GR_DEFINE_STATIC_UNIQUE_KEY(name) \ + static GrUniqueKey name; \ + SkOnce(&name##_once, gr_init_static_unique_key_once, &name) + +static inline void gr_init_static_unique_key_once(GrUniqueKey* key) { + GrUniqueKey::Builder builder(key, GrUniqueKey::GenerateDomain(), 0); +} + // The cache listens for these messages to purge junk resources proactively. class GrUniqueKeyInvalidatedMessage { public: |