Index: src/gpu/GrFragmentProcessor.cpp |
diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp |
index a9d4a5e8a18bcb4ec6b976b154b732ae3d9c718a..3dfe25ea28517e4eb14ad4edcb137a90db73b71a 100644 |
--- a/src/gpu/GrFragmentProcessor.cpp |
+++ b/src/gpu/GrFragmentProcessor.cpp |
@@ -8,6 +8,7 @@ |
#include "GrFragmentProcessor.h" |
#include "GrCoordTransform.h" |
#include "GrInvariantOutput.h" |
+#include "GrPipeline.h" |
#include "GrProcOptInfo.h" |
#include "glsl/GrGLSLFragmentProcessor.h" |
#include "glsl/GrGLSLFragmentShaderBuilder.h" |
@@ -81,16 +82,10 @@ void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) { |
fCoordTransforms.push_back(transform); |
fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_GrCoordSet; |
SkDEBUGCODE(transform->setInProcessor();) |
- fNumTransformsExclChildren++; |
} |
int GrFragmentProcessor::registerChildProcessor(sk_sp<GrFragmentProcessor> child) { |
- // Append the child's transforms to our transforms array and the child's textures array to our |
- // textures array |
- if (!child->fCoordTransforms.empty()) { |
- fCoordTransforms.push_back_n(child->fCoordTransforms.count(), |
- child->fCoordTransforms.begin()); |
- } |
+ // Append the child's textures array to our textures array |
if (!child->fTextureAccesses.empty()) { |
fTextureAccesses.push_back_n(child->fTextureAccesses.count(), |
child->fTextureAccesses.begin()); |
@@ -120,10 +115,10 @@ void GrFragmentProcessor::notifyRefCntIsZero() const { |
} |
bool GrFragmentProcessor::hasSameTransforms(const GrFragmentProcessor& that) const { |
- if (this->numTransforms() != that.numTransforms()) { |
+ if (this->numCoordTransforms() != that.numCoordTransforms()) { |
return false; |
} |
- int count = this->numTransforms(); |
+ int count = this->numCoordTransforms(); |
for (int i = 0; i < count; ++i) { |
if (this->coordTransform(i) != that.coordTransform(i)) { |
return false; |
@@ -408,3 +403,39 @@ sk_sp<GrFragmentProcessor> GrFragmentProcessor::RunInSeries(sk_sp<GrFragmentProc |
} |
return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); |
} |
+ |
+////////////////////////////////////////////////////////////////////////////// |
+ |
+GrFragmentProcessor::Iter::Iter(const GrPipeline& pipeline) { |
+ for (int i = pipeline.numFragmentProcessors() - 1; i >= 0; --i) { |
+ fFPStack.push_back(&pipeline.getFragmentProcessor(i)); |
+ } |
+} |
+ |
+const GrFragmentProcessor* GrFragmentProcessor::Iter::next() { |
+ if (fFPStack.empty()) { |
+ return nullptr; |
+ } |
+ const GrFragmentProcessor* back = fFPStack.back(); |
+ fFPStack.pop_back(); |
+ for (int i = back->numChildProcessors() - 1; i >= 0; --i) { |
+ fFPStack.push_back(&back->childProcessor(i)); |
+ } |
+ return back; |
+} |
+ |
+////////////////////////////////////////////////////////////////////////////// |
+ |
+const GrCoordTransform* GrFragmentProcessor::CoordTransformIter::next() { |
+ if (!fCurrFP) { |
+ return nullptr; |
+ } |
+ while (fCTIdx == fCurrFP->numCoordTransforms()) { |
+ fCTIdx = 0; |
+ fCurrFP = fFPIter.next(); |
+ if (!fCurrFP) { |
+ return nullptr; |
+ } |
+ } |
+ return &fCurrFP->coordTransform(fCTIdx++); |
+} |