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

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

Issue 1251173002: Added GrGLFragmentProcessor::EmitArgs struct for use with emitCode() (Closed) Base URL: https://skia.googlesource.com/skia@composeshader_gpu
Patch Set: Created 5 years, 5 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 | « src/gpu/effects/GrConfigConversionEffect.cpp ('k') | src/gpu/effects/GrConvexPolyEffect.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(GrGLFPBuilder* builder, 16 void emitCode(EmitArgs& args) override {
17 const GrFragmentProcessor& fp, 17 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder ();
18 const char* outputColor,
19 const char* inputColor,
20 const TransformedCoordsArray& coords,
21 const TextureSamplerArray& samplers) override {
22 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
23 const char* colorUni; 18 const char* colorUni;
24 fColorUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibi lity, 19 fColorUniform = args.fBuilder->addUniform(GrGLProgramBuilder::kFragment_ Visibility,
25 kVec4f_GrSLType, kMedium_GrSLPrecisi on, "constantColor", 20 kVec4f_GrSLType, kMedium_GrSLPrecisi on, "constantColor",
26 &colorUni); 21 &colorUni);
27 switch (fp.cast<GrConstColorProcessor>().inputMode()) { 22 switch (args.fFp.cast<GrConstColorProcessor>().inputMode()) {
28 case GrConstColorProcessor::kIgnore_InputMode: 23 case GrConstColorProcessor::kIgnore_InputMode:
29 fsBuilder->codeAppendf("%s = %s;", outputColor, colorUni); 24 fsBuilder->codeAppendf("%s = %s;", args.fOutputColor, colorUni);
30 break; 25 break;
31 case GrConstColorProcessor::kModulateRGBA_InputMode: 26 case GrConstColorProcessor::kModulateRGBA_InputMode:
32 fsBuilder->codeAppendf("%s = %s * %s;", outputColor, inputColor, colorUni); 27 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputColor, args. fInputColor,
28 colorUni);
33 break; 29 break;
34 case GrConstColorProcessor::kModulateA_InputMode: 30 case GrConstColorProcessor::kModulateA_InputMode:
35 fsBuilder->codeAppendf("%s = %s.a * %s;", outputColor, inputColo r, colorUni); 31 fsBuilder->codeAppendf("%s = %s.a * %s;", args.fOutputColor, arg s.fInputColor,
32 colorUni);
36 break; 33 break;
37 } 34 }
38 } 35 }
39 36
40 void setData(const GrGLProgramDataManager& pdm, const GrProcessor& processor ) override { 37 void setData(const GrGLProgramDataManager& pdm, const GrProcessor& processor ) override {
41 GrColor color = processor.cast<GrConstColorProcessor>().color(); 38 GrColor color = processor.cast<GrConstColorProcessor>().color();
42 // We use the "illegal" color value as an uninit sentinel. However, ut i sn't inherently 39 // We use the "illegal" color value as an uninit sentinel. However, ut i sn't inherently
43 // illegal to use this processor with unpremul colors. So we correctly h andle the case 40 // illegal to use this processor with unpremul colors. So we correctly h andle the case
44 // when the "illegal" color is used but we will always upload it. 41 // when the "illegal" color is used but we will always upload it.
45 if (GrColor_ILLEGAL == color || fPrevColor != color) { 42 if (GrColor_ILLEGAL == color || fPrevColor != color) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 color = 0; 118 color = 0;
122 break; 119 break;
123 case 2: 120 case 2:
124 color = d->fRandom->nextULessThan(0x100); 121 color = d->fRandom->nextULessThan(0x100);
125 color = color | (color << 8) | (color << 16) | (color << 24); 122 color = color | (color << 8) | (color << 16) | (color << 24);
126 break; 123 break;
127 } 124 }
128 InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputMode Cnt)); 125 InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputMode Cnt));
129 return GrConstColorProcessor::Create(color, mode); 126 return GrConstColorProcessor::Create(color, mode);
130 } 127 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrConfigConversionEffect.cpp ('k') | src/gpu/effects/GrConvexPolyEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698