OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #include "GrPorterDuffXferProcessor.h" |
| 9 |
| 10 #include "GrBackendProcessorFactory.h" |
| 11 #include "GrDrawState.h" |
| 12 #include "GrInvariantOutput.h" |
| 13 #include "GrProcessor.h" |
| 14 #include "GrTBackendProcessorFactory.h" |
| 15 #include "GrTypes.h" |
| 16 #include "GrXferProcessor.h" |
| 17 #include "gl/GrGLProcessor.h" |
| 18 #include "gl/builders/GrGLFragmentShaderBuilder.h" |
| 19 #include "gl/builders/GrGLProgramBuilder.h" |
| 20 |
| 21 class GrGLPorterDuffXferProcessor : public GrGLXferProcessor { |
| 22 public: |
| 23 GrGLPorterDuffXferProcessor(const GrBackendProcessorFactory& factory, const
GrProcessor&) |
| 24 : INHERITED(factory) {} |
| 25 |
| 26 virtual ~GrGLPorterDuffXferProcessor() {} |
| 27 |
| 28 virtual void emitCode(GrGLFPBuilder* builder, |
| 29 const GrFragmentProcessor& fp, |
| 30 const char* outputColor, |
| 31 const char* inputColor, |
| 32 const TransformedCoordsArray& coords, |
| 33 const TextureSamplerArray& samplers) SK_OVERRIDE { |
| 34 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| 35 fsBuilder->codeAppendf("%s = %s;", outputColor, inputColor); |
| 36 } |
| 37 |
| 38 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE {}; |
| 39 |
| 40 static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyB
uilder* b) {}; |
| 41 |
| 42 private: |
| 43 typedef GrGLXferProcessor INHERITED; |
| 44 }; |
| 45 |
| 46 /////////////////////////////////////////////////////////////////////////////// |
| 47 |
| 48 GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBl
endCoeff dstBlend) |
| 49 : fSrcBlend(srcBlend), fDstBlend(dstBlend) {} |
| 50 |
| 51 GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() { |
| 52 } |
| 53 |
| 54 const GrBackendFragmentProcessorFactory& GrPorterDuffXferProcessor::getFactory()
const { |
| 55 return GrTBackendFragmentProcessorFactory<GrPorterDuffXferProcessor>::getIns
tance(); |
| 56 } |
| 57 |
| 58 void GrPorterDuffXferProcessor::onComputeInvariantOutput(GrInvariantOutput* inou
t) const { |
| 59 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); |
| 60 } |
| 61 |
| 62 /////////////////////////////////////////////////////////////////////////////// |
| 63 |
| 64 const GrXferProcessor* GrPorterDuffXPFactory::createXferProcessor() const { |
| 65 return GrPorterDuffXferProcessor::Create(fSrc, fDst); |
| 66 } |
| 67 |
| 68 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, |
| 69 uint32_t knownColorFlags) const
{ |
| 70 if (kOne_GrBlendCoeff == fSrc && kISA_GrBlendCoeff == fDst && |
| 71 kRGBA_GrColorComponentFlags == knownColorFlags) { |
| 72 return true; |
| 73 } |
| 74 return false; |
| 75 } |
| 76 |
OLD | NEW |