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 GrProgramElementRef_DEFINED | 8 #ifndef GrProgramElementRef_DEFINED |
9 #define GrProgramElementRef_DEFINED | 9 #define GrProgramElementRef_DEFINED |
10 | 10 |
(...skipping 24 matching lines...) Expand all Loading... |
35 void convertToPendingExec() { | 35 void convertToPendingExec() { |
36 SkASSERT(!fOwnPendingExec); | 36 SkASSERT(!fOwnPendingExec); |
37 fObj->convertRefToPendingExecution(); | 37 fObj->convertRefToPendingExecution(); |
38 fOwnPendingExec = true; | 38 fOwnPendingExec = true; |
39 } | 39 } |
40 | 40 |
41 T* get() const { return fObj; } | 41 T* get() const { return fObj; } |
42 operator T*() { return fObj; } | 42 operator T*() { return fObj; } |
43 | 43 |
44 /** If T is const, the type returned from operator-> will also be const. */ | 44 /** If T is const, the type returned from operator-> will also be const. */ |
45 typedef typename SkTConstType<typename SkAutoTUnref<T>::BlockRef<T>, | 45 typedef typename SkTConstType<typename SkAutoTUnref<T>::template BlockRef<T>
, |
46 SkTIsConst<T>::value>::type BlockRefType; | 46 SkTIsConst<T>::value>::type BlockRefType; |
47 | 47 |
48 /** | 48 /** |
49 * GrProgramElementRef assumes ownership of the ref and manages converting t
he ref to a | 49 * GrProgramElementRef assumes ownership of the ref and manages converting t
he ref to a |
50 * pending execution. As a result, it is an error for the user to ref or unr
ef through | 50 * pending execution. As a result, it is an error for the user to ref or unr
ef through |
51 * GrProgramElementRef. Therefore operator-> returns BlockRef<T>*. | 51 * GrProgramElementRef. Therefore operator-> returns BlockRef<T>*. |
52 */ | 52 */ |
53 BlockRefType *operator->() const { | 53 BlockRefType *operator->() const { |
54 return static_cast<BlockRefType*>(fObj); | 54 return static_cast<BlockRefType*>(fObj); |
55 } | 55 } |
56 | 56 |
57 ~GrProgramElementRef() { | 57 ~GrProgramElementRef() { |
58 if (fObj) { | 58 if (fObj) { |
59 if (fOwnPendingExec) { | 59 if (fOwnPendingExec) { |
60 fObj->completedExecution(); | 60 fObj->completedExecution(); |
61 } else { | 61 } else { |
62 fObj->unref(); | 62 fObj->unref(); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 bool fOwnPendingExec; | 68 bool fOwnPendingExec; |
69 T* fObj; | 69 T* fObj; |
70 | 70 |
71 typedef SkNoncopyable INHERITED; | 71 typedef SkNoncopyable INHERITED; |
72 }; | 72 }; |
73 #endif | 73 #endif |
OLD | NEW |