Chromium Code Reviews| 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(const GrDrawState& drawState) co nst { | |
| 69 if (kOne_GrBlendCoeff == fSrc && kISA_GrBlendCoeff == fDst && | |
| 70 0 == drawState.numColorStages() && !drawState.coverageWillBeSingleCompon ent()) { | |
|
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
| |
| 71 return true; | |
| 72 } | |
| 73 return false; | |
| 74 } | |
| 75 | |
| OLD | NEW |