| 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 GrGpuResource_DEFINED | 8 #ifndef GrGpuResource_DEFINED |
| 9 #define GrGpuResource_DEFINED | 9 #define GrGpuResource_DEFINED |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 */ | 167 */ |
| 168 uint32_t getUniqueID() const { return fUniqueID; } | 168 uint32_t getUniqueID() const { return fUniqueID; } |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * Internal-only helper class used for cache manipulations of the reosurce. | 171 * Internal-only helper class used for cache manipulations of the reosurce. |
| 172 */ | 172 */ |
| 173 class CacheAccess; | 173 class CacheAccess; |
| 174 inline CacheAccess cacheAccess(); | 174 inline CacheAccess cacheAccess(); |
| 175 inline const CacheAccess cacheAccess() const; | 175 inline const CacheAccess cacheAccess() const; |
| 176 | 176 |
| 177 /** |
| 178 * Removes references to objects in the underlying 3D API without freeing th
em. |
| 179 * Called by CacheAccess. |
| 180 * In general this method should not be called outside of skia. It was |
| 181 * made by public for a special case where it needs to be called in Blink |
| 182 * when a texture becomes unsafe to use after having been shared through |
| 183 * a texture mailbox. |
| 184 */ |
| 185 void abandon(); |
| 186 |
| 177 protected: | 187 protected: |
| 178 // This must be called by every GrGpuObject. It should be called once the ob
ject is fully | 188 // This must be called by every GrGpuObject. It should be called once the ob
ject is fully |
| 179 // initialized (i.e. not in a base class constructor). | 189 // initialized (i.e. not in a base class constructor). |
| 180 void registerWithCache(); | 190 void registerWithCache(); |
| 181 | 191 |
| 182 GrGpuResource(GrGpu*, bool isWrapped); | 192 GrGpuResource(GrGpu*, bool isWrapped); |
| 183 virtual ~GrGpuResource(); | 193 virtual ~GrGpuResource(); |
| 184 | 194 |
| 185 GrGpu* getGpu() const { return fGpu; } | 195 GrGpu* getGpu() const { return fGpu; } |
| 186 | 196 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 204 * By default resources are not usable as scratch. This should only be calle
d once. | 214 * By default resources are not usable as scratch. This should only be calle
d once. |
| 205 **/ | 215 **/ |
| 206 void setScratchKey(const GrResourceKey& scratchKey); | 216 void setScratchKey(const GrResourceKey& scratchKey); |
| 207 | 217 |
| 208 private: | 218 private: |
| 209 /** | 219 /** |
| 210 * Frees the object in the underlying 3D API. Called by CacheAccess. | 220 * Frees the object in the underlying 3D API. Called by CacheAccess. |
| 211 */ | 221 */ |
| 212 void release(); | 222 void release(); |
| 213 | 223 |
| 214 /** | |
| 215 * Removes references to objects in the underlying 3D API without freeing th
em. | |
| 216 * Called by CacheAccess. | |
| 217 */ | |
| 218 void abandon(); | |
| 219 | |
| 220 virtual size_t onGpuMemorySize() const = 0; | 224 virtual size_t onGpuMemorySize() const = 0; |
| 221 | 225 |
| 222 // See comments in CacheAccess. | 226 // See comments in CacheAccess. |
| 223 bool setContentKey(const GrResourceKey& contentKey); | 227 bool setContentKey(const GrResourceKey& contentKey); |
| 224 void setBudgeted(bool countsAgainstBudget); | 228 void setBudgeted(bool countsAgainstBudget); |
| 225 void notifyIsPurgable() const; | 229 void notifyIsPurgable() const; |
| 226 void removeScratchKey(); | 230 void removeScratchKey(); |
| 227 | 231 |
| 228 #ifdef SK_DEBUG | 232 #ifdef SK_DEBUG |
| 229 friend class GrGpu; // for assert in GrGpu to access getGpu | 233 friend class GrGpu; // for assert in GrGpu to access getGpu |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 mutable size_t fGpuMemorySize; | 270 mutable size_t fGpuMemorySize; |
| 267 | 271 |
| 268 uint32_t fFlags; | 272 uint32_t fFlags; |
| 269 const uint32_t fUniqueID; | 273 const uint32_t fUniqueID; |
| 270 | 274 |
| 271 typedef GrIORef<GrGpuResource> INHERITED; | 275 typedef GrIORef<GrGpuResource> INHERITED; |
| 272 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. | 276 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. |
| 273 }; | 277 }; |
| 274 | 278 |
| 275 #endif | 279 #endif |
| OLD | NEW |