Chromium Code Reviews| Index: src/gpu/effects/GrPorterDuffXferProcessor.cpp |
| diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..de19745b337274afdf4afe3817c37fade90c59ed |
| --- /dev/null |
| +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp |
| @@ -0,0 +1,76 @@ |
| +/* |
| + * 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 "GrPorterDuffXferProcessor.h" |
| + |
| +#include "GrBackendProcessorFactory.h" |
| +#include "GrDrawState.h" |
| +#include "GrInvariantOutput.h" |
| +#include "GrProcessor.h" |
| +#include "GrTBackendProcessorFactory.h" |
| +#include "GrTypes.h" |
| +#include "GrXferProcessor.h" |
| +#include "gl/GrGLProcessor.h" |
| +#include "gl/builders/GrGLFragmentShaderBuilder.h" |
| +#include "gl/builders/GrGLProgramBuilder.h" |
| + |
| +class GrGLPorterDuffXferProcessor : public GrGLXferProcessor { |
| +public: |
| + GrGLPorterDuffXferProcessor(const GrBackendProcessorFactory& factory, const GrProcessor&) |
| + : INHERITED(factory) {} |
| + |
| + virtual ~GrGLPorterDuffXferProcessor() {} |
| + |
| + virtual void emitCode(GrGLFPBuilder* builder, |
| + const GrFragmentProcessor& fp, |
| + const GrProcessorKey& key, |
| + const char* outputColor, |
| + const char* inputColor, |
| + const TransformedCoordsArray& coords, |
|
bsalomon
2014/11/26 21:02:45
Do these need coords? I don't think XPs should be
egdaniel
2014/12/01 18:18:25
Yeah for now that it comes from fp it needs it. Fi
|
| + const TextureSamplerArray& samplers) SK_OVERRIDE { |
| + GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| + fsBuilder->codeAppendf("\t\t%s = %s;\n", outputColor, inputColor); |
|
joshualitt
2014/11/26 20:10:34
no need for \t or \n
egdaniel
2014/12/01 18:18:24
fine
|
| + } |
| + |
| + virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_OVERRIDE {}; |
| + |
| + static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyBuilder* b) {}; |
| + |
| +private: |
| + typedef GrGLXferProcessor INHERITED; |
| +}; |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend) |
| + : INHERITED(srcBlend, dstBlend) {} |
| + |
| +GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() { |
| +} |
| + |
| +const GrBackendFragmentProcessorFactory& GrPorterDuffXferProcessor::getFactory() const { |
| + return GrTBackendFragmentProcessorFactory<GrPorterDuffXferProcessor>::getInstance(); |
| +} |
| + |
| +void GrPorterDuffXferProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const { |
| + inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); |
| +} |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +const GrXferProcessor* GrPorterDuffXPFactory::createXferProcessor() const { |
| + return GrPorterDuffXferProcessor::Create(fSrc, fDst); |
| +} |
| + |
| +bool GrPorterDuffXPFactory::supportsLCDText(const GrDrawState& drawState) const { |
| + if (kOne_GrBlendCoeff == fSrc && kISA_GrBlendCoeff == fDst && |
| + 0 == drawState.numColorStages() && !drawState.coverageWillBeSingleComponent()) { |
| + return true; |
| + } |
| + return false; |
| +} |
| + |