| OLD | NEW |
| 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 |
| 11 #if SK_SUPPORT_GPU | 11 #if SK_SUPPORT_GPU |
| 12 | 12 |
| 13 #include "GrGpuResource.h" | 13 #include "GrGpuResource.h" |
| 14 #include "GrContext.h" | 14 #include "GrContext.h" |
| 15 #include "GrGpu.h" | 15 #include "GrGpu.h" |
| 16 #include "GrResourceCache2.h" | 16 #include "GrResourceCache2.h" |
| 17 #include "SkCanvas.h" | 17 #include "SkCanvas.h" |
| 18 | 18 |
| 19 enum { | 19 enum { |
| 20 CACHE_SIZE_COUNT = 4096, | 20 CACHE_SIZE_COUNT = 4096, |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 class BenchResource : public GrGpuResource { | 23 class BenchResource : public GrGpuResource { |
| 24 public: | 24 public: |
| 25 SK_DECLARE_INST_COUNT(BenchResource); | 25 SK_DECLARE_INST_COUNT(BenchResource); |
| 26 BenchResource (GrGpu* gpu) | 26 BenchResource (GrGpu* gpu) |
| 27 : INHERITED(gpu, false) { | 27 : INHERITED(gpu, kCached_LifeCycle) { |
| 28 this->registerWithCache(); | 28 this->registerWithCache(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 static GrResourceKey ComputeKey(int i) { | 31 static GrResourceKey ComputeKey(int i) { |
| 32 GrCacheID::Key key; | 32 GrCacheID::Key key; |
| 33 memset(&key, 0, sizeof(key)); | 33 memset(&key, 0, sizeof(key)); |
| 34 key.fData32[0] = i; | 34 key.fData32[0] = i; |
| 35 static int gDomain = GrCacheID::GenerateDomain(); | 35 static int gDomain = GrCacheID::GenerateDomain(); |
| 36 return GrResourceKey(GrCacheID(gDomain, key), 0); | 36 return GrResourceKey(GrCacheID(gDomain, key), 0); |
| 37 } | 37 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| OLD | NEW |