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

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

Issue 12462008: Add GrEllipseEdgeEffect (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: 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();
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) {
166 GrAssert(0 == fSavedCoordChangeCnt); 179 GrAssert(0 == fSavedCoordChangeCnt);
167 GrSafeAssign(fEffectRef, EffectRef); 180 GrSafeAssign(fEffectRef, EffectRef);
168 fCoordChangeMatrix.reset(); 181 fCoordChangeMatrix.reset();
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 void setVertexAttribIndices(const int indices[], int count) {
robertphillips 2013/03/05 20:30:13 Is there a reserve we can use here?
jvanverth1 2013/03/07 15:21:54 Done.
188 fVertexAttribIndices.reset();
189 for (int index = 0; index < count; ++index) {
190 fVertexAttribIndices.push_back(indices[index]);
191 }
192 }
193
194 const int* getVertexAttribIndices() const { return fVertexAttribIndices.begi n(); }
195 int getVertexAttribIndexCount() const { return fVertexAttribIndices.count(); }
196
174 private: 197 private:
175 SkMatrix fCoordChangeMatrix; 198 SkMatrix fCoordChangeMatrix;
176 const GrEffectRef* fEffectRef; 199 const GrEffectRef* fEffectRef;
200 SkSTArray<2, int, true> fVertexAttribIndices;
177 201
178 GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;) 202 GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
179 }; 203 };
180 204
181 #endif 205 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698