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

Side by Side Diff: src/gpu/effects/GrConstColorProcessor.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
« no previous file with comments | « include/gpu/GrProcessorUnitTest.h ('k') | src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/GrConstColorProcessor.h" 8 #include "effects/GrConstColorProcessor.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 GLConstColorProcessor : public GrGLFragmentProcessor { 12 class GLConstColorProcessor : public GrGLFragmentProcessor {
13 public: 13 public:
14 GLConstColorProcessor() : fPrevColor(GrColor_ILLEGAL) {} 14 GLConstColorProcessor() : fPrevColor(GrColor_ILLEGAL) {}
15 15
16 void emitCode(EmitArgs& args) override { 16 void emitCode(EmitArgs& args) override {
17 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder (); 17 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder ();
18 const char* colorUni; 18 const char* colorUni;
19 fColorUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_ Visibility, 19 fColorUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_ Visibility,
20 kVec4f_GrSLType, kMedium_GrSLPrecisi on, "constantColor", 20 kVec4f_GrSLType, kMedium_GrSLPrecisi on, "constantColor",
21 &colorUni); 21 &colorUni);
22 switch (args.fFp.cast<GrConstColorProcessor>().inputMode()) { 22 GrConstColorProcessor::InputMode mode = args.fFp.cast<GrConstColorProces sor>().inputMode();
23 if (!args.fInputColor) {
24 mode = GrConstColorProcessor::kIgnore_InputMode;
25 }
26 switch (mode) {
23 case GrConstColorProcessor::kIgnore_InputMode: 27 case GrConstColorProcessor::kIgnore_InputMode:
24 fsBuilder->codeAppendf("%s = %s;", args.fOutputColor, colorUni); 28 fsBuilder->codeAppendf("%s = %s;", args.fOutputColor, colorUni);
25 break; 29 break;
26 case GrConstColorProcessor::kModulateRGBA_InputMode: 30 case GrConstColorProcessor::kModulateRGBA_InputMode:
27 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputColor, args. fInputColor, 31 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputColor, args. fInputColor,
28 colorUni); 32 colorUni);
29 break; 33 break;
30 case GrConstColorProcessor::kModulateA_InputMode: 34 case GrConstColorProcessor::kModulateA_InputMode:
31 fsBuilder->codeAppendf("%s = %s.a * %s;", args.fOutputColor, arg s.fInputColor, 35 fsBuilder->codeAppendf("%s = %s.a * %s;", args.fOutputColor, arg s.fInputColor,
32 colorUni); 36 colorUni);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 color = 0; 123 color = 0;
120 break; 124 break;
121 case 2: 125 case 2:
122 color = d->fRandom->nextULessThan(0x100); 126 color = d->fRandom->nextULessThan(0x100);
123 color = color | (color << 8) | (color << 16) | (color << 24); 127 color = color | (color << 8) | (color << 16) | (color << 24);
124 break; 128 break;
125 } 129 }
126 InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputMode Cnt)); 130 InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputMode Cnt));
127 return GrConstColorProcessor::Create(color, mode); 131 return GrConstColorProcessor::Create(color, mode);
128 } 132 }
OLDNEW
« no previous file with comments | « include/gpu/GrProcessorUnitTest.h ('k') | src/gpu/effects/GrExtractAlphaFragmentProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698