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