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 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 this->registerWithCache(); | 57 this->registerWithCache(); |
58 } | 58 } |
59 | 59 |
60 virtual ~TextureResource() { this->release(); } | 60 virtual ~TextureResource() { this->release(); } |
61 | 61 |
62 virtual size_t gpuMemorySize() const SK_OVERRIDE { | 62 virtual size_t gpuMemorySize() const SK_OVERRIDE { |
63 return 100 + ((fID % 1 == 0) ? -40 : 33); | 63 return 100 + ((fID % 1 == 0) ? -40 : 33); |
64 } | 64 } |
65 | 65 |
66 static GrResourceKey ComputeKey(const GrTextureDesc& desc) { | 66 static GrResourceKey ComputeKey(const GrTextureDesc& desc) { |
67 return GrTexturePriv::ComputeScratchKey(desc); | 67 GrCacheID::Key key; |
| 68 memset(&key, 0, sizeof(key)); |
| 69 key.fData32[0] = (desc.fWidth) | (desc.fHeight << 16); |
| 70 key.fData32[1] = desc.fConfig | desc.fSampleCnt << 16; |
| 71 key.fData32[2] = desc.fFlags; |
| 72 static int gType = GrResourceKey::GenerateResourceType(); |
| 73 static int gDomain = GrCacheID::GenerateDomain(); |
| 74 return GrResourceKey(GrCacheID(gDomain, key), gType, 0); |
68 } | 75 } |
69 | 76 |
70 int fID; | 77 int fID; |
71 | 78 |
72 private: | 79 private: |
73 typedef GrGpuResource INHERITED; | 80 typedef GrGpuResource INHERITED; |
74 }; | 81 }; |
75 | 82 |
76 static void get_stencil(int i, int* w, int* h, int* s) { | 83 static void get_stencil(int i, int* w, int* h, int* s) { |
77 *w = i % 1024; | 84 *w = i % 1024; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 239 } |
233 | 240 |
234 private: | 241 private: |
235 typedef Benchmark INHERITED; | 242 typedef Benchmark INHERITED; |
236 }; | 243 }; |
237 | 244 |
238 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) | 245 DEF_BENCH( return new GrResourceCacheBenchAdd(); ) |
239 DEF_BENCH( return new GrResourceCacheBenchFind(); ) | 246 DEF_BENCH( return new GrResourceCacheBenchFind(); ) |
240 | 247 |
241 #endif | 248 #endif |
OLD | NEW |