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

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

Issue 12462008: Add GrEllipseEdgeEffect (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Minor fixes, added validation step 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
142 if (!(*stage.getEffect())->isEqual(*fEffect)) { 144 if (fVertexAttribIndices != stage.fVertexAttribIndices) {
143 return false; 145 return false;
144 } 146 }
145 147
146 return fCoordChangeMatrix == stage.fCoordChangeMatrix; 148 return fCoordChangeMatrix == stage.fCoordChangeMatrix;
147 } 149 }
148 150
149 private: 151 private:
150 const GrEffect* fEffect; 152 const GrEffect* fEffect;
151 SkMatrix fCoordChangeMatrix; 153 SkMatrix fCoordChangeMatrix;
154 SkSTArray<GrEffect::kMaxVertexAttribs, int, true> fVertexAttribIndices;
152 SkDEBUGCODE(bool fInitialized;) 155 SkDEBUGCODE(bool fInitialized;)
153 }; 156 };
154 157
155 /** 158 /**
156 * Gets the matrix representing all changes of coordinate system since the G rEffect was 159 * Gets the matrix representing all changes of coordinate system since the G rEffect was
157 * installed in the stage. 160 * installed in the stage.
158 */ 161 */
159 const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; } 162 const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; }
160 163
161 void reset() { 164 void reset() {
162 GrSafeSetNull(fEffectRef); 165 GrSafeSetNull(fEffectRef);
163 } 166 }
164 167
165 const GrEffectRef* setEffect(const GrEffectRef* EffectRef) { 168 const GrEffectRef* setEffect(const GrEffectRef* EffectRef, const int* attrib Indices = NULL) {
166 GrAssert(0 == fSavedCoordChangeCnt); 169 GrAssert(0 == fSavedCoordChangeCnt);
167 GrSafeAssign(fEffectRef, EffectRef); 170 GrSafeAssign(fEffectRef, EffectRef);
168 fCoordChangeMatrix.reset(); 171 fCoordChangeMatrix.reset();
172
173 fVertexAttribIndices.reset();
174 int numVertexAttribs = (EffectRef == NULL) ? 0 : EffectRef->get()->numVe rtexAttribs();
175 GrAssert(numVertexAttribs == 0 || attribIndices != NULL);
176 fVertexAttribIndices.push_back_n(numVertexAttribs, attribIndices);
177
169 return EffectRef; 178 return EffectRef;
170 } 179 }
171 180
172 const GrEffectRef* getEffect() const { return fEffectRef; } 181 const GrEffectRef* getEffect() const { return fEffectRef; }
173 182
183 const int* getVertexAttribIndices() const { return fVertexAttribIndices.begi n(); }
184 int getVertexAttribIndexCount() const { return fVertexAttribIndices.count(); }
185
174 private: 186 private:
175 SkMatrix fCoordChangeMatrix; 187 SkMatrix fCoordChangeMatrix;
176 const GrEffectRef* fEffectRef; 188 const GrEffectRef* fEffectRef;
189 SkSTArray<2, int, true> fVertexAttribIndices;
177 190
178 GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;) 191 GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
179 }; 192 };
180 193
181 #endif 194 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698