OLD | NEW |
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 "GrInvariantOutput.h" | 9 #include "GrInvariantOutput.h" |
10 #include "glsl/GrGLSLFragmentProcessor.h" | 10 #include "glsl/GrGLSLFragmentProcessor.h" |
11 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 11 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
12 #include "glsl/GrGLSLProgramDataManager.h" | 12 #include "glsl/GrGLSLProgramDataManager.h" |
13 #include "glsl/GrGLSLUniformHandler.h" | 13 #include "glsl/GrGLSLUniformHandler.h" |
14 | 14 |
15 class GLConstColorProcessor : public GrGLSLFragmentProcessor { | 15 class GLConstColorProcessor : public GrGLSLFragmentProcessor { |
16 public: | 16 public: |
17 GLConstColorProcessor() : fPrevColor(GrColor_ILLEGAL) {} | 17 GLConstColorProcessor() : fPrevColor(GrColor_ILLEGAL) {} |
18 | 18 |
19 void emitCode(EmitArgs& args) override { | 19 void emitCode(EmitArgs& args) override { |
20 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 20 GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder; |
21 const char* colorUni; | 21 const char* colorUni; |
22 fColorUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, | 22 fColorUniform = args.fUniformHandler->addUniform(kFragment_GrShaderFlag, |
23 kVec4f_GrSLType, kMediu
m_GrSLPrecision, | 23 kVec4f_GrSLType, kMediu
m_GrSLPrecision, |
24 "constantColor", | 24 "constantColor", |
25 &colorUni); | 25 &colorUni); |
26 GrConstColorProcessor::InputMode mode = args.fFp.cast<GrConstColorProces
sor>().inputMode(); | 26 GrConstColorProcessor::InputMode mode = args.fFp.cast<GrConstColorProces
sor>().inputMode(); |
27 if (!args.fInputColor) { | 27 if (!args.fInputColor) { |
28 mode = GrConstColorProcessor::kIgnore_InputMode; | 28 mode = GrConstColorProcessor::kIgnore_InputMode; |
29 } | 29 } |
30 switch (mode) { | 30 switch (mode) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 color = 0; | 128 color = 0; |
129 break; | 129 break; |
130 case 2: | 130 case 2: |
131 color = d->fRandom->nextULessThan(0x100); | 131 color = d->fRandom->nextULessThan(0x100); |
132 color = color | (color << 8) | (color << 16) | (color << 24); | 132 color = color | (color << 8) | (color << 16) | (color << 24); |
133 break; | 133 break; |
134 } | 134 } |
135 InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputMode
Cnt)); | 135 InputMode mode = static_cast<InputMode>(d->fRandom->nextULessThan(kInputMode
Cnt)); |
136 return GrConstColorProcessor::Create(color, mode); | 136 return GrConstColorProcessor::Create(color, mode); |
137 } | 137 } |
OLD | NEW |