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

Side by Side Diff: bench/GrResourceCacheBench.cpp

Issue 940463006: Rename GrContentKey to GrUniqueKey (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 5 years, 10 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
« no previous file with comments | « no previous file | include/gpu/GrContext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "Benchmark.h" 9 #include "Benchmark.h"
10 10
(...skipping 11 matching lines...) Expand all
22 }; 22 };
23 23
24 class BenchResource : public GrGpuResource { 24 class BenchResource : public GrGpuResource {
25 public: 25 public:
26 SK_DECLARE_INST_COUNT(BenchResource); 26 SK_DECLARE_INST_COUNT(BenchResource);
27 BenchResource (GrGpu* gpu) 27 BenchResource (GrGpu* gpu)
28 : INHERITED(gpu, kCached_LifeCycle) { 28 : INHERITED(gpu, kCached_LifeCycle) {
29 this->registerWithCache(); 29 this->registerWithCache();
30 } 30 }
31 31
32 static void ComputeKey(int i, GrContentKey* key) { 32 static void ComputeKey(int i, GrUniqueKey* key) {
33 static GrContentKey::Domain kDomain = GrContentKey::GenerateDomain(); 33 static GrUniqueKey::Domain kDomain = GrUniqueKey::GenerateDomain();
34 GrContentKey::Builder builder(key, kDomain, 1); 34 GrUniqueKey::Builder builder(key, kDomain, 1);
35 builder[0] = i; 35 builder[0] = i;
36 } 36 }
37 37
38 private: 38 private:
39 size_t onGpuMemorySize() const SK_OVERRIDE { return 100; } 39 size_t onGpuMemorySize() const SK_OVERRIDE { return 100; }
40 40
41 typedef GrGpuResource INHERITED; 41 typedef GrGpuResource INHERITED;
42 }; 42 };
43 43
44 static void populate_cache(GrGpu* gpu, int resourceCount) { 44 static void populate_cache(GrGpu* gpu, int resourceCount) {
45 for (int i = 0; i < resourceCount; ++i) { 45 for (int i = 0; i < resourceCount; ++i) {
46 GrContentKey key; 46 GrUniqueKey key;
47 BenchResource::ComputeKey(i, &key); 47 BenchResource::ComputeKey(i, &key);
48 GrGpuResource* resource = SkNEW_ARGS(BenchResource, (gpu)); 48 GrGpuResource* resource = SkNEW_ARGS(BenchResource, (gpu));
49 resource->resourcePriv().setContentKey(key); 49 resource->resourcePriv().setUniqueKey(key);
50 resource->unref(); 50 resource->unref();
51 } 51 }
52 } 52 }
53 53
54 class GrResourceCacheBenchAdd : public Benchmark { 54 class GrResourceCacheBenchAdd : public Benchmark {
55 public: 55 public:
56 bool isSuitableFor(Backend backend) SK_OVERRIDE { 56 bool isSuitableFor(Backend backend) SK_OVERRIDE {
57 return backend == kNonRendering_Backend; 57 return backend == kNonRendering_Backend;
58 } 58 }
59 59
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { 121 void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE {
122 if (!fContext) { 122 if (!fContext) {
123 return; 123 return;
124 } 124 }
125 GrResourceCache* cache = fContext->getResourceCache(); 125 GrResourceCache* cache = fContext->getResourceCache();
126 SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount()); 126 SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount());
127 for (int i = 0; i < loops; ++i) { 127 for (int i = 0; i < loops; ++i) {
128 for (int k = 0; k < CACHE_SIZE_COUNT; ++k) { 128 for (int k = 0; k < CACHE_SIZE_COUNT; ++k) {
129 GrContentKey key; 129 GrUniqueKey key;
130 BenchResource::ComputeKey(k, &key); 130 BenchResource::ComputeKey(k, &key);
131 SkAutoTUnref<GrGpuResource> resource(cache->findAndRefContentRes ource(key)); 131 SkAutoTUnref<GrGpuResource> resource(cache->findAndRefUniqueReso urce(key));
132 SkASSERT(resource); 132 SkASSERT(resource);
133 } 133 }
134 } 134 }
135 } 135 }
136 136
137 private: 137 private:
138 SkAutoTUnref<GrContext> fContext; 138 SkAutoTUnref<GrContext> fContext;
139 typedef Benchmark INHERITED; 139 typedef Benchmark INHERITED;
140 }; 140 };
141 141
142 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) 142 DEF_BENCH( return new GrResourceCacheBenchAdd(); )
143 DEF_BENCH( return new GrResourceCacheBenchFind(); ) 143 DEF_BENCH( return new GrResourceCacheBenchFind(); )
144 144
145 #endif 145 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698