Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(715)

Side by Side Diff: tests/ImageCacheTest.cpp

Issue 950363002: Notify resource caches when pixelref genID goes stale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use a sharedID for purging Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDiscardableMemory.h" 8 #include "SkDiscardableMemory.h"
9 #include "SkResourceCache.h" 9 #include "SkResourceCache.h"
10 #include "Test.h" 10 #include "Test.h"
11 11
12 namespace { 12 namespace {
13 static void* gGlobalAddress; 13 static void* gGlobalAddress;
14 struct TestingKey : public SkResourceCache::Key { 14 struct TestingKey : public SkResourceCache::Key {
15 intptr_t fValue; 15 intptr_t fValue;
16 16
17 TestingKey(intptr_t value) : fValue(value) { 17 TestingKey(intptr_t value) : fValue(value) {
18 this->init(&gGlobalAddress, sizeof(fValue)); 18 this->init(&gGlobalAddress, 0, sizeof(fValue));
19 } 19 }
20 }; 20 };
21 struct TestingRec : public SkResourceCache::Rec { 21 struct TestingRec : public SkResourceCache::Rec {
22 TestingRec(const TestingKey& key, uint32_t value) : fKey(key), fValue(value) {} 22 TestingRec(const TestingKey& key, uint32_t value) : fKey(key), fValue(value) {}
23 23
24 TestingKey fKey; 24 TestingKey fKey;
25 intptr_t fValue; 25 intptr_t fValue;
26 26
27 const Key& getKey() const SK_OVERRIDE { return fKey; } 27 const Key& getKey() const SK_OVERRIDE { return fKey; }
28 size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + sizeof(fValue); } 28 size_t bytesUsed() const SK_OVERRIDE { return sizeof(fKey) + sizeof(fValue); }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 TestingKey key(1); 106 TestingKey key(1);
107 107
108 cache.add(SkNEW_ARGS(TestingRec, (key, 2))); 108 cache.add(SkNEW_ARGS(TestingRec, (key, 2)));
109 cache.add(SkNEW_ARGS(TestingRec, (key, 3))); 109 cache.add(SkNEW_ARGS(TestingRec, (key, 3)));
110 110
111 // Lookup can return either value. 111 // Lookup can return either value.
112 intptr_t value = -1; 112 intptr_t value = -1;
113 REPORTER_ASSERT(r, cache.find(key, TestingRec::Visitor, &value)); 113 REPORTER_ASSERT(r, cache.find(key, TestingRec::Visitor, &value));
114 REPORTER_ASSERT(r, 2 == value || 3 == value); 114 REPORTER_ASSERT(r, 2 == value || 3 == value);
115 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698