1 /* 2 * Copyright 2012 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "GrTypes.h" 9 #include "SkThread.h" // for sk_atomic_inc 10 11 static GrCacheID::Key kAssertKey; 12 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData32)); 13 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData64)); 14 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey)); 15 16 GrCacheID::Domain GrCacheID::GenerateDomain() { 17 static int32_t gNextDomain = kInvalid_Domain + 1; 18 19 int32_t domain = sk_atomic_inc(&gNextDomain); 20 if (domain >= 1 << (8 * sizeof(Domain))) { 21 GrCrash("Too many Cache Domains"); 22 } 23 24 return static_cast<Domain>(domain); 25 } 26