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 28 matching lines...) Expand all Loading... |
39 * before notifyIsPurgeable(). Moreover, if notifyRefCountIsZero() returns false
then | 39 * before notifyIsPurgeable(). Moreover, if notifyRefCountIsZero() returns false
then |
40 * notifyAllRefCntsAreZero() won't be called at all. notifyRefCountIsZero() must
return false if the | 40 * notifyAllRefCntsAreZero() won't be called at all. notifyRefCountIsZero() must
return false if the |
41 * object may be deleted after notifyRefCntIsZero() returns. | 41 * object may be deleted after notifyRefCntIsZero() returns. |
42 * | 42 * |
43 * GrIORef and GrGpuResource are separate classes for organizational reasons and
to be | 43 * GrIORef and GrGpuResource are separate classes for organizational reasons and
to be |
44 * able to give access via friendship to only the functions related to pending I
O operations. | 44 * able to give access via friendship to only the functions related to pending I
O operations. |
45 */ | 45 */ |
46 template <typename DERIVED> class GrIORef : public SkNoncopyable { | 46 template <typename DERIVED> class GrIORef : public SkNoncopyable { |
47 public: | 47 public: |
48 // Some of the signatures are written to mirror SkRefCnt so that GrGpuResour
ce can work with | 48 // Some of the signatures are written to mirror SkRefCnt so that GrGpuResour
ce can work with |
49 // templated helper classes (e.g. SkAutoTUnref). However, we have different
categories of | 49 // templated helper classes (e.g. sk_sp). However, we have different categor
ies of |
50 // refs (e.g. pending reads). We also don't require thread safety as GrCache
able objects are | 50 // refs (e.g. pending reads). We also don't require thread safety as GrCache
able objects are |
51 // not intended to cross thread boundaries. | 51 // not intended to cross thread boundaries. |
52 void ref() const { | 52 void ref() const { |
53 this->validate(); | 53 this->validate(); |
54 ++fRefCnt; | 54 ++fRefCnt; |
55 } | 55 } |
56 | 56 |
57 void unref() const { | 57 void unref() const { |
58 this->validate(); | 58 this->validate(); |
59 | 59 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 300 |
301 SkBudgeted fBudgeted; | 301 SkBudgeted fBudgeted; |
302 bool fRefsWrappedObjects; | 302 bool fRefsWrappedObjects; |
303 const uint32_t fUniqueID; | 303 const uint32_t fUniqueID; |
304 | 304 |
305 typedef GrIORef<GrGpuResource> INHERITED; | 305 typedef GrIORef<GrGpuResource> INHERITED; |
306 friend class GrIORef<GrGpuResource>; // to access notifyAllCntsAreZero and n
otifyRefCntIsZero. | 306 friend class GrIORef<GrGpuResource>; // to access notifyAllCntsAreZero and n
otifyRefCntIsZero. |
307 }; | 307 }; |
308 | 308 |
309 #endif | 309 #endif |
OLD | NEW |