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

Side by Side Diff: src/gpu/GrProcessor.cpp

Issue 1350523004: Move GrFragmentProcessor implementation to its own cpp file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: whitespace Created 5 years, 2 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
« no previous file with comments | « src/gpu/GrFragmentProcessor.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrProcessor.h" 8 #include "GrProcessor.h"
9 #include "GrContext.h" 9 #include "GrContext.h"
10 #include "GrCoordTransform.h"
11 #include "GrGeometryProcessor.h" 10 #include "GrGeometryProcessor.h"
12 #include "GrInvariantOutput.h" 11 #include "GrInvariantOutput.h"
13 #include "GrMemoryPool.h" 12 #include "GrMemoryPool.h"
14 #include "GrXferProcessor.h" 13 #include "GrXferProcessor.h"
15 #include "SkSpinlock.h" 14 #include "SkSpinlock.h"
16 #include "gl/GrGLFragmentProcessor.h"
17 15
18 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 16 #if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
19 17
20 class GrFragmentProcessor; 18 class GrFragmentProcessor;
21 class GrGeometryProcessor; 19 class GrGeometryProcessor;
22 20
23 /* 21 /*
24 * Originally these were both in the processor unit test header, but then it see med to cause linker 22 * Originally these were both in the processor unit test header, but then it see med to cause linker
25 * problems on android. 23 * problems on android.
26 */ 24 */
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 for (int i = 0; i < this->numTextures(); ++i) { 121 for (int i = 0; i < this->numTextures(); ++i) {
124 if (this->textureAccess(i) != that.textureAccess(i)) { 122 if (this->textureAccess(i) != that.textureAccess(i)) {
125 return false; 123 return false;
126 } 124 }
127 } 125 }
128 return true; 126 return true;
129 } 127 }
130 128
131 //////////////////////////////////////////////////////////////////////////////// /////////////////// 129 //////////////////////////////////////////////////////////////////////////////// ///////////////////
132 130
133 GrFragmentProcessor::~GrFragmentProcessor() {
134 // If we got here then our ref count must have reached zero, so we will have converted refs
135 // to pending executions for all children.
136 for (int i = 0; i < fChildProcessors.count(); ++i) {
137 fChildProcessors[i]->completedExecution();
138 }
139 }
140
141 bool GrFragmentProcessor::isEqual(const GrFragmentProcessor& that,
142 bool ignoreCoordTransforms) const {
143 if (this->classID() != that.classID() ||
144 !this->hasSameTextureAccesses(that)) {
145 return false;
146 }
147 if (ignoreCoordTransforms) {
148 if (this->numTransforms() != that.numTransforms()) {
149 return false;
150 }
151 } else if (!this->hasSameTransforms(that)) {
152 return false;
153 }
154 if (!this->onIsEqual(that)) {
155 return false;
156 }
157 if (this->numChildProcessors() != that.numChildProcessors()) {
158 return false;
159 }
160 for (int i = 0; i < this->numChildProcessors(); ++i) {
161 if (!this->childProcessor(i).isEqual(that.childProcessor(i), ignoreCoord Transforms)) {
162 return false;
163 }
164 }
165 return true;
166 }
167
168 GrGLFragmentProcessor* GrFragmentProcessor::createGLInstance() const {
169 GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance();
170 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count());
171 for (int i = 0; i < fChildProcessors.count(); ++i) {
172 glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLInstance( );
173 }
174 return glFragProc;
175 }
176
177 void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess) {
178 // Can't add texture accesses after registering any children since their tex ture accesses have
179 // already been bubbled up into our fTextureAccesses array
180 SkASSERT(fChildProcessors.empty());
181
182 INHERITED::addTextureAccess(textureAccess);
183 fNumTexturesExclChildren++;
184 }
185
186 void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) {
187 // Can't add transforms after registering any children since their transform s have already been
188 // bubbled up into our fCoordTransforms array
189 SkASSERT(fChildProcessors.empty());
190
191 fCoordTransforms.push_back(transform);
192 fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_G rCoordSet;
193 SkDEBUGCODE(transform->setInProcessor();)
194 fNumTransformsExclChildren++;
195 }
196
197 int GrFragmentProcessor::registerChildProcessor(const GrFragmentProcessor* child ) {
198 // Append the child's transforms to our transforms array and the child's tex tures array to our
199 // textures array
200 if (!child->fCoordTransforms.empty()) {
201 fCoordTransforms.push_back_n(child->fCoordTransforms.count(),
202 child->fCoordTransforms.begin());
203 }
204 if (!child->fTextureAccesses.empty()) {
205 fTextureAccesses.push_back_n(child->fTextureAccesses.count(),
206 child->fTextureAccesses.begin());
207 }
208
209 int index = fChildProcessors.count();
210 fChildProcessors.push_back(SkRef(child));
211
212 if (child->willReadFragmentPosition()) {
213 this->setWillReadFragmentPosition();
214 }
215
216 if (child->usesLocalCoords()) {
217 fUsesLocalCoords = true;
218 }
219
220 return index;
221 }
222
223 void GrFragmentProcessor::notifyRefCntIsZero() const {
224 // See comment above GrProgramElement for a detailed explanation of why we d o this.
225 for (int i = 0; i < fChildProcessors.count(); ++i) {
226 fChildProcessors[i]->addPendingExecution();
227 fChildProcessors[i]->unref();
228 }
229 }
230
231 bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) con st {
232 if (this->numTransforms() != that.numTransforms()) {
233 return false;
234 }
235 int count = this->numTransforms();
236 for (int i = 0; i < count; ++i) {
237 if (this->coordTransform(i) != that.coordTransform(i)) {
238 return false;
239 }
240 }
241 return true;
242 }
243
244 #include "effects/GrXfermodeFragmentProcessor.h"
245
246 const GrFragmentProcessor* GrFragmentProcessor::MulOuputByInputAlpha(
247 const GrFragmentProcessor* fp) {
248 return GrXfermodeFragmentProcessor::CreateFromDstProcessor(fp, SkXfermode::k DstIn_Mode);
249 }
250
251 //////////////////////////////////////////////////////////////////////////////// ///////////////////
252
253 // Initial static variable from GrXPFactory 131 // Initial static variable from GrXPFactory
254 int32_t GrXPFactory::gCurrXPFClassID = 132 int32_t GrXPFactory::gCurrXPFClassID =
255 GrXPFactory::kIllegalXPFClassID; 133 GrXPFactory::kIllegalXPFClassID;
OLDNEW
« no previous file with comments | « src/gpu/GrFragmentProcessor.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698