When getGLInstance is called on a frag proc, the resulting GrGLFragmentProcessor will be the root of a tree of GrGLFragmentProcessors that mirrors the GrFragmentProcessor's tree. This allows setData() to be called recursively (removing the responsibility from compose shader) and allows gl instances direct access to their children gl instances so they can emit their code.
BUG=skia:4182
Review URL: https://codereview.chromium.org/1287023009
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp
index 3090d0f..0eaab75 100644
--- a/src/gpu/GrProcessor.cpp
+++ b/src/gpu/GrProcessor.cpp
@@ -13,6 +13,7 @@
#include "GrMemoryPool.h"
#include "GrXferProcessor.h"
#include "SkSpinlock.h"
+#include "gl/GrGLFragmentProcessor.h"
#if SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
@@ -156,6 +157,15 @@
return true;
}
+GrGLFragmentProcessor* GrFragmentProcessor::createGLInstance() const {
+ GrGLFragmentProcessor* glFragProc = this->onCreateGLInstance();
+ glFragProc->fChildProcessors.push_back_n(fChildProcessors.count());
+ for (int i = 0; i < fChildProcessors.count(); ++i) {
+ glFragProc->fChildProcessors[i] = fChildProcessors[i].processor()->createGLInstance();
+ }
+ return glFragProc;
+}
+
void GrFragmentProcessor::addCoordTransform(const GrCoordTransform* transform) {
fCoordTransforms.push_back(transform);
fUsesLocalCoords = fUsesLocalCoords || transform->sourceCoords() == kLocal_GrCoordSet;