| 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 "GrResourceCache.h" | 14 #include "GrResourceCache.h" |
| 15 #include "GrStencilBuffer.h" | 15 #include "GrStencilBuffer.h" |
| 16 #include "GrTexture.h" | 16 #include "GrTexture.h" |
| 17 #include "SkCanvas.h" | 17 #include "SkCanvas.h" |
| 18 | 18 |
| 19 enum { | 19 enum { |
| 20 CACHE_SIZE_COUNT = 2048, | 20 CACHE_SIZE_COUNT = 2048, |
| 21 CACHE_SIZE_BYTES = 2 * 1024 * 1024, | 21 CACHE_SIZE_BYTES = 2 * 1024 * 1024, |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 class StencilResource : public GrGpuResource { | 24 class StencilResource : public GrGpuResource { |
| 25 public: | 25 public: |
| 26 SK_DECLARE_INST_COUNT(StencilResource); | 26 SK_DECLARE_INST_COUNT(StencilResource); |
| 27 StencilResource(GrGpu* gpu, int id) | 27 StencilResource(GrGpu* gpu, int id) |
| 28 : INHERITED(gpu, false) | 28 : INHERITED(gpu, false) |
| 29 , fID(id) { | 29 , fID(id) { |
| 30 this->registerWithCache(); | |
| 31 } | 30 } |
| 32 | 31 |
| 33 virtual ~StencilResource() { this->release(); } | 32 virtual ~StencilResource() { this->release(); } |
| 34 | 33 |
| 35 virtual size_t gpuMemorySize() const SK_OVERRIDE { | 34 virtual size_t gpuMemorySize() const SK_OVERRIDE { |
| 36 return 100 + ((fID % 1 == 0) ? -5 : 6); | 35 return 100 + ((fID % 1 == 0) ? -5 : 6); |
| 37 } | 36 } |
| 38 | 37 |
| 39 static GrResourceKey ComputeKey(int width, int height, int sampleCnt) { | 38 static GrResourceKey ComputeKey(int width, int height, int sampleCnt) { |
| 40 return GrStencilBuffer::ComputeKey(width, height, sampleCnt); | 39 return GrStencilBuffer::ComputeKey(width, height, sampleCnt); |
| 41 } | 40 } |
| 42 | 41 |
| 43 int fID; | 42 int fID; |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 typedef GrGpuResource INHERITED; | 45 typedef GrGpuResource INHERITED; |
| 47 }; | 46 }; |
| 48 | 47 |
| 49 class TextureResource : public GrGpuResource { | 48 class TextureResource : public GrGpuResource { |
| 50 public: | 49 public: |
| 51 SK_DECLARE_INST_COUNT(TextureResource); | 50 SK_DECLARE_INST_COUNT(TextureResource); |
| 52 TextureResource(GrGpu* gpu, int id) | 51 TextureResource(GrGpu* gpu, int id) |
| 53 : INHERITED(gpu, false) | 52 : INHERITED(gpu, false) |
| 54 , fID(id) { | 53 , fID(id) { |
| 55 this->registerWithCache(); | |
| 56 } | 54 } |
| 57 | 55 |
| 58 virtual ~TextureResource() { this->release(); } | 56 virtual ~TextureResource() { this->release(); } |
| 59 | 57 |
| 60 virtual size_t gpuMemorySize() const SK_OVERRIDE { | 58 virtual size_t gpuMemorySize() const SK_OVERRIDE { |
| 61 return 100 + ((fID % 1 == 0) ? -40 : 33); | 59 return 100 + ((fID % 1 == 0) ? -40 : 33); |
| 62 } | 60 } |
| 63 | 61 |
| 64 static GrResourceKey ComputeKey(const GrTextureDesc& desc) { | 62 static GrResourceKey ComputeKey(const GrTextureDesc& desc) { |
| 65 return GrTextureImpl::ComputeScratchKey(desc); | 63 return GrTextureImpl::ComputeScratchKey(desc); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 228 } |
| 231 | 229 |
| 232 private: | 230 private: |
| 233 typedef Benchmark INHERITED; | 231 typedef Benchmark INHERITED; |
| 234 }; | 232 }; |
| 235 | 233 |
| 236 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) | 234 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) |
| 237 DEF_BENCH( return new GrResourceCacheBenchFind(); ) | 235 DEF_BENCH( return new GrResourceCacheBenchFind(); ) |
| 238 | 236 |
| 239 #endif | 237 #endif |
| OLD | NEW |