Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp

Issue 1341853002: Test that GrFragmentProcessors work without input colors. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update more FPs Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 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 "effects/GrExtractAlphaFragmentProcessor.h" 8 #include "effects/GrExtractAlphaFragmentProcessor.h"
9 #include "gl/GrGLFragmentProcessor.h" 9 #include "gl/GrGLFragmentProcessor.h"
10 #include "gl/builders/GrGLProgramBuilder.h" 10 #include "gl/builders/GrGLProgramBuilder.h"
11 11
12 class GLExtractAlphaFragmentProcessor : public GrGLFragmentProcessor { 12 class GLExtractAlphaFragmentProcessor : public GrGLFragmentProcessor {
13 public: 13 public:
14 GLExtractAlphaFragmentProcessor() {} 14 GLExtractAlphaFragmentProcessor() {}
15 15
16 void emitCode(EmitArgs& args) override { 16 void emitCode(EmitArgs& args) override {
17 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder (); 17 if (args.fInputColor) {
18 fsBuilder->codeAppendf("vec4 alpha4 = %s.aaaa;", args.fInputColor); 18 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBui lder();
19 this->emitChild(0, "alpha4", args.fOutputColor, args); 19 fsBuilder->codeAppendf("vec4 alpha4 = %s.aaaa;", args.fInputColor);
20 this->emitChild(0, "alpha4", args.fOutputColor, args);
21 } else {
22 this->emitChild(0, nullptr, args.fOutputColor, args);
23 }
20 } 24 }
21 25
22 private: 26 private:
23 typedef GrGLFragmentProcessor INHERITED; 27 typedef GrGLFragmentProcessor INHERITED;
24 }; 28 };
25 29
26 GrGLFragmentProcessor* GrExtractAlphaFragmentProcessor::onCreateGLInstance() con st { 30 GrGLFragmentProcessor* GrExtractAlphaFragmentProcessor::onCreateGLInstance() con st {
27 return SkNEW(GLExtractAlphaFragmentProcessor); 31 return SkNEW(GLExtractAlphaFragmentProcessor);
28 } 32 }
29 33
30 void GrExtractAlphaFragmentProcessor::onGetGLProcessorKey(const GrGLSLCaps&, 34 void GrExtractAlphaFragmentProcessor::onGetGLProcessorKey(const GrGLSLCaps&,
31 GrProcessorKeyBuilder* ) const { 35 GrProcessorKeyBuilder* ) const {
32 } 36 }
33 37
34 bool GrExtractAlphaFragmentProcessor::onIsEqual(const GrFragmentProcessor&) cons t { return true; } 38 bool GrExtractAlphaFragmentProcessor::onIsEqual(const GrFragmentProcessor&) cons t { return true; }
35 39
36 void GrExtractAlphaFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput * inout) const { 40 void GrExtractAlphaFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput * inout) const {
37 if (inout->validFlags() & kA_GrColorComponentFlag) { 41 if (inout->validFlags() & kA_GrColorComponentFlag) {
38 GrColor color = GrColorPackA4(GrColorUnpackA(inout->color())); 42 GrColor color = GrColorPackA4(GrColorUnpackA(inout->color()));
39 inout->setToOther(kRGBA_GrColorComponentFlags, color, 43 inout->setToOther(kRGBA_GrColorComponentFlags, color,
40 GrInvariantOutput::kWill_ReadInput); 44 GrInvariantOutput::kWill_ReadInput);
41 } else { 45 } else {
42 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput); 46 inout->setToUnknown(GrInvariantOutput::kWill_ReadInput);
43 } 47 }
44 this->childProcessor(0).computeInvariantOutput(inout); 48 this->childProcessor(0).computeInvariantOutput(inout);
45 } 49 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConstColorProcessor.cpp ('k') | src/gpu/effects/GrXfermodeFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698