| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrFragmentProcessor.h" | 8 #include "GrFragmentProcessor.h" |
| 9 #include "GrCoordTransform.h" | 9 #include "GrCoordTransform.h" |
| 10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 GrGLSLFragmentProcessor* GrFragmentProcessor::createGLSLInstance() const { | 50 GrGLSLFragmentProcessor* GrFragmentProcessor::createGLSLInstance() const { |
| 51 GrGLSLFragmentProcessor* glFragProc = this->onCreateGLSLInstance(); | 51 GrGLSLFragmentProcessor* glFragProc = this->onCreateGLSLInstance(); |
| 52 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); | 52 glFragProc->fChildProcessors.push_back_n(fChildProcessors.count()); |
| 53 for (int i = 0; i < fChildProcessors.count(); ++i) { | 53 for (int i = 0; i < fChildProcessors.count(); ++i) { |
| 54 glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLSLInstanc
e(); | 54 glFragProc->fChildProcessors[i] = fChildProcessors[i]->createGLSLInstanc
e(); |
| 55 } | 55 } |
| 56 return glFragProc; | 56 return glFragProc; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess)
{ | 59 void GrFragmentProcessor::addTextureAccess(const GrTextureAccess* textureAccess)
{ |
| 60 // Can't add texture accesses after registering any children since their tex
ture accesses have | |
| 61 // already been bubbled up into our fTextureAccesses array | |
| 62 SkASSERT(fChildProcessors.empty()); | |
| 63 | |
| 64 INHERITED::addTextureAccess(textureAccess); | 60 INHERITED::addTextureAccess(textureAccess); |
| 65 fNumTexturesExclChildren++; | |
| 66 } | 61 } |
| 67 | 62 |
| 68 void GrFragmentProcessor::addBufferAccess(const GrBufferAccess* bufferAccess) { | 63 void GrFragmentProcessor::addBufferAccess(const GrBufferAccess* bufferAccess) { |
| 69 // Can't add buffer accesses after registering any children since their buff
er accesses have | |
| 70 // already been bubbled up into our fBufferAccesses array | |
| 71 SkASSERT(fChildProcessors.empty()); | |
| 72 | |
| 73 INHERITED::addBufferAccess(bufferAccess); | 64 INHERITED::addBufferAccess(bufferAccess); |
| 74 fNumBuffersExclChildren++; | |
| 75 } | 65 } |
| 76 | 66 |
| 77 void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { | 67 void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { |
| 78 // Can't add transforms after registering any children since their transform
s have already been | |
| 79 // bubbled up into our fCoordTransforms array | |
| 80 SkASSERT(fChildProcessors.empty()); | |
| 81 | |
| 82 fCoordTransforms.push_back(transform); | 68 fCoordTransforms.push_back(transform); |
| 83 fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_G
rCoordSet; | 69 fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_G
rCoordSet; |
| 84 SkDEBUGCODE(transform->setInProcessor();) | 70 SkDEBUGCODE(transform->setInProcessor();) |
| 85 } | 71 } |
| 86 | 72 |
| 87 int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child
) { | 73 int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child
) { |
| 88 // Append the child's textures array to our textures array | |
| 89 if (!child->fTextureAccesses.empty()) { | |
| 90 fTextureAccesses.push_back_n(child->fTextureAccesses.count(), | |
| 91 child->fTextureAccesses.begin()); | |
| 92 } | |
| 93 | |
| 94 this->combineRequiredFeatures(*child); | 74 this->combineRequiredFeatures(*child); |
| 95 | 75 |
| 96 if (child->usesLocalCoords()) { | 76 if (child->usesLocalCoords()) { |
| 97 fUsesLocalCoords = true; | 77 fUsesLocalCoords = true; |
| 98 } | 78 } |
| 99 if (child->usesDistanceVectorField()) { | 79 if (child->usesDistanceVectorField()) { |
| 100 fUsesDistanceVectorField = true; | 80 fUsesDistanceVectorField = true; |
| 101 } | 81 } |
| 102 | 82 |
| 103 int index = fChildProcessors.count(); | 83 int index = fChildProcessors.count(); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 return nullptr; | 397 return nullptr; |
| 418 } | 398 } |
| 419 const GrFragmentProcessor* back = fFPStack.back(); | 399 const GrFragmentProcessor* back = fFPStack.back(); |
| 420 fFPStack.pop_back(); | 400 fFPStack.pop_back(); |
| 421 for (int i = back->numChildProcessors() - 1; i >= 0; --i) { | 401 for (int i = back->numChildProcessors() - 1; i >= 0; --i) { |
| 422 fFPStack.push_back(&back->childProcessor(i)); | 402 fFPStack.push_back(&back->childProcessor(i)); |
| 423 } | 403 } |
| 424 return back; | 404 return back; |
| 425 } | 405 } |
| 426 | 406 |
| 427 ////////////////////////////////////////////////////////////////////////////// | |
| 428 | |
| 429 const GrCoordTransform* GrFragmentProcessor::CoordTransformIter::next() { | |
| 430 if (!fCurrFP) { | |
| 431 return nullptr; | |
| 432 } | |
| 433 while (fCTIdx == fCurrFP->numCoordTransforms()) { | |
| 434 fCTIdx = 0; | |
| 435 fCurrFP = fFPIter.next(); | |
| 436 if (!fCurrFP) { | |
| 437 return nullptr; | |
| 438 } | |
| 439 } | |
| 440 return &fCurrFP->coordTransform(fCTIdx++); | |
| 441 } | |
| OLD | NEW |