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

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

Issue 940463006: Rename GrContentKey to GrUniqueKey (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 5 years, 10 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/GrGpuResourceCacheAccess.h ('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 2015 Google Inc. 3 * Copyright 2015 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 GrGpuResourcePriv_DEFINED 9 #ifndef GrGpuResourcePriv_DEFINED
10 #define GrGpuResourcePriv_DEFINED 10 #define GrGpuResourcePriv_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 and budget 15 * This class allows code internal to Skia privileged access to manage the cache keys and budget
16 * status of a GrGpuResource object. 16 * status of a GrGpuResource object.
17 */ 17 */
18 class GrGpuResource::ResourcePriv { 18 class GrGpuResource::ResourcePriv {
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 unique key for the resource. If the resource was previously cached 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 uniquely-keyed resource. Currently this may only be cal led once per
23 * fails if there is already a resource with the same content key. TODO: mak e this supplant the 23 * resource. It fails if there is already a resource with the same unique ke y. TODO: make this
24 * resource that currently is using the content key, allow resources' conten t keys to change, 24 * supplant the resource that currently is using the unique key, allow resou rces' unique keys
25 * and allow removal of a content key to convert a resource back to scratch. 25 * to change, and allow removal of a unique key to convert a resource back t o scratch.
26 */ 26 */
27 bool setContentKey(const GrContentKey& contentKey) { 27 bool setUniqueKey(const GrUniqueKey& key) {
28 return fResource->setContentKey(contentKey); 28 return fResource->setUniqueKey(key);
29 } 29 }
30 30
31 /** Removes the content key from a resource */ 31 /** Removes the unique key from a resource */
32 void removeContentKey() { return fResource->removeContentKey(); } 32 void removeUniqueKey() { return fResource->removeUniqueKey(); }
33 33
34 /** 34 /**
35 * If the resource is uncached make it cached. Has no effect on resources th at are wrapped or 35 * If the resource is uncached make it cached. Has no effect on resources th at are wrapped or
36 * already cached. 36 * already cached.
37 */ 37 */
38 void makeBudgeted() { fResource->makeBudgeted(); } 38 void makeBudgeted() { fResource->makeBudgeted(); }
39 39
40 /** 40 /**
41 * If the resource is cached make it uncached. Has no effect on resources th at are wrapped or 41 * If the resource is cached make it uncached. Has no effect on resources th at are wrapped or
42 * already uncached. Furthermore, resources with content keys cannot be made unbudgeted. 42 * already uncached. Furthermore, resources with unique keys cannot be made unbudgeted.
43 */ 43 */
44 void makeUnbudgeted() { fResource->makeUnbudgeted(); } 44 void makeUnbudgeted() { fResource->makeUnbudgeted(); }
45 45
46 /** 46 /**
47 * Does the resource count against the resource budget? 47 * Does the resource count against the resource budget?
48 */ 48 */
49 bool isBudgeted() const { 49 bool isBudgeted() const {
50 bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle; 50 bool ret = GrGpuResource::kCached_LifeCycle == fResource->fLifeCycle;
51 SkASSERT(ret || !fResource->getContentKey().isValid()); 51 SkASSERT(ret || !fResource->getUniqueKey().isValid());
52 return ret; 52 return ret;
53 } 53 }
54 54
55 /** 55 /**
56 * If this resource can be used as a scratch resource this returns a valid s cratch key. 56 * If this resource can be used as a scratch resource this returns a valid s cratch key.
57 * Otherwise it returns a key for which isNullScratch is true. The resource may currently be 57 * Otherwise it returns a key for which isNullScratch is true. The resource may currently be
58 * used as a content resource rather than scratch. Check isScratch(). 58 * used as a uniquely keyed resource rather than scratch. Check isScratch().
59 */ 59 */
60 const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; } 60 const GrScratchKey& getScratchKey() const { return fResource->fScratchKey; }
61 61
62 /** 62 /**
63 * If the resource has a scratch key, the key will be removed. Since scratch keys are installed 63 * If the resource has a scratch key, the key will be removed. Since scratch keys are installed
64 * at resource creation time, this means the resource will never again be us ed as scratch. 64 * at resource creation time, this means the resource will never again be us ed as scratch.
65 */ 65 */
66 void removeScratchKey() const { fResource->removeScratchKey(); } 66 void removeScratchKey() const { fResource->removeScratchKey(); }
67 67
68 protected: 68 protected:
(...skipping 10 matching lines...) Expand all
79 friend class GrGpuResource; // to construct/copy this type. 79 friend class GrGpuResource; // to construct/copy this type.
80 }; 80 };
81 81
82 inline GrGpuResource::ResourcePriv GrGpuResource::resourcePriv() { return Resour cePriv(this); } 82 inline GrGpuResource::ResourcePriv GrGpuResource::resourcePriv() { return Resour cePriv(this); }
83 83
84 inline const GrGpuResource::ResourcePriv GrGpuResource::resourcePriv() const { 84 inline const GrGpuResource::ResourcePriv GrGpuResource::resourcePriv() const {
85 return ResourcePriv(const_cast<GrGpuResource*>(this)); 85 return ResourcePriv(const_cast<GrGpuResource*>(this));
86 } 86 }
87 87
88 #endif 88 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpuResourceCacheAccess.h ('k') | src/gpu/GrPath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698