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 |
11 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
12 #include "SkTArray.h" | 12 #include "SkTArray.h" |
13 | 13 |
14 class GrGpuResourceRef; | 14 class GrGpuResourceRef; |
15 | 15 |
16 /** | 16 /** |
17 * Base class for GrProcessor. GrDrawState uses this to manage | 17 * Base class for GrProcessor. GrDrawState uses this to manage |
18 * transitioning a GrProcessor from being owned by a client to being scheduled f
or execution. It | 18 * transitioning a GrProcessor from being owned by a client to being scheduled f
or execution. It |
19 * converts resources owned by the effect from being ref'ed to having pending re
ads/writes. | 19 * converts resources owned by the effect from being ref'ed to having pending re
ads/writes. |
20 * | 20 * |
21 * All GrGpuResource objects owned by a GrProgramElement or derived classes (eit
her directly or | 21 * All GrGpuResource objects owned by a GrProgramElement or derived classes (eit
her directly or |
22 * indirectly) must be wrapped in a GrGpuResourceRef and registered with the GrP
rogramElement using | 22 * indirectly) must be wrapped in a GrGpuResourceRef and registered with the GrP
rogramElement using |
23 * addGpuResource(). This allows the regular refs to be converted to pending IO
events | 23 * addGpuResource(). This allows the regular refs to be converted to pending IO
events |
24 * when the program element is scheduled for deferred execution. | 24 * when the program element is scheduled for deferred execution. |
25 */ | 25 */ |
26 class GrProgramElement : public SkNoncopyable { | 26 class GrProgramElement : public SkNoncopyable { |
27 public: | 27 public: |
28 SK_DECLARE_INST_COUNT(GrProgramElement) | |
29 | |
30 virtual ~GrProgramElement() { | 28 virtual ~GrProgramElement() { |
31 // fRefCnt can be one when an effect is created statically using GR_CREA
TE_STATIC_EFFECT | 29 // fRefCnt can be one when an effect is created statically using GR_CREA
TE_STATIC_EFFECT |
32 SkASSERT((0 == fRefCnt || 1 == fRefCnt) && 0 == fPendingExecutions); | 30 SkASSERT((0 == fRefCnt || 1 == fRefCnt) && 0 == fPendingExecutions); |
33 // Set to invalid values. | 31 // Set to invalid values. |
34 SkDEBUGCODE(fRefCnt = fPendingExecutions = -10;) | 32 SkDEBUGCODE(fRefCnt = fPendingExecutions = -10;) |
35 } | 33 } |
36 | 34 |
37 void ref() const { | 35 void ref() const { |
38 this->validate(); | 36 this->validate(); |
39 // Once the ref cnt reaches zero it should never be ref'ed again. | 37 // Once the ref cnt reaches zero it should never be ref'ed again. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 116 |
119 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources; | 117 SkSTArray<4, const GrGpuResourceRef*, true> fGpuResources; |
120 | 118 |
121 // Only this class can access addPendingExecution() and completedExecution()
. | 119 // Only this class can access addPendingExecution() and completedExecution()
. |
122 template <typename T> friend class GrPendingProgramElement; | 120 template <typename T> friend class GrPendingProgramElement; |
123 | 121 |
124 typedef SkNoncopyable INHERITED; | 122 typedef SkNoncopyable INHERITED; |
125 }; | 123 }; |
126 | 124 |
127 #endif | 125 #endif |
OLD | NEW |