OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrGpuResourceCacheAccess_DEFINED | 8 #ifndef GrGpuResourceCacheAccess_DEFINED |
9 #define GrGpuResourceCacheAccess_DEFINED | 9 #define GrGpuResourceCacheAccess_DEFINED |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 /** | 23 /** |
24 * Is the resource currently cached as scratch? This means it is cached, has
a valid scratch | 24 * Is the resource currently cached as scratch? This means it is cached, has
a valid scratch |
25 * key, and does not have a unique key. | 25 * key, and does not have a unique key. |
26 */ | 26 */ |
27 bool isScratch() const { | 27 bool isScratch() const { |
28 return !fResource->getUniqueKey().isValid() && fResource->fScratchKey.is
Valid() && | 28 return !fResource->getUniqueKey().isValid() && fResource->fScratchKey.is
Valid() && |
29 SkBudgeted::kYes == fResource->resourcePriv().isBudgeted(); | 29 SkBudgeted::kYes == fResource->resourcePriv().isBudgeted(); |
30 } | 30 } |
31 | 31 |
32 /** | 32 /** |
33 * Is the resource object wrapping an externally allocated GPU resource that
Skia has not taken | |
34 * ownership of. | |
35 */ | |
36 bool isBorrowed() const { return GrGpuResource::kBorrowed_LifeCycle == fReso
urce->fLifeCycle; } | |
37 | |
38 /** | |
39 * Is the resource object wrapping an externally allocated GPU resource that
Skia has taken | |
40 * ownership of. | |
41 */ | |
42 bool isAdopted() const { return GrGpuResource::kAdopted_LifeCycle == fResour
ce->fLifeCycle; } | |
43 | |
44 /** | |
45 * Called by the cache to delete the resource under normal circumstances. | 33 * Called by the cache to delete the resource under normal circumstances. |
46 */ | 34 */ |
47 void release() { | 35 void release() { |
48 fResource->release(); | 36 fResource->release(); |
49 if (fResource->isPurgeable()) { | 37 if (fResource->isPurgeable()) { |
50 delete fResource; | 38 delete fResource; |
51 } | 39 } |
52 } | 40 } |
53 | 41 |
54 /** | 42 /** |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 friend void test_unbudgeted_to_scratch(skiatest::Reporter* reporter); // for
unit testing | 75 friend void test_unbudgeted_to_scratch(skiatest::Reporter* reporter); // for
unit testing |
88 }; | 76 }; |
89 | 77 |
90 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } | 78 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc
ess(this); } |
91 | 79 |
92 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { | 80 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { |
93 return CacheAccess(const_cast<GrGpuResource*>(this)); | 81 return CacheAccess(const_cast<GrGpuResource*>(this)); |
94 } | 82 } |
95 | 83 |
96 #endif | 84 #endif |
OLD | NEW |