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 "gl/GrGLProcessor.h" | 9 #include "gl/GrGLProcessor.h" |
10 #include "gl/GrGLSL.h" | 10 #include "gl/GrGLSL.h" |
11 #include "gl/builders/GrGLProgramBuilder.h" | 11 #include "gl/builders/GrGLProgramBuilder.h" |
12 | 12 |
13 class GLConstColorProcessor : public GrGLFragmentProcessor { | 13 class GLConstColorProcessor : public GrGLFragmentProcessor { |
14 public: | 14 public: |
15 GLConstColorProcessor() : fPrevColor(GrColor_ILLEGAL) {} | 15 GLConstColorProcessor() : fPrevColor(GrColor_ILLEGAL) {} |
16 | 16 |
17 void emitCode(GrGLFPBuilder* builder, | 17 void emitCode(GrGLFPBuilder* builder, |
18 const GrFragmentProcessor& fp, | 18 const GrFragmentProcessor& fp, |
19 const char* outputColor, | 19 const char* outputColor, |
20 const char* inputColor, | 20 const char* inputColor, |
21 const TransformedCoordsArray& coords, | 21 const TransformedCoordsArray& coords, |
22 const TextureSamplerArray& samplers) override { | 22 const TextureSamplerArray& samplers) override { |
23 GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 23 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
24 const char* colorUni; | 24 const char* colorUni; |
25 fColorUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibi
lity, | 25 fColorUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibi
lity, |
26 kVec4f_GrSLType, kMedium_GrSLPrecisi
on, "constantColor", | 26 kVec4f_GrSLType, kMedium_GrSLPrecisi
on, "constantColor", |
27 &colorUni); | 27 &colorUni); |
28 switch (fp.cast<GrConstColorProcessor>().inputMode()) { | 28 switch (fp.cast<GrConstColorProcessor>().inputMode()) { |
29 case GrConstColorProcessor::kIgnore_InputMode: | 29 case GrConstColorProcessor::kIgnore_InputMode: |
30 fsBuilder->codeAppendf("%s = %s;", outputColor, colorUni); | 30 fsBuilder->codeAppendf("%s = %s;", outputColor, colorUni); |
31 break; | 31 break; |
32 case GrConstColorProcessor::kModulateRGBA_InputMode: | 32 case GrConstColorProcessor::kModulateRGBA_InputMode: |
33 fsBuilder->codeAppendf("%s = %s * %s;", outputColor, inputColor,
colorUni); | 33 fsBuilder->codeAppendf("%s = %s * %s;", outputColor, inputColor,
colorUni); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 color = 0; | 124 color = 0; |
125 break; | 125 break; |
126 case 2: | 126 case 2: |
127 color = random->nextULessThan(0x100); | 127 color = random->nextULessThan(0x100); |
128 color = color | (color << 8) | (color << 16) | (color << 24); | 128 color = color | (color << 8) | (color << 16) | (color << 24); |
129 break; | 129 break; |
130 } | 130 } |
131 InputMode mode = static_cast<InputMode>(random->nextULessThan(kInputModeCnt)
); | 131 InputMode mode = static_cast<InputMode>(random->nextULessThan(kInputModeCnt)
); |
132 return GrConstColorProcessor::Create(color, mode); | 132 return GrConstColorProcessor::Create(color, mode); |
133 } | 133 } |
OLD | NEW |