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

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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 }

mercurial