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

Unified Diff: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp

Issue 1283223003: Changed auto child advance back to backwards linear search for getting subset of coords and sampler… Base URL: https://skia.googlesource.com/skia@cs3_onBeforeAfter
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
diff --git a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
index 20bb3a389341a5bf1f614587d042a8ca3e0d91cf..a82b6b7f44dd2dfb734c8db78e6bcca0798a8be6 100644
--- a/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLFragmentShaderBuilder.cpp
@@ -312,3 +312,52 @@ void GrGLFragmentBuilder::onAfterChildProcEmitCode() {
int removeAt = fMangleString.findLastOf('_');
fMangleString.remove(removeAt, fMangleString.size() - removeAt);
}
+
+GrGLFragmentBuilder::AutoFragmentChildProcAdvance::AutoFragmentChildProcAdvance(
+ int childProcIndex,
+ GrGLFPBuilder* builder,
+ const GrFragmentProcessor& fp,
+ const char* outputColor,
+ const TransformedCoordsArray& coords,
+ const TextureSamplerArray& samplers,
+ const GrFragmentProcessor** childFp,
+ SkString* childOutputColor,
+ TransformedCoordsArray* childCoords,
+ TextureSamplerArray* childSamplers
+ ) {
+ fFsb = builder->getFragmentShaderBuilder();
+ fFsb->onBeforeChildProcEmitCode(); // call first so mangleString is updated
+
+ const GrFragmentProcessor& childProc = fp.childProcessor(childProcIndex);
+ *childFp = &childProc;
+
+ // Mangle the name of the outputColor
+ childOutputColor->set(outputColor);
+ childOutputColor->append(fFsb->getMangleStringThisLevel());
+
+ // Find the subset of the transforms and textures that belongs to this child proc.
+ // Since we don't know how many transforms/textures at the head of the arrays
+ // belong to this proc and not one of its children, we have to do a backwards linear search
+ // from the ends of the arrays.
+ SkASSERT(childCoords->empty());
+ SkASSERT(childSamplers->empty());
+ int firstCoordAt = fp.numTransforms();
+ int firstSamplerAt = fp.numTextures();
+ for (int i = fp.numChildProcessors() - 1; i >= childProcIndex; --i) {
+ firstCoordAt -= fp.childProcessor(i).numTransforms();
+ firstSamplerAt -= fp.childProcessor(i).numTextures();
+ }
+ if (!coords.empty())
+ childCoords->push_back_n(childProc.numTransforms(), &coords[firstCoordAt]);
+ if (!samplers.empty())
+ childSamplers->push_back_n(childProc.numTextures(), &samplers[firstSamplerAt]);
+
+ fFsb->codeAppendf("vec4 %s;\n", childOutputColor->c_str());
+ fFsb->codeAppend("{\n");
+ fFsb->codeAppendf("// Child %d: %s\n", fFsb->getChildNumberThisLevel(), childProc.name());
+}
+
+GrGLFragmentBuilder::AutoFragmentChildProcAdvance::~AutoFragmentChildProcAdvance() {
+ fFsb->codeAppend("}\n");
+ fFsb->onAfterChildProcEmitCode();
+}
« no previous file with comments | « src/gpu/gl/builders/GrGLFragmentShaderBuilder.h ('k') | src/gpu/gl/builders/GrGLProgramBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698