OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 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 "effects/GrExtractAlphaFragmentProcessor.h" | |
9 #include "gl/GrGLFragmentProcessor.h" | |
10 #include "gl/builders/GrGLProgramBuilder.h" | |
11 | |
12 class GLExtractAlphaFragmentProcessor : public GrGLFragmentProcessor { | |
13 public: | |
14 GLExtractAlphaFragmentProcessor() {} | |
15 | |
16 void emitCode(EmitArgs& args) override { | |
17 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder
(); | |
18 fsBuilder->codeAppendf("vec4 alpha4 = %s.aaaa;", args.fInputColor); | |
19 SkString output; | |
20 this->emitChild(0, "alpha4", &output, args); | |
21 fsBuilder->codeAppendf("%s = %s;", args.fOutputColor, output.c_str()); | |
22 } | |
23 | |
24 private: | |
25 typedef GrGLFragmentProcessor INHERITED; | |
26 }; | |
27 | |
28 GrGLFragmentProcessor* GrExtractAlphaFragmentProcessor::onCreateGLInstance() con
st { | |
29 return SkNEW(GLExtractAlphaFragmentProcessor); | |
30 } | |
31 | |
32 void GrExtractAlphaFragmentProcessor::onGetGLProcessorKey(const GrGLSLCaps&, | |
33 GrProcessorKeyBuilder*
) const { | |
34 } | |
35 | |
36 bool GrExtractAlphaFragmentProcessor::onIsEqual(const GrFragmentProcessor&) cons
t { return true; } | |
37 | |
38 void GrExtractAlphaFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput
* inout) const { | |
39 if (inout->validFlags() & kA_GrColorComponentFlag) { | |
40 GrColor color = GrColorPackA4(GrColorUnpackA(inout->color())); | |
41 inout->setToOther(kRGBA_GrColorComponentFlags, color, | |
42 GrInvariantOutput::kWill_ReadInput); | |
43 } else { | |
44 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); | |
45 } | |
46 this->childProcessor(0).computeInvariantOutput(inout); | |
47 } | |
OLD | NEW |