aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/glsl/GrGLSLProgramBuilder.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-06-07 14:42:52 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-07 19:42:41 +0000
commit4d3f517282b90250026ca61ed8846092b9fbf604 (patch)
tree1867b0b09a8a7064cc9b783fb651e31345c90fa7 /src/gpu/glsl/GrGLSLProgramBuilder.cpp
parentcd2c3f9055452d413d6be7ea6dc63fd1922fe994 (diff)
Remove GrGLSLFragProcs typedef. Use unique_ptr to for GrGLSLFragmentProcessor ownership.
Change-Id: Ifefbde2ec0002e7e41bed2e4bc2cd7bdd04504d0 Reviewed-on: https://skia-review.googlesource.com/132931 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src/gpu/glsl/GrGLSLProgramBuilder.cpp')
-rw-r--r--src/gpu/glsl/GrGLSLProgramBuilder.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/gpu/glsl/GrGLSLProgramBuilder.cpp b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
index 91ac5c3e71..cae1c2ad65 100644
--- a/src/gpu/glsl/GrGLSLProgramBuilder.cpp
+++ b/src/gpu/glsl/GrGLSLProgramBuilder.cpp
@@ -128,28 +128,37 @@ void GrGLSLProgramBuilder::emitAndInstallPrimProc(const GrPrimitiveProcessor& pr
void GrGLSLProgramBuilder::emitAndInstallFragProcs(SkString* color, SkString* coverage) {
int transformedCoordVarsIdx = 0;
SkString** inOut = &color;
+ SkSTArray<8, std::unique_ptr<GrGLSLFragmentProcessor>> glslFragmentProcessors;
for (int i = 0; i < this->pipeline().numFragmentProcessors(); ++i) {
if (i == this->pipeline().numColorFragmentProcessors()) {
inOut = &coverage;
}
SkString output;
const GrFragmentProcessor& fp = this->pipeline().getFragmentProcessor(i);
- output = this->emitAndInstallFragProc(fp, i, transformedCoordVarsIdx, **inOut, output);
+ output = this->emitAndInstallFragProc(fp, i, transformedCoordVarsIdx, **inOut, output,
+ &glslFragmentProcessors);
GrFragmentProcessor::Iter iter(&fp);
while (const GrFragmentProcessor* fp = iter.next()) {
transformedCoordVarsIdx += fp->numCoordTransforms();
}
**inOut = output;
}
+ fFragmentProcessorCnt = glslFragmentProcessors.count();
+ fFragmentProcessors.reset(new std::unique_ptr<GrGLSLFragmentProcessor>[fFragmentProcessorCnt]);
+ for (int i = 0; i < fFragmentProcessorCnt; ++i) {
+ fFragmentProcessors[i] = std::move(glslFragmentProcessors[i]);
+ }
}
// TODO Processors cannot output zeros because an empty string is all 1s
// the fix is to allow effects to take the SkString directly
-SkString GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor& fp,
- int index,
- int transformedCoordVarsIdx,
- const SkString& input,
- SkString output) {
+SkString GrGLSLProgramBuilder::emitAndInstallFragProc(
+ const GrFragmentProcessor& fp,
+ int index,
+ int transformedCoordVarsIdx,
+ const SkString& input,
+ SkString output,
+ SkTArray<std::unique_ptr<GrGLSLFragmentProcessor>>* glslFragmentProcessors) {
SkASSERT(input.size());
// Program builders have a bit of state we need to clear with each effect
AutoStageAdvance adv(this);
@@ -188,7 +197,7 @@ SkString GrGLSLProgramBuilder::emitAndInstallFragProc(const GrFragmentProcessor&
// We have to check that effects and the code they emit are consistent, ie if an effect
// asks for dst color, then the emit code needs to follow suit
SkDEBUGCODE(verify(fp);)
- fFragmentProcessors.push_back(fragProc);
+ glslFragmentProcessors->emplace_back(fragProc);
fFS.codeAppend("}");
return output;
@@ -403,12 +412,6 @@ void GrGLSLProgramBuilder::addRTHeightUniform(const char* name) {
name, false, 0, nullptr);
}
-void GrGLSLProgramBuilder::cleanupFragmentProcessors() {
- for (int i = 0; i < fFragmentProcessors.count(); ++i) {
- delete fFragmentProcessors[i];
- }
-}
-
void GrGLSLProgramBuilder::finalizeShaders() {
this->varyingHandler()->finalize();
fVS.finalize(kVertex_GrShaderFlag);