Chromium Code Reviews| Index: src/gpu/GrGeometryProcessor.cpp |
| diff --git a/src/gpu/GrGeometryProcessor.cpp b/src/gpu/GrGeometryProcessor.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a5cd602aea552eccaf1c8f17d576e6bb9af8d195 |
| --- /dev/null |
| +++ b/src/gpu/GrGeometryProcessor.cpp |
| @@ -0,0 +1,65 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#include "GrGeometryProcessor.h" |
| + |
| +#include "gl/GrGLGeometryProcessor.h" |
| +#include "GrInvariantOutput.h" |
| + |
| +/////////////////////////////////////////////////////////////////////////////////////////////////// |
| + |
| +void GrGeometryProcessor::getInvariantOutputColor(GrInitInvariantOutput* out) const { |
| + if (fHasVertexColor) { |
| + if (fOpaqueVertexColors) { |
| + out->setUnknownOpaqueFourComponents(); |
| + } else { |
| + out->setUnknownFourComponents(); |
| + } |
| + } else { |
| + out->setKnownFourComponents(fColor); |
| + } |
| + this->onGetInvariantOutputColor(out); |
|
bsalomon
2014/12/12 14:29:35
this flow seems odd to me... should we always be g
|
| +} |
| + |
| +void GrGeometryProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) const { |
| + this->onGetInvariantOutputCoverage(out); |
| +} |
| + |
| +/////////////////////////////////////////////////////////////////////////////////////////////////// |
| + |
| +void GrPathProcessor::getInvariantOutputColor(GrInitInvariantOutput* out) const { |
| + out->setKnownFourComponents(fColor); |
| +} |
| + |
| +void GrPathProcessor::getInvariantOutputCoverage(GrInitInvariantOutput* out) const { |
| + out->setKnownSingleComponent(0xff); |
| +} |
| +/////////////////////////////////////////////////////////////////////////////////////////////////// |
| + |
| +#include "gl/builders/GrGLProgramBuilder.h" |
| + |
| +void GrGLGeometryProcessor::setupColor(GrGLGPBuilder* pb, |
| + GPInput outputType, |
| + const char* outputName, |
| + const GrGeometryProcessor::GrAttribute* colorAttr, |
| + UniformHandle* colorUniform) { |
| + GrGLGPFragmentBuilder* fs = pb->getFragmentShaderBuilder(); |
| + if (kUniform_GPInput == outputType) { |
| + const char* fragColor; |
| + *colorUniform = pb->addUniform(GrGLProgramBuilder::kFragment_Visibility, |
| + kVec4f_GrSLType, |
| + kDefault_GrSLPrecision, |
| + "Color", |
| + &fragColor); |
| + fs->codeAppendf("%s = %s;", outputName, fragColor); |
| + } else if (kAttribute_GPInput == outputType) { |
| + SkASSERT(colorAttr); |
| + pb->addPassThroughAttribute(colorAttr, outputName); |
| + } else { |
| + fs->codeAppendf("%s = vec4(1);", outputName); |
| + } |
| +} |