OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrGLFragmentShaderBuilder.h" | 8 #include "GrGLFragmentShaderBuilder.h" |
9 #include "GrGLProgramBuilder.h" | 9 #include "GrGLProgramBuilder.h" |
10 #include "gl/GrGLGpu.h" | 10 #include "gl/GrGLGpu.h" |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
305 fSubstageIndices.back()++; | 305 fSubstageIndices.back()++; |
306 fSubstageIndices.push_back(0); | 306 fSubstageIndices.push_back(0); |
307 fMangleString.append(this->getMangleStringThisLevel()); | 307 fMangleString.append(this->getMangleStringThisLevel()); |
308 } | 308 } |
309 | 309 |
310 void GrGLFragmentBuilder::onAfterChildProcEmitCode() { | 310 void GrGLFragmentBuilder::onAfterChildProcEmitCode() { |
311 fSubstageIndices.pop_back(); | 311 fSubstageIndices.pop_back(); |
312 int removeAt = fMangleString.findLastOf('_'); | 312 int removeAt = fMangleString.findLastOf('_'); |
313 fMangleString.remove(removeAt, fMangleString.size() - removeAt); | 313 fMangleString.remove(removeAt, fMangleString.size() - removeAt); |
314 } | 314 } |
315 | |
316 GrGLFragmentBuilder::AutoFragmentChildProcAdvance::AutoFragmentChildProcAdvance( | |
317 int childProcIndex, | |
318 GrGLFPBuilder* builder, | |
319 const GrFragmentProcessor& f p, | |
320 const char* outputColor, | |
321 const TransformedCoordsArray & coords, | |
322 const TextureSamplerArray& s amplers, | |
323 const GrFragmentProcessor** childFp, | |
324 SkString* childOutputColor, | |
325 TransformedCoordsArray* chil dCoords, | |
326 TextureSamplerArray* childSa mplers | |
327 ) { | |
328 fFsb = builder->getFragmentShaderBuilder(); | |
329 fFsb->onBeforeChildProcEmitCode(); // call first so mangleString is updated | |
330 | |
331 const GrFragmentProcessor& childProc = fp.childProcessor(childProcIndex); | |
332 *childFp = &childProc; | |
333 | |
334 // Mangle the name of the outputColor | |
335 childOutputColor->set(outputColor); | |
336 childOutputColor->append(fFsb->getMangleStringThisLevel()); | |
337 | |
338 // Find the subset of the transforms and textures that belongs to this child proc. | |
339 // Since we don't know how many transforms/textures at the head of the array s | |
340 // belong to this proc and not one of its children, we have to do a backward s linear search | |
341 // from the ends of the arrays. | |
342 SkASSERT(childCoords->empty()); | |
343 SkASSERT(childSamplers->empty()); | |
344 int firstCoordAt = fp.numTransforms(); | |
345 int firstSamplerAt = fp.numTextures(); | |
346 for (int i = fp.numChildProcessors() - 1; i >= childProcIndex; --i) { | |
347 firstCoordAt -= fp.childProcessor(i).numTransforms(); | |
348 firstSamplerAt -= fp.childProcessor(i).numTextures(); | |
349 } | |
350 if (!coords.empty()) | |
joshualitt
2015/08/13 18:33:53
braces
wangyix
2015/08/14 13:46:16
Done.
| |
351 childCoords->push_back_n(childProc.numTransforms(), &coords[firstCoordAt ]); | |
352 if (!samplers.empty()) | |
joshualitt
2015/08/13 18:33:53
braces
wangyix
2015/08/14 13:46:16
Done.
| |
353 childSamplers->push_back_n(childProc.numTextures(), &samplers[firstSampl erAt]); | |
354 | |
355 fFsb->codeAppendf("vec4 %s;\n", childOutputColor->c_str()); | |
356 fFsb->codeAppend("{\n"); | |
357 fFsb->codeAppendf("// Child %d: %s\n", fFsb->getChildNumberThisLevel(), chil dProc.name()); | |
358 } | |
359 | |
360 GrGLFragmentBuilder::AutoFragmentChildProcAdvance::~AutoFragmentChildProcAdvance () { | |
361 fFsb->codeAppend("}\n"); | |
362 fFsb->onAfterChildProcEmitCode(); | |
363 } | |
OLD | NEW |