| 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 GrProgramElement_DEFINED | 8 #ifndef GrProgramElement_DEFINED |
| 9 #define GrProgramElement_DEFINED | 9 #define GrProgramElement_DEFINED |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 SkASSERT(fRefCnt > 0); | 38 SkASSERT(fRefCnt > 0); |
| 39 ++fRefCnt; | 39 ++fRefCnt; |
| 40 this->validate(); | 40 this->validate(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void unref() const { | 43 void unref() const { |
| 44 this->validate(); | 44 this->validate(); |
| 45 --fRefCnt; | 45 --fRefCnt; |
| 46 if (0 == fRefCnt) { | 46 if (0 == fRefCnt) { |
| 47 if (0 == fPendingExecutions) { | 47 if (0 == fPendingExecutions) { |
| 48 SkDELETE(this); | 48 delete this; |
| 49 return; | 49 return; |
| 50 } else { | 50 } else { |
| 51 this->removeRefs(); | 51 this->removeRefs(); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 this->validate(); | 54 this->validate(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Gets an id that is unique for this GrProgramElement object. This will nev
er return 0. | 58 * Gets an id that is unique for this GrProgramElement object. This will nev
er return 0. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 89 } | 89 } |
| 90 ++fPendingExecutions; | 90 ++fPendingExecutions; |
| 91 this->validate(); | 91 this->validate(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void completedExecution() const { | 94 void completedExecution() const { |
| 95 this->validate(); | 95 this->validate(); |
| 96 --fPendingExecutions; | 96 --fPendingExecutions; |
| 97 if (0 == fPendingExecutions) { | 97 if (0 == fPendingExecutions) { |
| 98 if (0 == fRefCnt) { | 98 if (0 == fRefCnt) { |
| 99 SkDELETE(this); | 99 delete this; |
| 100 return; | 100 return; |
| 101 } else { | 101 } else { |
| 102 this->pendingIOComplete(); | 102 this->pendingIOComplete(); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 this->validate(); | 105 this->validate(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void removeRefs() const; | 108 void removeRefs() const; |
| 109 void addPendingIOs() const; | 109 void addPendingIOs() const; |
| 110 void pendingIOComplete() const; | 110 void pendingIOComplete() const; |
| 111 | 111 |
| 112 mutable int32_t fRefCnt; | 112 mutable int32_t fRefCnt; |
| 113 // Count of deferred executions not yet issued to the 3D API. | 113 // Count of deferred executions not yet issued to the 3D API. |
| 114 mutable int32_t fPendingExecutions; | 114 mutable int32_t fPendingExecutions; |
| 115 uint32_t fUniqueID; | 115 uint32_t fUniqueID; |
| 116 | 116 |
| 117 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources; | 117 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources; |
| 118 | 118 |
| 119 // Only this class can access addPendingExecution() and completedExecution()
. | 119 // Only this class can access addPendingExecution() and completedExecution()
. |
| 120 template <typename T> friend class GrPendingProgramElement; | 120 template <typename T> friend class GrPendingProgramElement; |
| 121 | 121 |
| 122 typedef SkNoncopyable INHERITED; | 122 typedef SkNoncopyable INHERITED; |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 #endif | 125 #endif |
| OLD | NEW |