| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrTypes.h" | 8 #include "GrTypes.h" |
| 9 #include "SkThread.h" // for sk_atomic_inc | 9 #include "SkThread.h" // for sk_atomic_inc |
| 10 | 10 |
| 11 // Well, the dummy_ "fix" caused a warning on windows, so hiding all of it | 11 // Well, the dummy_ "fix" caused a warning on windows, so hiding all of it |
| 12 // until we can find a universal fix. | 12 // until we can find a universal fix. |
| 13 #if 0 | 13 #if 0 |
| 14 // This used to be a global scope, but we got a warning about unused variable | 14 // This used to be a global scope, but we got a warning about unused variable |
| 15 // so we moved it into here. We just want it to compile, so we can test the | 15 // so we moved it into here. We just want it to compile, so we can test the |
| 16 // static asserts. | 16 // static asserts. |
| 17 static inline void dummy_function_to_avoid_unused_var_warning() { | 17 static inline void dummy_function_to_avoid_unused_var_warning() { |
| 18 GrCacheID::Key kAssertKey; | 18 GrCacheID::Key kAssertKey; |
| 19 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData32)); | 19 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData32)); |
| 20 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData64)); | 20 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData64)); |
| 21 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey)); | 21 GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey)); |
| 22 } | 22 } |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 GrCacheID::Domain GrCacheID::GenerateDomain() { | 25 GrCacheID::Domain GrCacheID::GenerateDomain() { |
| 26 static int32_t gNextDomain = kInvalid_Domain + 1; | 26 static int32_t gNextDomain = kInvalid_Domain + 1; |
| 27 | 27 |
| 28 int32_t domain = sk_atomic_inc(&gNextDomain); | 28 int32_t domain = sk_atomic_inc(&gNextDomain); |
| 29 if (domain >= 1 << (8 * sizeof(Domain))) { | 29 if (domain >= 1 << (8 * sizeof(Domain))) { |
| 30 GrCrash("Too many Cache Domains"); | 30 SkFAIL("Too many Cache Domains"); |
| 31 } | 31 } |
| 32 | 32 |
| 33 return static_cast<Domain>(domain); | 33 return static_cast<Domain>(domain); |
| 34 } | 34 } |
| OLD | NEW |