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 GrProcessorKey& key, | |
31 const char* outputColor, | |
32 const char* inputColor, | |
33 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
| |
34 const TextureSamplerArray& samplers) SK_OVERRIDE { | |
35 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | |
36 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
| |
37 } | |
38 | |
39 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O VERRIDE {}; | |
40 | |
41 static void GenKey(const GrProcessor&, const GrGLCaps& caps, GrProcessorKeyB uilder* b) {}; | |
42 | |
43 private: | |
44 typedef GrGLXferProcessor INHERITED; | |
45 }; | |
46 | |
47 /////////////////////////////////////////////////////////////////////////////// | |
48 | |
49 GrPorterDuffXferProcessor::GrPorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBl endCoeff dstBlend) | |
50 : INHERITED(srcBlend, dstBlend) {} | |
51 | |
52 GrPorterDuffXferProcessor::~GrPorterDuffXferProcessor() { | |
53 } | |
54 | |
55 const GrBackendFragmentProcessorFactory& GrPorterDuffXferProcessor::getFactory() const { | |
56 return GrTBackendFragmentProcessorFactory<GrPorterDuffXferProcessor>::getIns tance(); | |
57 } | |
58 | |
59 void GrPorterDuffXferProcessor::onComputeInvariantOutput(GrInvariantOutput* inou t) const { | |
60 inout->setToUnknown(GrInvariantOutput::kWillNot_ReadInput); | |
61 } | |
62 | |
63 /////////////////////////////////////////////////////////////////////////////// | |
64 | |
65 const GrXferProcessor* GrPorterDuffXPFactory::createXferProcessor() const { | |
66 return GrPorterDuffXferProcessor::Create(fSrc, fDst); | |
67 } | |
68 | |
69 bool GrPorterDuffXPFactory::supportsLCDText(const GrDrawState& drawState) const { | |
70 if (kOne_GrBlendCoeff == fSrc && kISA_GrBlendCoeff == fDst && | |
71 0 == drawState.numColorStages() && !drawState.coverageWillBeSingleCompon ent()) { | |
72 return true; | |
73 } | |
74 return false; | |
75 } | |
76 | |
OLD | NEW |