gfx/skia/trunk/src/gpu/GrCacheID.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/gpu/GrCacheID.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,34 @@
     1.4 +/*
     1.5 + * Copyright 2012 Google Inc.
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#include "GrTypes.h"
    1.12 +#include "SkThread.h"       // for sk_atomic_inc
    1.13 +
    1.14 +// Well, the dummy_ "fix" caused a warning on windows, so hiding all of it
    1.15 +// until we can find a universal fix.
    1.16 +#if 0
    1.17 +// This used to be a global scope, but we got a warning about unused variable
    1.18 +// so we moved it into here. We just want it to compile, so we can test the
    1.19 +// static asserts.
    1.20 +static inline void dummy_function_to_avoid_unused_var_warning() {
    1.21 +    GrCacheID::Key kAssertKey;
    1.22 +    GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData32));
    1.23 +    GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey.fData64));
    1.24 +    GR_STATIC_ASSERT(sizeof(kAssertKey.fData8) == sizeof(kAssertKey));
    1.25 +}
    1.26 +#endif
    1.27 +
    1.28 +GrCacheID::Domain GrCacheID::GenerateDomain() {
    1.29 +    static int32_t gNextDomain = kInvalid_Domain + 1;
    1.30 +
    1.31 +    int32_t domain = sk_atomic_inc(&gNextDomain);
    1.32 +    if (domain >= 1 << (8 * sizeof(Domain))) {
    1.33 +        GrCrash("Too many Cache Domains");
    1.34 +    }
    1.35 +
    1.36 +    return static_cast<Domain>(domain);
    1.37 +}

mercurial