blob: c3d1d6612dbc211ef1a90db7223c7532eb6d6696 [file] [log] [blame]
robertphillips@google.com46a86002012-08-08 10:42:44 +00001/*
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
bsalomon@google.com0797c2c2012-12-20 15:13:01 +00008#include "GrTypes.h"
robertphillips@google.com46a86002012-08-08 10:42:44 +00009#include "SkThread.h" // for sk_atomic_inc
10
bsalomon@google.com0797c2c2012-12-20 15:13:01 +000011static GrCacheID::Key kAssertKey;
12GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData32));
13GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData64));
14GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey));
15
16GrCacheID::Domain GrCacheID::GenerateDomain() {
17 static int32_t gNextDomain = kInvalid_Domain + 1;
robertphillips@google.com46a86002012-08-08 10:42:44 +000018
19 int32_t domain = sk_atomic_inc(&gNextDomain);
bsalomon@google.com0797c2c2012-12-20 15:13:01 +000020 if (domain >= 1 << (8 * sizeof(Domain))) {
robertphillips@google.com46a86002012-08-08 10:42:44 +000021 GrCrash("Too many Cache Domains");
22 }
23
bsalomon@google.com0797c2c2012-12-20 15:13:01 +000024 return static_cast<Domain>(domain);
robertphillips@google.com46a86002012-08-08 10:42:44 +000025}