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

Side by Side Diff: include/gpu/GrGpuResource.h

Issue 796163002: Adding a custom data field to GrGpuResource (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ref Created 6 years 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 | src/gpu/GrGpuResource.cpp » ('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 * 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 GrGpuResource_DEFINED 8 #ifndef GrGpuResource_DEFINED
9 #define GrGpuResource_DEFINED 9 #define GrGpuResource_DEFINED
10 10
11 #include "GrResourceKey.h" 11 #include "GrResourceKey.h"
12 #include "GrTypesPriv.h" 12 #include "GrTypesPriv.h"
13 #include "SkData.h"
13 #include "SkInstCnt.h" 14 #include "SkInstCnt.h"
14 #include "SkTInternalLList.h" 15 #include "SkTInternalLList.h"
15 16
16 class GrContext; 17 class GrContext;
17 class GrGpu; 18 class GrGpu;
18 class GrResourceCache2; 19 class GrResourceCache2;
19 20
20 /** 21 /**
21 * Base class for GrGpuResource. Handles the various types of refs we need. Sepa rated out as a base 22 * Base class for GrGpuResource. Handles the various types of refs we need. Sepa rated out as a base
22 * class to isolate the ref-cnting behavior and provide friendship without expos ing all of 23 * class to isolate the ref-cnting behavior and provide friendship without expos ing all of
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 162 }
162 163
163 /** 164 /**
164 * Gets an id that is unique for this GrGpuResource object. It is static in that it does 165 * Gets an id that is unique for this GrGpuResource object. It is static in that it does
165 * not change when the content of the GrGpuResource object changes. This wil l never return 166 * not change when the content of the GrGpuResource object changes. This wil l never return
166 * 0. 167 * 0.
167 */ 168 */
168 uint32_t getUniqueID() const { return fUniqueID; } 169 uint32_t getUniqueID() const { return fUniqueID; }
169 170
170 /** 171 /**
172 * Attach a custom data object to this resource. The data will remain attach ed
173 * for the lifetime of this resource (until it is abandoned or released).
174 * Takes a ref on data. Previously attached data, if any, is unrefed.
175 * Returns the data argument, for convenience.
176 */
177 const SkData* setCustomData(const SkData* data);
178
179 /**
180 * Returns the custom data object that was attached to this resource by
181 * calling setCustomData.
182 */
183 const SkData* getCustomData() const { return fData.get(); }
184
185 /**
171 * Internal-only helper class used for cache manipulations of the reosurce. 186 * Internal-only helper class used for cache manipulations of the reosurce.
172 */ 187 */
173 class CacheAccess; 188 class CacheAccess;
174 inline CacheAccess cacheAccess(); 189 inline CacheAccess cacheAccess();
175 inline const CacheAccess cacheAccess() const; 190 inline const CacheAccess cacheAccess() const;
176 191
177 /** 192 /**
178 * Removes references to objects in the underlying 3D API without freeing th em. 193 * Removes references to objects in the underlying 3D API without freeing th em.
179 * Called by CacheAccess. 194 * Called by CacheAccess.
180 * In general this method should not be called outside of skia. It was 195 * In general this method should not be called outside of skia. It was
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 GrResourceKey fContentKey; 280 GrResourceKey fContentKey;
266 281
267 // This is not ref'ed but abandon() or release() will be called before the G rGpu object 282 // This is not ref'ed but abandon() or release() will be called before the G rGpu object
268 // is destroyed. Those calls set will this to NULL. 283 // is destroyed. Those calls set will this to NULL.
269 GrGpu* fGpu; 284 GrGpu* fGpu;
270 mutable size_t fGpuMemorySize; 285 mutable size_t fGpuMemorySize;
271 286
272 uint32_t fFlags; 287 uint32_t fFlags;
273 const uint32_t fUniqueID; 288 const uint32_t fUniqueID;
274 289
290 SkAutoTUnref<const SkData> fData;
291
275 typedef GrIORef<GrGpuResource> INHERITED; 292 typedef GrIORef<GrGpuResource> INHERITED;
276 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. 293 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable.
277 }; 294 };
278 295
279 #endif 296 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrGpuResource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698