OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrFragmentProcessor.h" | 9 #include "GrFragmentProcessor.h" |
10 #include "GrCoordTransform.h" | 10 #include "GrCoordTransform.h" |
| 11 #include "GrInvariantOutput.h" |
| 12 #include "GrProcOptInfo.h" |
11 #include "glsl/GrGLSLFragmentProcessor.h" | 13 #include "glsl/GrGLSLFragmentProcessor.h" |
12 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 14 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
13 #include "glsl/GrGLSLProgramBuilder.h" | |
14 #include "glsl/GrGLSLProgramDataManager.h" | 15 #include "glsl/GrGLSLProgramDataManager.h" |
| 16 #include "glsl/GrGLSLUniformHandler.h" |
15 #include "effects/GrConstColorProcessor.h" | 17 #include "effects/GrConstColorProcessor.h" |
16 #include "effects/GrXfermodeFragmentProcessor.h" | 18 #include "effects/GrXfermodeFragmentProcessor.h" |
17 | 19 |
18 GrFragmentProcessor::~GrFragmentProcessor() { | 20 GrFragmentProcessor::~GrFragmentProcessor() { |
19 // If we got here then our ref count must have reached zero, so we will have
converted refs | 21 // If we got here then our ref count must have reached zero, so we will have
converted refs |
20 // to pending executions for all children. | 22 // to pending executions for all children. |
21 for (int i = 0; i < fChildProcessors.count(); ++i) { | 23 for (int i = 0; i < fChildProcessors.count(); ++i) { |
22 fChildProcessors[i]->completedExecution(); | 24 fChildProcessors[i]->completedExecution(); |
23 } | 25 } |
24 } | 26 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 221 } |
220 | 222 |
221 const char* name() const override { return "Replace Color"; } | 223 const char* name() const override { return "Replace Color"; } |
222 | 224 |
223 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { | 225 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { |
224 class GLFP : public GrGLSLFragmentProcessor { | 226 class GLFP : public GrGLSLFragmentProcessor { |
225 public: | 227 public: |
226 GLFP() : fHaveSetColor(false) {} | 228 GLFP() : fHaveSetColor(false) {} |
227 void emitCode(EmitArgs& args) override { | 229 void emitCode(EmitArgs& args) override { |
228 const char* colorName; | 230 const char* colorName; |
229 fColorUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::
kFragment_Visibility, | 231 fColorUni = args.fUniformHandler->addUniform( |
230 kVec4f_GrSLType, kDefa
ult_GrSLPrecision, | 232 GrGLSLUniformHandler::k
Fragment_Visibility, |
231 "Color", &colorName); | 233 kVec4f_GrSLType, kDefau
lt_GrSLPrecision, |
| 234 "Color", &colorName); |
232 this->emitChild(0, colorName, args); | 235 this->emitChild(0, colorName, args); |
233 } | 236 } |
234 | 237 |
235 private: | 238 private: |
236 void onSetData(const GrGLSLProgramDataManager& pdman, | 239 void onSetData(const GrGLSLProgramDataManager& pdman, |
237 const GrProcessor& fp) override { | 240 const GrProcessor& fp) override { |
238 GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fCo
lor; | 241 GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fCo
lor; |
239 if (!fHaveSetColor || color != fPreviousColor) { | 242 if (!fHaveSetColor || color != fPreviousColor) { |
240 static const float scale = 1.f / 255.f; | 243 static const float scale = 1.f / 255.f; |
241 float floatColor[4] = { | 244 float floatColor[4] = { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 } | 372 } |
370 } | 373 } |
371 | 374 |
372 if (1 == cnt) { | 375 if (1 == cnt) { |
373 return SkRef(series[0]); | 376 return SkRef(series[0]); |
374 } else { | 377 } else { |
375 return new SeriesFragmentProcessor(series, cnt); | 378 return new SeriesFragmentProcessor(series, cnt); |
376 } | 379 } |
377 } | 380 } |
378 | 381 |
OLD | NEW |