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 "gl/GrGLFragmentProcessor.h" | 11 #include "gl/GrGLFragmentProcessor.h" |
12 #include "gl/builders/GrGLProgramBuilder.h" | 12 #include "gl/builders/GrGLProgramBuilder.h" |
| 13 #include "glsl/GrGLSLProgramDataManager.h" |
13 #include "effects/GrConstColorProcessor.h" | 14 #include "effects/GrConstColorProcessor.h" |
14 #include "effects/GrXfermodeFragmentProcessor.h" | 15 #include "effects/GrXfermodeFragmentProcessor.h" |
15 | 16 |
16 GrFragmentProcessor::~GrFragmentProcessor() { | 17 GrFragmentProcessor::~GrFragmentProcessor() { |
17 // If we got here then our ref count must have reached zero, so we will have
converted refs | 18 // If we got here then our ref count must have reached zero, so we will have
converted refs |
18 // to pending executions for all children. | 19 // to pending executions for all children. |
19 for (int i = 0; i < fChildProcessors.count(); ++i) { | 20 for (int i = 0; i < fChildProcessors.count(); ++i) { |
20 fChildProcessors[i]->completedExecution(); | 21 fChildProcessors[i]->completedExecution(); |
21 } | 22 } |
22 } | 23 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 GLFP() : fHaveSetColor(false) {} | 225 GLFP() : fHaveSetColor(false) {} |
225 void emitCode(EmitArgs& args) override { | 226 void emitCode(EmitArgs& args) override { |
226 const char* colorName; | 227 const char* colorName; |
227 fColorUni = args.fBuilder->addUniform(GrGLProgramBuilder::kF
ragment_Visibility, | 228 fColorUni = args.fBuilder->addUniform(GrGLProgramBuilder::kF
ragment_Visibility, |
228 kVec4f_GrSLType, kDefa
ult_GrSLPrecision, | 229 kVec4f_GrSLType, kDefa
ult_GrSLPrecision, |
229 "Color", &colorName); | 230 "Color", &colorName); |
230 this->emitChild(0, colorName, args); | 231 this->emitChild(0, colorName, args); |
231 } | 232 } |
232 | 233 |
233 private: | 234 private: |
234 void onSetData(const GrGLProgramDataManager& pdman, | 235 void onSetData(const GrGLSLProgramDataManager& pdman, |
235 const GrProcessor& fp) override { | 236 const GrProcessor& fp) override { |
236 GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fCo
lor; | 237 GrColor color = fp.cast<ReplaceInputFragmentProcessor>().fCo
lor; |
237 if (!fHaveSetColor || color != fPreviousColor) { | 238 if (!fHaveSetColor || color != fPreviousColor) { |
238 static const GrGLfloat scale = 1.f / 255.f; | 239 static const float scale = 1.f / 255.f; |
239 GrGLfloat floatColor[4] = { | 240 float floatColor[4] = { |
240 GrColorUnpackR(color) * scale, | 241 GrColorUnpackR(color) * scale, |
241 GrColorUnpackG(color) * scale, | 242 GrColorUnpackG(color) * scale, |
242 GrColorUnpackB(color) * scale, | 243 GrColorUnpackB(color) * scale, |
243 GrColorUnpackA(color) * scale, | 244 GrColorUnpackA(color) * scale, |
244 }; | 245 }; |
245 pdman.set4fv(fColorUni, 1, floatColor); | 246 pdman.set4fv(fColorUni, 1, floatColor); |
246 fPreviousColor = color; | 247 fPreviousColor = color; |
247 fHaveSetColor = true; | 248 fHaveSetColor = true; |
248 } | 249 } |
249 } | 250 } |
250 | 251 |
251 GrGLProgramDataManager::UniformHandle fColorUni; | 252 GrGLSLProgramDataManager::UniformHandle fColorUni; |
252 bool fHaveSetColor; | 253 bool fHaveSetColor; |
253 GrColor fPreviousColor; | 254 GrColor fPreviousColor; |
254 }; | 255 }; |
255 | 256 |
256 return new GLFP; | 257 return new GLFP; |
257 } | 258 } |
258 | 259 |
259 private: | 260 private: |
260 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder*
b) const override {} | 261 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder*
b) const override {} |
261 | 262 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 } | 367 } |
367 } | 368 } |
368 | 369 |
369 if (1 == cnt) { | 370 if (1 == cnt) { |
370 return SkRef(series[0]); | 371 return SkRef(series[0]); |
371 } else { | 372 } else { |
372 return new SeriesFragmentProcessor(series, cnt); | 373 return new SeriesFragmentProcessor(series, cnt); |
373 } | 374 } |
374 } | 375 } |
375 | 376 |
OLD | NEW |