146a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com/*
246a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com * Copyright 2012 Google Inc.
346a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com *
446a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com * Use of this source code is governed by a BSD-style license that can be
546a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com * found in the LICENSE file.
646a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com */
746a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com
80797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com#include "GrTypes.h"
946a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com#include "SkThread.h"       // for sk_atomic_inc
1046a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com
115c265d6fd3537c99304b153fc49066db3be46d46bsalomon@google.com// Well, the dummy_ "fix" caused a warning on windows, so hiding all of it
125c265d6fd3537c99304b153fc49066db3be46d46bsalomon@google.com// until we can find a universal fix.
135c265d6fd3537c99304b153fc49066db3be46d46bsalomon@google.com#if 0
143ac5eb571bda3422a2868ddcf67ac731e7242a92reed@google.com// This used to be a global scope, but we got a warning about unused variable
153ac5eb571bda3422a2868ddcf67ac731e7242a92reed@google.com// so we moved it into here. We just want it to compile, so we can test the
163ac5eb571bda3422a2868ddcf67ac731e7242a92reed@google.com// static asserts.
173ac5eb571bda3422a2868ddcf67ac731e7242a92reed@google.comstatic inline void dummy_function_to_avoid_unused_var_warning() {
185c265d6fd3537c99304b153fc49066db3be46d46bsalomon@google.com    GrCacheID::Key kAssertKey;
193ac5eb571bda3422a2868ddcf67ac731e7242a92reed@google.com    GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData32));
203ac5eb571bda3422a2868ddcf67ac731e7242a92reed@google.com    GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData64));
213ac5eb571bda3422a2868ddcf67ac731e7242a92reed@google.com    GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey));
223ac5eb571bda3422a2868ddcf67ac731e7242a92reed@google.com}
235c265d6fd3537c99304b153fc49066db3be46d46bsalomon@google.com#endif
240797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com
250797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.comGrCacheID::Domain GrCacheID::GenerateDomain() {
260797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    static int32_t gNextDomain = kInvalid_Domain + 1;
2746a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com
2846a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com    int32_t domain = sk_atomic_inc(&gNextDomain);
290797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    if (domain >= 1 << (8 * sizeof(Domain))) {
3088cb22b6b4816c7a9ca6c5b795965b4606f9eb7bcommit-bot@chromium.org        SkFAIL("Too many Cache Domains");
3146a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com    }
3246a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com
330797c2cceadd7dfc2e7f9efa30b611d18efcdcddbsalomon@google.com    return static_cast<Domain>(domain);
3446a8600405e678718271f62c5994119b8d3241e9robertphillips@google.com}
35