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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 fEffect->decDeferredRefCounts(); | 109 fEffect->decDeferredRefCounts(); |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 void saveFrom(const GrEffectStage& stage) { | 113 void saveFrom(const GrEffectStage& stage) { |
114 GrAssert(!fInitialized); | 114 GrAssert(!fInitialized); |
115 if (NULL != stage.fEffectRef) { | 115 if (NULL != stage.fEffectRef) { |
116 stage.fEffectRef->get()->incDeferredRefCounts(); | 116 stage.fEffectRef->get()->incDeferredRefCounts(); |
117 fEffect = stage.fEffectRef->get(); | 117 fEffect = stage.fEffectRef->get(); |
118 fCoordChangeMatrix = stage.fCoordChangeMatrix; | 118 fCoordChangeMatrix = stage.fCoordChangeMatrix; |
| 119 fVertexAttribIndices = stage.fVertexAttribIndices; |
119 } | 120 } |
120 SkDEBUGCODE(fInitialized = true;) | 121 SkDEBUGCODE(fInitialized = true;) |
121 } | 122 } |
122 | 123 |
123 void restoreTo(GrEffectStage* stage) { | 124 void restoreTo(GrEffectStage* stage) { |
124 GrAssert(fInitialized); | 125 GrAssert(fInitialized); |
125 const GrEffectRef* oldEffectRef = stage->fEffectRef; | 126 const GrEffectRef* oldEffectRef = stage->fEffectRef; |
126 if (NULL != fEffect) { | 127 if (NULL != fEffect) { |
127 stage->fEffectRef = GrEffect::CreateEffectRef(fEffect); | 128 stage->fEffectRef = GrEffect::CreateEffectRef(fEffect); |
128 stage->fCoordChangeMatrix = fCoordChangeMatrix; | 129 stage->fCoordChangeMatrix = fCoordChangeMatrix; |
| 130 stage->fVertexAttribIndices = fVertexAttribIndices; |
129 } else { | 131 } else { |
130 stage->fEffectRef = NULL; | 132 stage->fEffectRef = NULL; |
131 } | 133 } |
132 SkSafeUnref(oldEffectRef); | 134 SkSafeUnref(oldEffectRef); |
133 } | 135 } |
134 | 136 |
135 bool isEqual(const GrEffectStage& stage) const { | 137 bool isEqual(const GrEffectStage& stage) const { |
136 if (NULL == stage.fEffectRef) { | 138 if (NULL == stage.fEffectRef) { |
137 return NULL == fEffect; | 139 return NULL == fEffect; |
138 } else if (NULL == fEffect) { | 140 } else if (NULL == fEffect) { |
139 return false; | 141 return false; |
140 } | 142 } |
141 | 143 |
142 if (!(*stage.getEffect())->isEqual(*fEffect)) { | 144 if (fVertexAttribIndices != stage.fVertexAttribIndices) { |
143 return false; | 145 return false; |
144 } | 146 } |
145 | 147 |
| 148 if (!(*stage.getEffect())->isEqual(*fEffect)) { |
| 149 return false; |
| 150 } |
| 151 |
146 return fCoordChangeMatrix == stage.fCoordChangeMatrix; | 152 return fCoordChangeMatrix == stage.fCoordChangeMatrix; |
147 } | 153 } |
148 | 154 |
149 private: | 155 private: |
150 const GrEffect* fEffect; | 156 const GrEffect* fEffect; |
151 SkMatrix fCoordChangeMatrix; | 157 SkMatrix fCoordChangeMatrix; |
| 158 SkSTArray<GrEffect::kMaxVertexAttribs, int, true> fVertexAttribIndices; |
152 SkDEBUGCODE(bool fInitialized;) | 159 SkDEBUGCODE(bool fInitialized;) |
153 }; | 160 }; |
154 | 161 |
155 /** | 162 /** |
156 * Gets the matrix representing all changes of coordinate system since the G
rEffect was | 163 * Gets the matrix representing all changes of coordinate system since the G
rEffect was |
157 * installed in the stage. | 164 * installed in the stage. |
158 */ | 165 */ |
159 const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; } | 166 const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; } |
160 | 167 |
161 void reset() { | 168 void reset() { |
162 GrSafeSetNull(fEffectRef); | 169 GrSafeSetNull(fEffectRef); |
163 } | 170 } |
164 | 171 |
165 const GrEffectRef* setEffect(const GrEffectRef* EffectRef) { | 172 const GrEffectRef* setEffect(const GrEffectRef* EffectRef, const int* attrib
Indices = NULL) { |
166 GrAssert(0 == fSavedCoordChangeCnt); | 173 GrAssert(0 == fSavedCoordChangeCnt); |
167 GrSafeAssign(fEffectRef, EffectRef); | 174 GrSafeAssign(fEffectRef, EffectRef); |
168 fCoordChangeMatrix.reset(); | 175 fCoordChangeMatrix.reset(); |
| 176 |
| 177 fVertexAttribIndices.reset(); |
| 178 int numVertexAttribs = (EffectRef == NULL) ? 0 : EffectRef->get()->numVe
rtexAttribs(); |
| 179 GrAssert(numVertexAttribs == 0 || attribIndices != NULL); |
| 180 fVertexAttribIndices.push_back_n(numVertexAttribs, attribIndices); |
| 181 |
169 return EffectRef; | 182 return EffectRef; |
170 } | 183 } |
171 | 184 |
172 const GrEffectRef* getEffect() const { return fEffectRef; } | 185 const GrEffectRef* getEffect() const { return fEffectRef; } |
173 | 186 |
| 187 const int* getVertexAttribIndices() const { return fVertexAttribIndices.begi
n(); } |
| 188 int getVertexAttribIndexCount() const { return fVertexAttribIndices.count();
} |
| 189 |
174 private: | 190 private: |
175 SkMatrix fCoordChangeMatrix; | 191 SkMatrix fCoordChangeMatrix; |
176 const GrEffectRef* fEffectRef; | 192 const GrEffectRef* fEffectRef; |
| 193 SkSTArray<2, int, true> fVertexAttribIndices; |
177 | 194 |
178 GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;) | 195 GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;) |
179 }; | 196 }; |
180 | 197 |
181 #endif | 198 #endif |
OLD | NEW |