aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrCacheID.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrCacheID.cpp')
-rw-r--r--src/gpu/GrCacheID.cpp39
1 files changed, 10 insertions, 29 deletions
diff --git a/src/gpu/GrCacheID.cpp b/src/gpu/GrCacheID.cpp
index 4c6dd492c3..c3d1d6612d 100644
--- a/src/gpu/GrCacheID.cpp
+++ b/src/gpu/GrCacheID.cpp
@@ -5,40 +5,21 @@
* found in the LICENSE file.
*/
-#include "GrCacheID.h"
+#include "GrTypes.h"
#include "SkThread.h" // for sk_atomic_inc
-uint8_t GrCacheID::GetNextDomain() {
- // 0 reserved for kUnrestricted_ResourceDomain
- static int32_t gNextDomain = 1;
+static GrCacheID::Key kAssertKey;
+GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData32));
+GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData64));
+GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey));
+
+GrCacheID::Domain GrCacheID::GenerateDomain() {
+ static int32_t gNextDomain = kInvalid_Domain + 1;
int32_t domain = sk_atomic_inc(&gNextDomain);
- if (domain >= 256) {
+ if (domain >= 1 << (8 * sizeof(Domain))) {
GrCrash("Too many Cache Domains");
}
- return (uint8_t) domain;
-}
-
-uint8_t GrCacheID::GetNextResourceType() {
- // 0 reserved for kInvalid_ResourceType
- static int32_t gNextResourceType = 1;
-
- int32_t type = sk_atomic_inc(&gNextResourceType);
- if (type >= 256) {
- GrCrash("Too many Cache Resource Types");
- }
-
- return (uint8_t) type;
-}
-
-void GrCacheID::toRaw(uint32_t v[4]) {
- GrAssert(4*sizeof(uint32_t) == sizeof(GrCacheID));
-
- v[0] = (uint32_t) (fPublicID & 0xffffffffUL);
- v[1] = (uint32_t) ((fPublicID >> 32) & 0xffffffffUL);
- v[2] = fResourceSpecific32;
- v[3] = fDomain << 24 |
- fResourceType << 16 |
- fResourceSpecific16;
+ return static_cast<Domain>(domain);
}