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