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 "GrFragmentProcessor.h" | 8 #include "GrFragmentProcessor.h" |
9 #include "GrCoordTransform.h" | 9 #include "GrCoordTransform.h" |
10 #include "GrInvariantOutput.h" | 10 #include "GrInvariantOutput.h" |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 this->registerChildProcessor(std::move(children[i])); | 303 this->registerChildProcessor(std::move(children[i])); |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 const char* name() const override { return "Series"; } | 307 const char* name() const override { return "Series"; } |
308 | 308 |
309 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { | 309 GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { |
310 class GLFP : public GrGLSLFragmentProcessor { | 310 class GLFP : public GrGLSLFragmentProcessor { |
311 public: | 311 public: |
312 void emitCode(EmitArgs& args) override { | 312 void emitCode(EmitArgs& args) override { |
313 SkString input(args.fInputColor); | 313 // First guy's input might be nil. |
314 for (int i = 0; i < this->numChildProcessors() - 1; ++i) { | 314 SkString temp("out0"); |
315 SkString temp; | 315 this->emitChild(0, args.fInputColor, &temp, args); |
| 316 SkString input = temp; |
| 317 for (int i = 1; i < this->numChildProcessors() - 1; ++i) { |
316 temp.printf("out%d", i); | 318 temp.printf("out%d", i); |
317 this->emitChild(i, input.c_str(), &temp, args); | 319 this->emitChild(i, input.c_str(), &temp, args); |
318 input = temp; | 320 input = temp; |
319 } | 321 } |
320 // Last guy writes to our output variable. | 322 // Last guy writes to our output variable. |
321 this->emitChild(this->numChildProcessors() - 1, input.c_str(
), args); | 323 this->emitChild(this->numChildProcessors() - 1, input.c_str(
), args); |
322 } | 324 } |
323 }; | 325 }; |
324 return new GLFP; | 326 return new GLFP; |
325 } | 327 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 } else { | 370 } else { |
369 series += firstIdx; | 371 series += firstIdx; |
370 cnt -= firstIdx; | 372 cnt -= firstIdx; |
371 } | 373 } |
372 | 374 |
373 if (1 == cnt) { | 375 if (1 == cnt) { |
374 return series[0]; | 376 return series[0]; |
375 } | 377 } |
376 return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); | 378 return sk_sp<GrFragmentProcessor>(new SeriesFragmentProcessor(series, cnt)); |
377 } | 379 } |
OLD | NEW |