OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; | 41 fCoordChangeMatrixSet = other.fCoordChangeMatrixSet; |
42 if (other.fCoordChangeMatrixSet) { | 42 if (other.fCoordChangeMatrixSet) { |
43 fCoordChangeMatrix = other.fCoordChangeMatrix; | 43 fCoordChangeMatrix = other.fCoordChangeMatrix; |
44 } | 44 } |
45 fEffectRef.reset(SkRef(other.fEffectRef.get())); | 45 fEffectRef.reset(SkRef(other.fEffectRef.get())); |
46 memcpy(fVertexAttribIndices, other.fVertexAttribIndices, sizeof(fVertexA
ttribIndices)); | 46 memcpy(fVertexAttribIndices, other.fVertexAttribIndices, sizeof(fVertexA
ttribIndices)); |
47 return *this; | 47 return *this; |
48 } | 48 } |
49 | 49 |
50 bool operator== (const GrEffectStage& other) const { | 50 bool operator== (const GrEffectStage& other) const { |
51 GrAssert(NULL != fEffectRef.get()); | 51 SkASSERT(NULL != fEffectRef.get()); |
52 GrAssert(NULL != other.fEffectRef.get()); | 52 SkASSERT(NULL != other.fEffectRef.get()); |
53 | 53 |
54 if (!(*this->getEffect())->isEqual(*other.getEffect())) { | 54 if (!(*this->getEffect())->isEqual(*other.getEffect())) { |
55 return false; | 55 return false; |
56 } | 56 } |
57 | 57 |
58 if (fCoordChangeMatrixSet != other.fCoordChangeMatrixSet) { | 58 if (fCoordChangeMatrixSet != other.fCoordChangeMatrixSet) { |
59 return false; | 59 return false; |
60 } | 60 } |
61 | 61 |
62 if (!fCoordChangeMatrixSet) { | 62 if (!fCoordChangeMatrixSet) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 * This gets the current coordinate system change. It is the accumulation of | 96 * This gets the current coordinate system change. It is the accumulation of |
97 * localCoordChange calls since the effect was installed. It is used when th
en caller | 97 * localCoordChange calls since the effect was installed. It is used when th
en caller |
98 * wants to temporarily change the source geometry coord system, draw someth
ing, and then | 98 * wants to temporarily change the source geometry coord system, draw someth
ing, and then |
99 * restore the previous coord system (e.g. temporarily draw in device coords
). | 99 * restore the previous coord system (e.g. temporarily draw in device coords
). |
100 */ | 100 */ |
101 void saveCoordChange(SavedCoordChange* savedCoordChange) const { | 101 void saveCoordChange(SavedCoordChange* savedCoordChange) const { |
102 savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet; | 102 savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet; |
103 if (fCoordChangeMatrixSet) { | 103 if (fCoordChangeMatrixSet) { |
104 savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix; | 104 savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix; |
105 } | 105 } |
106 GrAssert(NULL == savedCoordChange->fEffectRef.get()); | 106 SkASSERT(NULL == savedCoordChange->fEffectRef.get()); |
107 GR_DEBUGCODE(SkRef(fEffectRef.get());) | 107 GR_DEBUGCODE(SkRef(fEffectRef.get());) |
108 GR_DEBUGCODE(savedCoordChange->fEffectRef.reset(fEffectRef.get());) | 108 GR_DEBUGCODE(savedCoordChange->fEffectRef.reset(fEffectRef.get());) |
109 } | 109 } |
110 | 110 |
111 /** | 111 /** |
112 * This balances the saveCoordChange call. | 112 * This balances the saveCoordChange call. |
113 */ | 113 */ |
114 void restoreCoordChange(const SavedCoordChange& savedCoordChange) { | 114 void restoreCoordChange(const SavedCoordChange& savedCoordChange) { |
115 fCoordChangeMatrixSet = savedCoordChange.fCoordChangeMatrixSet; | 115 fCoordChangeMatrixSet = savedCoordChange.fCoordChangeMatrixSet; |
116 if (fCoordChangeMatrixSet) { | 116 if (fCoordChangeMatrixSet) { |
117 fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix; | 117 fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix; |
118 } | 118 } |
119 GrAssert(savedCoordChange.fEffectRef.get() == fEffectRef); | 119 SkASSERT(savedCoordChange.fEffectRef.get() == fEffectRef); |
120 GR_DEBUGCODE(savedCoordChange.fEffectRef.reset(NULL);) | 120 GR_DEBUGCODE(savedCoordChange.fEffectRef.reset(NULL);) |
121 } | 121 } |
122 | 122 |
123 /** | 123 /** |
124 * Used when storing a deferred GrDrawState. The DeferredStage allows resour
ces owned by its | 124 * Used when storing a deferred GrDrawState. The DeferredStage allows resour
ces owned by its |
125 * GrEffect to be recycled through the cache. | 125 * GrEffect to be recycled through the cache. |
126 */ | 126 */ |
127 class DeferredStage { | 127 class DeferredStage { |
128 public: | 128 public: |
129 DeferredStage() : fEffect(NULL) { | 129 DeferredStage() : fEffect(NULL) { |
130 SkDEBUGCODE(fInitialized = false;) | 130 SkDEBUGCODE(fInitialized = false;) |
131 } | 131 } |
132 | 132 |
133 ~DeferredStage() { | 133 ~DeferredStage() { |
134 if (NULL != fEffect) { | 134 if (NULL != fEffect) { |
135 fEffect->decDeferredRefCounts(); | 135 fEffect->decDeferredRefCounts(); |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 void saveFrom(const GrEffectStage& stage) { | 139 void saveFrom(const GrEffectStage& stage) { |
140 GrAssert(!fInitialized); | 140 SkASSERT(!fInitialized); |
141 GrAssert(NULL != stage.fEffectRef.get()); | 141 SkASSERT(NULL != stage.fEffectRef.get()); |
142 stage.fEffectRef->get()->incDeferredRefCounts(); | 142 stage.fEffectRef->get()->incDeferredRefCounts(); |
143 fEffect = stage.fEffectRef->get(); | 143 fEffect = stage.fEffectRef->get(); |
144 fCoordChangeMatrixSet = stage.fCoordChangeMatrixSet; | 144 fCoordChangeMatrixSet = stage.fCoordChangeMatrixSet; |
145 if (fCoordChangeMatrixSet) { | 145 if (fCoordChangeMatrixSet) { |
146 fCoordChangeMatrix = stage.fCoordChangeMatrix; | 146 fCoordChangeMatrix = stage.fCoordChangeMatrix; |
147 } | 147 } |
148 fVertexAttribIndices[0] = stage.fVertexAttribIndices[0]; | 148 fVertexAttribIndices[0] = stage.fVertexAttribIndices[0]; |
149 fVertexAttribIndices[1] = stage.fVertexAttribIndices[1]; | 149 fVertexAttribIndices[1] = stage.fVertexAttribIndices[1]; |
150 SkDEBUGCODE(fInitialized = true;) | 150 SkDEBUGCODE(fInitialized = true;) |
151 } | 151 } |
152 | 152 |
153 void restoreTo(GrEffectStage* stage) const { | 153 void restoreTo(GrEffectStage* stage) const { |
154 GrAssert(fInitialized); | 154 SkASSERT(fInitialized); |
155 stage->fEffectRef.reset(GrEffect::CreateEffectRef(fEffect)); | 155 stage->fEffectRef.reset(GrEffect::CreateEffectRef(fEffect)); |
156 stage->fCoordChangeMatrixSet = fCoordChangeMatrixSet; | 156 stage->fCoordChangeMatrixSet = fCoordChangeMatrixSet; |
157 if (fCoordChangeMatrixSet) { | 157 if (fCoordChangeMatrixSet) { |
158 stage->fCoordChangeMatrix = fCoordChangeMatrix; | 158 stage->fCoordChangeMatrix = fCoordChangeMatrix; |
159 } | 159 } |
160 stage->fVertexAttribIndices[0] = fVertexAttribIndices[0]; | 160 stage->fVertexAttribIndices[0] = fVertexAttribIndices[0]; |
161 stage->fVertexAttribIndices[1] = fVertexAttribIndices[1]; | 161 stage->fVertexAttribIndices[1] = fVertexAttribIndices[1]; |
162 } | 162 } |
163 | 163 |
164 bool isEqual(const GrEffectStage& stage, bool ignoreCoordChange) const { | 164 bool isEqual(const GrEffectStage& stage, bool ignoreCoordChange) const { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 int getVertexAttribIndexCount() const { return fEffectRef->get()->numVertexA
ttribs(); } | 214 int getVertexAttribIndexCount() const { return fEffectRef->get()->numVertexA
ttribs(); } |
215 | 215 |
216 private: | 216 private: |
217 bool fCoordChangeMatrixSet; | 217 bool fCoordChangeMatrixSet; |
218 SkMatrix fCoordChangeMatrix; | 218 SkMatrix fCoordChangeMatrix; |
219 SkAutoTUnref<const GrEffectRef> fEffectRef; | 219 SkAutoTUnref<const GrEffectRef> fEffectRef; |
220 int fVertexAttribIndices[2]; | 220 int fVertexAttribIndices[2]; |
221 }; | 221 }; |
222 | 222 |
223 #endif | 223 #endif |
OLD | NEW |