michael@0: /* michael@0: * Copyright 2012 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #include "GrTypes.h" michael@0: #include "SkThread.h" // for sk_atomic_inc michael@0: michael@0: // Well, the dummy_ "fix" caused a warning on windows, so hiding all of it michael@0: // until we can find a universal fix. michael@0: #if 0 michael@0: // This used to be a global scope, but we got a warning about unused variable michael@0: // so we moved it into here. We just want it to compile, so we can test the michael@0: // static asserts. michael@0: static inline void dummy_function_to_avoid_unused_var_warning() { michael@0: GrCacheID::Key kAssertKey; michael@0: GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData32)); michael@0: GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData64)); michael@0: GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey)); michael@0: } michael@0: #endif michael@0: michael@0: GrCacheID::Domain GrCacheID::GenerateDomain() { michael@0: static int32_t gNextDomain = kInvalid_Domain + 1; michael@0: michael@0: int32_t domain = sk_atomic_inc(&gNextDomain); michael@0: if (domain >= 1 << (8 * sizeof(Domain))) { michael@0: GrCrash("Too many Cache Domains"); michael@0: } michael@0: michael@0: return static_cast(domain); michael@0: }