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

Side by Side Diff: src/gpu/GrGpuResourceCacheAccess.h

Issue 858123002: Add specialized content key class for resources. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove default template arg Created 5 years, 11 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 | « src/gpu/GrGpuResource.cpp ('k') | src/gpu/GrPath.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 2014 Google Inc. 3 * Copyright 2014 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 #ifndef GrGpuResourceCacheAccess_DEFINED 9 #ifndef GrGpuResourceCacheAccess_DEFINED
10 #define GrGpuResourceCacheAccess_DEFINED 10 #define GrGpuResourceCacheAccess_DEFINED
11 11
12 #include "GrGpuResource.h" 12 #include "GrGpuResource.h"
13 13
14 /** 14 /**
15 * This class allows code internal to Skia privileged access to manage the cache keys of a 15 * This class allows code internal to Skia privileged access to manage the cache keys of a
16 * GrGpuResource object. 16 * GrGpuResource object.
17 */ 17 */
18 class GrGpuResource::CacheAccess { 18 class GrGpuResource::CacheAccess {
19 public: 19 public:
20 /** 20 /**
21 * Sets a content key for the resource. If the resource was previously cache d as scratch it will 21 * Sets a content key for the resource. If the resource was previously cache d as scratch it will
22 * be converted to a content resource. Currently this may only be called onc e per resource. It 22 * be converted to a content resource. Currently this may only be called onc e per resource. It
23 * fails if there is already a resource with the same content key. TODO: mak e this supplant the 23 * fails if there is already a resource with the same content key. TODO: mak e this supplant the
24 * resource that currently is using the content key, allow resources' conten t keys to change, 24 * resource that currently is using the content key, allow resources' conten t keys to change,
25 * and allow removal of a content key to convert a resource back to scratch. 25 * and allow removal of a content key to convert a resource back to scratch.
26 */ 26 */
27 bool setContentKey(const GrResourceKey& contentKey) { 27 bool setContentKey(const GrContentKey& contentKey) {
28 return fResource->setContentKey(contentKey); 28 return fResource->setContentKey(contentKey);
29 } 29 }
30 30
31 /** 31 /**
32 * Is the resource currently cached as scratch? This means it has a valid sc ratch key and does 32 * Is the resource currently cached as scratch? This means it has a valid sc ratch key and does
33 * not have a content key. 33 * not have a content key.
34 */ 34 */
35 bool isScratch() const { 35 bool isScratch() const {
36 return NULL == this->getContentKey() && fResource->fScratchKey.isValid() ; 36 return !this->getContentKey().isValid() && fResource->fScratchKey.isVali d();
37 } 37 }
38 38
39 /** 39 /**
40 * If this resource can be used as a scratch resource this returns a valid s cratch key. 40 * If this resource can be used as a scratch resource this returns a valid s cratch key.
41 * Otherwise it returns a key for which isNullScratch is true. The resource may currently be 41 * Otherwise it returns a key for which isNullScratch is true. The resource may currently be
42 * used as a content resource rather than scratch. Check isScratch(). 42 * used as a content resource rather than scratch. Check isScratch().
43 */ 43 */
44 const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; } 44 const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; }
45 45
46 /** 46 /**
47 * If the resource has a scratch key, the key will be removed. Since scratch keys are installed 47 * If the resource has a scratch key, the key will be removed. Since scratch keys are installed
48 * at resource creation time, this means the resource will never again be us ed as scratch. 48 * at resource creation time, this means the resource will never again be us ed as scratch.
49 */ 49 */
50 void removeScratchKey() const { fResource->removeScratchKey(); } 50 void removeScratchKey() const { fResource->removeScratchKey(); }
51 51
52 /** 52 /**
53 * If the resource is currently cached by a content key, the key is returned , otherwise NULL. 53 * If the resource is currently cached by a content key, the key is returned , otherwise NULL.
54 */ 54 */
55 const GrResourceKey* getContentKey() const { 55 const GrContentKey& getContentKey() const { return fResource->fContentKey; }
56 if (fResource->fFlags & GrGpuResource::kContentKeySet_Flag) {
57 return &fResource->fContentKey;
58 }
59 return NULL;
60 }
61 56
62 /** 57 /**
63 * Is the resource object wrapping an externally allocated GPU resource? 58 * Is the resource object wrapping an externally allocated GPU resource?
64 */ 59 */
65 bool isWrapped() const { return GrGpuResource::kWrapped_LifeCycle == fResour ce->fLifeCycle; } 60 bool isWrapped() const { return GrGpuResource::kWrapped_LifeCycle == fResour ce->fLifeCycle; }
66 61
67 /** 62 /**
68 * Does the resource count against the resource budget? 63 * Does the resource count against the resource budget?
69 */ 64 */
70 bool isBudgeted() const { return GrGpuResource::kCached_LifeCycle == fResour ce->fLifeCycle; } 65 bool isBudgeted() const { return GrGpuResource::kCached_LifeCycle == fResour ce->fLifeCycle; }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 friend class GrGpuResource; // to construct/copy this type. 104 friend class GrGpuResource; // to construct/copy this type.
110 }; 105 };
111 106
112 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc ess(this); } 107 inline GrGpuResource::CacheAccess GrGpuResource::cacheAccess() { return CacheAcc ess(this); }
113 108
114 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const { 109 inline const GrGpuResource::CacheAccess GrGpuResource::cacheAccess() const {
115 return CacheAccess(const_cast<GrGpuResource*>(this)); 110 return CacheAccess(const_cast<GrGpuResource*>(this));
116 } 111 }
117 112
118 #endif 113 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpuResource.cpp ('k') | src/gpu/GrPath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698