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

Unified Diff: src/gpu/glsl/GrGLSLProgramBuilder.cpp

Issue 2339203002: Stop flattening GrCoordTransforms in parent GrFragmentProcessors. (Closed)
Patch Set: Fix issue of taking ref to a temporary Created 4 years, 3 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/glsl/GrGLSLProgramBuilder.h ('k') | src/gpu/instanced/InstanceProcessor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/glsl/GrGLSLProgramBuilder.cpp
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 4d442f9752a90e5d4c18ab600e4c4a00d80f10cd..29470c4e2b9dc116a9e2412a53e1874fa9fce160 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -53,19 +53,9 @@ bool GrGLSLProgramBuilder::emitAndInstallProcs(GrGLSLExpr4* inputColor,
// be sent to the GrGLSLPrimitiveProcessor in its emitCode function
const GrPrimitiveProcessor& primProc = this->primitiveProcessor();
- for (int i = 0; i < this->pipeline().numFragmentProcessors(); i++) {
- const GrFragmentProcessor& processor = this->pipeline().getFragmentProcessor(i);
-
- SkTArray<const GrCoordTransform*, true>& procCoords = fCoordTransforms.push_back();
- processor.gatherCoordTransforms(&procCoords);
- }
-
this->emitAndInstallPrimProc(primProc, inputColor, inputCoverage);
- int numProcs = this->pipeline().numFragmentProcessors();
- this->emitAndInstallFragProcs(0, this->pipeline().numColorFragmentProcessors(), inputColor);
- this->emitAndInstallFragProcs(this->pipeline().numColorFragmentProcessors(), numProcs,
- inputCoverage);
+ this->emitAndInstallFragProcs(inputColor, inputCoverage);
if (primProc.getPixelLocalStorageState() !=
GrPixelLocalStorageState::kDraw_GrPixelLocalStorageState) {
this->emitAndInstallXferProc(this->pipeline().getXferProcessor(), *inputColor,
@@ -109,6 +99,8 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
SkSTArray<2, SamplerHandle> bufferSamplers(proc.numBuffers());
this->emitSamplers(proc, &texSamplers, &bufferSamplers);
+ GrGLSLPrimitiveProcessor::FPCoordTransformHandler transformHandler(fPipeline,
+ &fTransformedCoordVars);
GrGLSLGeometryProcessor::EmitArgs args(&fVS,
&fFS,
this->varyingHandler(),
@@ -120,8 +112,7 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
distanceVectorName,
texSamplers.begin(),
bufferSamplers.begin(),
- fCoordTransforms,
- &fOutCoords);
+ &transformHandler);
fGeometryProcessor->emitCode(args);
// We have to check that effects and the code they emit are consistent, ie if an effect
@@ -131,14 +122,21 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
fFS.codeAppend("}");
}
-void GrGLSLProgramBuilder::emitAndInstallFragProcs(int procOffset,
- int numProcs,
- GrGLSLExpr4* inOut) {
- for (int i = procOffset; i < numProcs; ++i) {
+void GrGLSLProgramBuilder::emitAndInstallFragProcs(GrGLSLExpr4* color, GrGLSLExpr4* coverage) {
+ int transformedCoordVarsIdx = 0;
+ GrGLSLExpr4** inOut = &color;
+ for (int i = 0; i < this->pipeline().numFragmentProcessors(); ++i) {
+ if (i == this->pipeline().numColorFragmentProcessors()) {
+ inOut = &coverage;
+ }
GrGLSLExpr4 output;
const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i);
- this->emitAndInstallFragProc(fp, i, *inOut, &output);
- *inOut = output;
+ this->emitAndInstallFragProc(fp, i, transformedCoordVarsIdx, **inOut, &output);
+ GrFragmentProcessor::Iter iter(&fp);
+ while (const GrFragmentProcessor* fp = iter.next()) {
+ transformedCoordVarsIdx += fp->numCoordTransforms();
+ }
+ **inOut = output;
}
}
@@ -146,6 +144,7 @@ void GrGLSLProgramBuilder::emitAndInstallFragProcs(int procOffset,
// the fix is to allow effects to take the GrGLSLExpr4 directly
void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
int index,
+ int transformedCoordVarsIdx,
const GrGLSLExpr4& input,
GrGLSLExpr4* output) {
// Program builders have a bit of state we need to clear with each effect
@@ -163,13 +162,15 @@ void GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
SkSTArray<2, SamplerHandle> bufferSamplers(fp.numBuffers());
this->emitSamplers(fp, &texSamplers, &bufferSamplers);
+ const GrShaderVar* coordVars = fTransformedCoordVars.begin() + transformedCoordVarsIdx;
+ GrGLSLFragmentProcessor::TransformedCoordVars coords(&fp, coordVars);
GrGLSLFragmentProcessor::EmitArgs args(&fFS,
this->uniformHandler(),
this->glslCaps(),
fp,
output->c_str(),
input.isOnes() ? nullptr : input.c_str(),
- fOutCoords[index],
+ coords,
texSamplers.begin(),
bufferSamplers.begin(),
this->primitiveProcessor().implementsDistanceVector());
@@ -418,5 +419,4 @@ void GrGLSLProgramBuilder::finalizeShaders() {
this->varyingHandler()->finalize();
fVS.finalize(kVertex_GrShaderFlag);
fFS.finalize(kFragment_GrShaderFlag);
-
}
« no previous file with comments | « src/gpu/glsl/GrGLSLProgramBuilder.h ('k') | src/gpu/instanced/InstanceProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698