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 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
10 | 10 |
11 #include "Benchmark.h" | 11 #include "Benchmark.h" |
12 #include "GrGpuResource.h" | 12 #include "GrGpuResource.h" |
13 #include "GrContext.h" | 13 #include "GrContext.h" |
| 14 #include "GrGpu.h" |
14 #include "GrResourceCache.h" | 15 #include "GrResourceCache.h" |
15 #include "GrStencilBuffer.h" | 16 #include "GrStencilBuffer.h" |
16 #include "GrTexture.h" | 17 #include "GrTexture.h" |
17 #include "GrTexturePriv.h" | 18 #include "GrTexturePriv.h" |
18 #include "SkCanvas.h" | 19 #include "SkCanvas.h" |
19 | 20 |
20 enum { | 21 enum { |
21 CACHE_SIZE_COUNT = 2048, | 22 CACHE_SIZE_COUNT = 2048, |
22 CACHE_SIZE_BYTES = 2 * 1024 * 1024, | 23 CACHE_SIZE_BYTES = 2 * 1024 * 1024, |
23 }; | 24 }; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 179 |
179 protected: | 180 protected: |
180 virtual const char* onGetName() SK_OVERRIDE { | 181 virtual const char* onGetName() SK_OVERRIDE { |
181 return "grresourcecache_add"; | 182 return "grresourcecache_add"; |
182 } | 183 } |
183 | 184 |
184 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 185 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
185 GrGpu* gpu = canvas->getGrContext()->getGpu(); | 186 GrGpu* gpu = canvas->getGrContext()->getGpu(); |
186 | 187 |
187 for (int i = 0; i < loops; ++i) { | 188 for (int i = 0; i < loops; ++i) { |
188 GrResourceCache cache(CACHE_SIZE_COUNT, CACHE_SIZE_BYTES); | 189 GrResourceCache cache(gpu->caps(), CACHE_SIZE_COUNT, CACHE_SIZE_BYTE
S); |
189 populate_cache(&cache, gpu, DUPLICATE_COUNT); | 190 populate_cache(&cache, gpu, DUPLICATE_COUNT); |
190 populate_cache(&cache, gpu, RESOURCE_COUNT); | 191 populate_cache(&cache, gpu, RESOURCE_COUNT); |
191 | 192 |
192 // Check that cache works. | 193 // Check that cache works. |
193 for (int k = 0; k < RESOURCE_COUNT; k += 33) { | 194 for (int k = 0; k < RESOURCE_COUNT; k += 33) { |
194 check_cache_contents_or_die(&cache, k); | 195 check_cache_contents_or_die(&cache, k); |
195 } | 196 } |
196 cache.purgeAllUnlocked(); | 197 cache.purgeAllUnlocked(); |
197 } | 198 } |
198 } | 199 } |
(...skipping 13 matching lines...) Expand all Loading... |
212 return backend == kGPU_Backend; | 213 return backend == kGPU_Backend; |
213 } | 214 } |
214 | 215 |
215 protected: | 216 protected: |
216 virtual const char* onGetName() SK_OVERRIDE { | 217 virtual const char* onGetName() SK_OVERRIDE { |
217 return "grresourcecache_find"; | 218 return "grresourcecache_find"; |
218 } | 219 } |
219 | 220 |
220 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { | 221 virtual void onDraw(const int loops, SkCanvas* canvas) SK_OVERRIDE { |
221 GrGpu* gpu = canvas->getGrContext()->getGpu(); | 222 GrGpu* gpu = canvas->getGrContext()->getGpu(); |
222 GrResourceCache cache(CACHE_SIZE_COUNT, CACHE_SIZE_BYTES); | 223 GrResourceCache cache(gpu->caps(), CACHE_SIZE_COUNT, CACHE_SIZE_BYTES); |
223 populate_cache(&cache, gpu, DUPLICATE_COUNT); | 224 populate_cache(&cache, gpu, DUPLICATE_COUNT); |
224 populate_cache(&cache, gpu, RESOURCE_COUNT); | 225 populate_cache(&cache, gpu, RESOURCE_COUNT); |
225 | 226 |
226 for (int i = 0; i < loops; ++i) { | 227 for (int i = 0; i < loops; ++i) { |
227 for (int k = 0; k < RESOURCE_COUNT; ++k) { | 228 for (int k = 0; k < RESOURCE_COUNT; ++k) { |
228 check_cache_contents_or_die(&cache, k); | 229 check_cache_contents_or_die(&cache, k); |
229 } | 230 } |
230 } | 231 } |
231 } | 232 } |
232 | 233 |
233 private: | 234 private: |
234 typedef Benchmark INHERITED; | 235 typedef Benchmark INHERITED; |
235 }; | 236 }; |
236 | 237 |
237 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) | 238 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) |
238 DEF_BENCH( return new GrResourceCacheBenchFind(); ) | 239 DEF_BENCH( return new GrResourceCacheBenchFind(); ) |
239 | 240 |
240 #endif | 241 #endif |
OLD | NEW |