| 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 26 matching lines...) Expand all Loading... |
| 37 void ref() const { | 37 void ref() const { |
| 38 // Once the ref cnt reaches zero it should never be ref'ed again. | 38 // Once the ref cnt reaches zero it should never be ref'ed again. |
| 39 SkASSERT(fRefCnt > 0); | 39 SkASSERT(fRefCnt > 0); |
| 40 this->validate(); | 40 this->validate(); |
| 41 ++fRefCnt; | 41 ++fRefCnt; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void unref() const { | 44 void unref() const { |
| 45 this->validate(); | 45 this->validate(); |
| 46 --fRefCnt; | 46 --fRefCnt; |
| 47 if (0 == fRefCnt && 0 == fPendingExecutions) { | 47 if (0 == fRefCnt) { |
| 48 SkDELETE(this); | 48 if (0 == fPendingExecutions) { |
| 49 SkDELETE(this); |
| 50 } else { |
| 51 this->removeRefs(); |
| 52 } |
| 49 } | 53 } |
| 50 } | 54 } |
| 51 | 55 |
| 52 /** | 56 /** |
| 53 * Gets an id that is unique for this GrProgramElement object. This will nev
er return 0. | 57 * Gets an id that is unique for this GrProgramElement object. This will nev
er return 0. |
| 54 */ | 58 */ |
| 55 uint32_t getUniqueID() const { return fUniqueID; } | 59 uint32_t getUniqueID() const { return fUniqueID; } |
| 56 | 60 |
| 57 void validate() const { | 61 void validate() const { |
| 58 #ifdef SK_DEBUG | 62 #ifdef SK_DEBUG |
| (...skipping 14 matching lines...) Expand all Loading... |
| 73 fGpuResources.push_back(res); | 77 fGpuResources.push_back(res); |
| 74 } | 78 } |
| 75 | 79 |
| 76 private: | 80 private: |
| 77 static uint32_t CreateUniqueID(); | 81 static uint32_t CreateUniqueID(); |
| 78 | 82 |
| 79 void convertRefToPendingExecution() const; | 83 void convertRefToPendingExecution() const; |
| 80 | 84 |
| 81 void completedExecution() const; | 85 void completedExecution() const; |
| 82 | 86 |
| 87 void removeRefs() const; |
| 88 |
| 83 mutable int32_t fRefCnt; | 89 mutable int32_t fRefCnt; |
| 84 // Count of deferred executions not yet issued to the 3D API. | 90 // Count of deferred executions not yet issued to the 3D API. |
| 85 mutable int32_t fPendingExecutions; | 91 mutable int32_t fPendingExecutions; |
| 86 uint32_t fUniqueID; | 92 uint32_t fUniqueID; |
| 87 | 93 |
| 88 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources; | 94 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources; |
| 89 | 95 |
| 90 // Only this class can access convertRefToPendingExecution() and completedEx
ecution(). | 96 // Only this class can access convertRefToPendingExecution() and completedEx
ecution(). |
| 91 template <typename T> friend class GrProgramElementRef; | 97 template <typename T> friend class GrProgramElementRef; |
| 92 | 98 |
| 93 typedef SkNoncopyable INHERITED; | 99 typedef SkNoncopyable INHERITED; |
| 94 }; | 100 }; |
| 95 | 101 |
| 96 #endif | 102 #endif |
| OLD | NEW |