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

Side by Side Diff: bench/GrResourceCacheBench.cpp

Issue 504313002: Make GrGpuResources register with GrResourceCache2 after fully constructed. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix insertion for GlyphPathRange. Created 6 years, 3 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/GrGpuResource.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 #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();
30 } 31 }
31 32
32 virtual ~StencilResource() { this->release(); } 33 virtual ~StencilResource() { this->release(); }
33 34
34 virtual size_t gpuMemorySize() const SK_OVERRIDE { 35 virtual size_t gpuMemorySize() const SK_OVERRIDE {
35 return 100 + ((fID % 1 == 0) ? -5 : 6); 36 return 100 + ((fID % 1 == 0) ? -5 : 6);
36 } 37 }
37 38
38 static GrResourceKey ComputeKey(int width, int height, int sampleCnt) { 39 static GrResourceKey ComputeKey(int width, int height, int sampleCnt) {
39 return GrStencilBuffer::ComputeKey(width, height, sampleCnt); 40 return GrStencilBuffer::ComputeKey(width, height, sampleCnt);
40 } 41 }
41 42
42 int fID; 43 int fID;
43 44
44 private: 45 private:
45 typedef GrGpuResource INHERITED; 46 typedef GrGpuResource INHERITED;
46 }; 47 };
47 48
48 class TextureResource : public GrGpuResource { 49 class TextureResource : public GrGpuResource {
49 public: 50 public:
50 SK_DECLARE_INST_COUNT(TextureResource); 51 SK_DECLARE_INST_COUNT(TextureResource);
51 TextureResource(GrGpu* gpu, int id) 52 TextureResource(GrGpu* gpu, int id)
52 : INHERITED(gpu, false) 53 : INHERITED(gpu, false)
53 , fID(id) { 54 , fID(id) {
55 this->registerWithCache();
54 } 56 }
55 57
56 virtual ~TextureResource() { this->release(); } 58 virtual ~TextureResource() { this->release(); }
57 59
58 virtual size_t gpuMemorySize() const SK_OVERRIDE { 60 virtual size_t gpuMemorySize() const SK_OVERRIDE {
59 return 100 + ((fID % 1 == 0) ? -40 : 33); 61 return 100 + ((fID % 1 == 0) ? -40 : 33);
60 } 62 }
61 63
62 static GrResourceKey ComputeKey(const GrTextureDesc& desc) { 64 static GrResourceKey ComputeKey(const GrTextureDesc& desc) {
63 return GrTextureImpl::ComputeScratchKey(desc); 65 return GrTextureImpl::ComputeScratchKey(desc);
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 230 }
229 231
230 private: 232 private:
231 typedef Benchmark INHERITED; 233 typedef Benchmark INHERITED;
232 }; 234 };
233 235
234 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) 236 DEF_BENCH( return new GrResourceCacheBenchAdd(); )
235 DEF_BENCH( return new GrResourceCacheBenchFind(); ) 237 DEF_BENCH( return new GrResourceCacheBenchFind(); )
236 238
237 #endif 239 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrGpuResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698