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..b304f6c18876fdff80daa14b05d6ca99cd71c86e |
| --- /dev/null |
| +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp |
| @@ -0,0 +1,75 @@ |
| +/* |
| + * 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 char* outputColor, |
| + const char* inputColor, |
| + const TransformedCoordsArray& coords, |
| + const TextureSamplerArray& samplers) SK_OVERRIDE { |
| + GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| + fsBuilder->codeAppendf("%s = %s;", outputColor, inputColor); |
| + } |
| + |
| + 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) |
| + : fSrcBlend(srcBlend), fDstBlend(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::supportsRGBCoverage(const GrDrawState& drawState) const { |
| + if (kOne_GrBlendCoeff == fSrc && kISA_GrBlendCoeff == fDst && |
| + 0 == drawState.numColorStages() && !drawState.coverageWillBeSingleComponent()) { |
|
bsalomon
2014/12/01 19:24:40
so what if this took something like
class GrXPFac
egdaniel
2014/12/02 15:07:09
Done partially. The change to actually check befor
|
| + return true; |
| + } |
| + return false; |
| +} |
| + |