Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: include/gpu/GrEffectStage.h

Issue 12462008: Add GrEllipseEdgeEffect (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Add dynamic vertex attributes for Effects Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
144 int vertexAttribCount = fVertexAttribIndices.count();
bsalomon 2013/03/08 14:31:58 maybe we should add op== to SkTArray?
jvanverth1 2013/03/08 17:39:55 Done.
145 if (vertexAttribCount != stage.fVertexAttribIndices.count()) {
146 return false;
147 }
148 for (int i = 0; i < vertexAttribCount; ++i) {
149 if (fVertexAttribIndices[i] != stage.fVertexAttribIndices[i]) {
150 return false;
151 }
152 }
153
142 if (!(*stage.getEffect())->isEqual(*fEffect)) { 154 if (!(*stage.getEffect())->isEqual(*fEffect)) {
143 return false; 155 return false;
144 } 156 }
145 157
146 return fCoordChangeMatrix == stage.fCoordChangeMatrix; 158 return fCoordChangeMatrix == stage.fCoordChangeMatrix;
147 } 159 }
148 160
149 private: 161 private:
150 const GrEffect* fEffect; 162 const GrEffect* fEffect;
151 SkMatrix fCoordChangeMatrix; 163 SkMatrix fCoordChangeMatrix;
164 SkSTArray<2, int, true> fVertexAttribIndices;
152 SkDEBUGCODE(bool fInitialized;) 165 SkDEBUGCODE(bool fInitialized;)
153 }; 166 };
154 167
155 /** 168 /**
156 * Gets the matrix representing all changes of coordinate system since the G rEffect was 169 * Gets the matrix representing all changes of coordinate system since the G rEffect was
157 * installed in the stage. 170 * installed in the stage.
158 */ 171 */
159 const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; } 172 const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; }
160 173
161 void reset() { 174 void reset() {
162 GrSafeSetNull(fEffectRef); 175 GrSafeSetNull(fEffectRef);
163 } 176 }
164 177
165 const GrEffectRef* setEffect(const GrEffectRef* EffectRef) { 178 const GrEffectRef* setEffect(const GrEffectRef* EffectRef, const int* indice s = NULL) {
bsalomon 2013/03/08 14:31:58 attributeIndices or attrIndices?
jvanverth1 2013/03/08 17:39:55 Done.
166 GrAssert(0 == fSavedCoordChangeCnt); 179 GrAssert(0 == fSavedCoordChangeCnt);
167 GrSafeAssign(fEffectRef, EffectRef); 180 GrSafeAssign(fEffectRef, EffectRef);
168 fCoordChangeMatrix.reset(); 181 fCoordChangeMatrix.reset();
182
183 fVertexAttribIndices.reset();
184 int numVertexAttribs = (EffectRef == NULL) ? 0 : EffectRef->get()->numVe rtexAttribs();
185 GrAssert(numVertexAttribs == 0 || indices != NULL);
186 fVertexAttribIndices.push_back_n(numVertexAttribs, indices);
187
169 return EffectRef; 188 return EffectRef;
170 } 189 }
171 190
172 const GrEffectRef* getEffect() const { return fEffectRef; } 191 const GrEffectRef* getEffect() const { return fEffectRef; }
173 192
193 const int* getVertexAttribIndices() const { return fVertexAttribIndices.begi n(); }
194 int getVertexAttribIndexCount() const { return fVertexAttribIndices.count(); }
195
174 private: 196 private:
175 SkMatrix fCoordChangeMatrix; 197 SkMatrix fCoordChangeMatrix;
176 const GrEffectRef* fEffectRef; 198 const GrEffectRef* fEffectRef;
199 SkSTArray<2, int, true> fVertexAttribIndices;
177 200
178 GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;) 201 GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
179 }; 202 };
180 203
181 #endif 204 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698