Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 * | 34 * |
| 35 * The latter two ref types are private and intended only for Gr core code. | 35 * The latter two ref types are private and intended only for Gr core code. |
| 36 * | 36 * |
| 37 * When an item is purgable DERIVED:notifyIsPurgable() will be called (static po ly morphism using | 37 * When an item is purgable DERIVED:notifyIsPurgable() will be called (static po ly morphism using |
| 38 * CRTP). GrIORef and GrGpuResource are separate classes for organizational reas ons and to be | 38 * CRTP). GrIORef and GrGpuResource are separate classes for organizational reas ons and to be |
| 39 * able to give access via friendship to only the functions related to pending I O operations. | 39 * able to give access via friendship to only the functions related to pending I O operations. |
| 40 */ | 40 */ |
| 41 template <typename DERIVED> class GrIORef : public SkNoncopyable { | 41 template <typename DERIVED> class GrIORef : public SkNoncopyable { |
| 42 public: | 42 public: |
| 43 SK_DECLARE_INST_COUNT_ROOT(GrIORef) | 43 SK_DECLARE_INST_COUNT_ROOT(GrIORef) |
| 44 virtual ~GrIORef(); | 44 |
| 45 virtual ~GrIORef() { | |
|
mtklein
2014/10/08 17:57:14
Drop this virtual? Seems like you don't have any
bsalomon
2014/10/08 18:01:53
Good point, will remove the virtual
| |
| 46 SkASSERT(0 == fRefCnt); | |
| 47 SkASSERT(0 == fPendingReads); | |
| 48 SkASSERT(0 == fPendingWrites); | |
| 49 // Set to invalid values. | |
| 50 SkDEBUGCODE(fRefCnt = fPendingReads = fPendingWrites = -10;) | |
| 51 } | |
| 45 | 52 |
| 46 // Some of the signatures are written to mirror SkRefCnt so that GrGpuResour ce can work with | 53 // Some of the signatures are written to mirror SkRefCnt so that GrGpuResour ce can work with |
| 47 // templated helper classes (e.g. SkAutoTUnref). However, we have different categories of | 54 // templated helper classes (e.g. SkAutoTUnref). However, we have different categories of |
| 48 // refs (e.g. pending reads). We also don't require thread safety as GrCache able objects are | 55 // refs (e.g. pending reads). We also don't require thread safety as GrCache able objects are |
| 49 // not intended to cross thread boundaries. | 56 // not intended to cross thread boundaries. |
| 50 void ref() const { | 57 void ref() const { |
| 51 this->validate(); | 58 this->validate(); |
| 52 ++fRefCnt; | 59 ++fRefCnt; |
| 53 } | 60 } |
| 54 | 61 |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache | 267 GrResourceCacheEntry* fCacheEntry; // NULL if not in cache |
| 261 const uint32_t fUniqueID; | 268 const uint32_t fUniqueID; |
| 262 | 269 |
| 263 GrResourceKey fScratchKey; | 270 GrResourceKey fScratchKey; |
| 264 | 271 |
| 265 typedef GrIORef<GrGpuResource> INHERITED; | 272 typedef GrIORef<GrGpuResource> INHERITED; |
| 266 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. | 273 friend class GrIORef<GrGpuResource>; // to access notifyIsPurgable. |
| 267 }; | 274 }; |
| 268 | 275 |
| 269 #endif | 276 #endif |
| OLD | NEW |