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/GrCustomXfermode.h" | 8 #include "effects/GrCustomXfermode.h" |
9 #include "effects/GrCustomXfermodePriv.h" | 9 #include "effects/GrCustomXfermodePriv.h" |
10 | 10 |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
440 } | 440 } |
441 } | 441 } |
442 | 442 |
443 /////////////////////////////////////////////////////////////////////////////// | 443 /////////////////////////////////////////////////////////////////////////////// |
444 | 444 |
445 class GLCustomXferFP : public GrGLFragmentProcessor { | 445 class GLCustomXferFP : public GrGLFragmentProcessor { |
446 public: | 446 public: |
447 GLCustomXferFP(const GrFragmentProcessor&) {} | 447 GLCustomXferFP(const GrFragmentProcessor&) {} |
448 ~GLCustomXferFP() override {}; | 448 ~GLCustomXferFP() override {}; |
449 | 449 |
450 void emitCode(GrGLFPBuilder* builder, | 450 void emitCode(EmitArgs& args) override { |
451 const GrFragmentProcessor& fp, | 451 SkXfermode::Mode mode = args.fFp.cast<GrCustomXferFP>().mode(); |
452 const char* outputColor, | 452 GrGLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder (); |
453 const char* inputColor, | |
454 const TransformedCoordsArray& coords, | |
455 const TextureSamplerArray& samplers) override { | |
456 SkXfermode::Mode mode = fp.cast<GrCustomXferFP>().mode(); | |
457 GrGLFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | |
458 const char* dstColor = "bgColor"; | 453 const char* dstColor = "bgColor"; |
459 fsBuilder->codeAppendf("vec4 %s = ", dstColor); | 454 fsBuilder->codeAppendf("vec4 %s = ", dstColor); |
460 fsBuilder->appendTextureLookup(samplers[0], coords[0].c_str(), coords[0] .getType()); | 455 fsBuilder->appendTextureLookup(args.fSamplers[0], args.fCoords[0].c_str( ), args.fCoords[0].getType()); |
joshualitt
2015/07/22 19:34:05
line wrap @100
| |
461 fsBuilder->codeAppendf(";"); | 456 fsBuilder->codeAppendf(";"); |
462 | 457 |
463 emit_custom_xfermode_code(mode, fsBuilder, outputColor, inputColor, dstC olor); | 458 emit_custom_xfermode_code(mode, fsBuilder, args.fOutputColor, args.fInpu tColor, dstColor); |
464 } | 459 } |
465 | 460 |
466 void setData(const GrGLProgramDataManager&, const GrProcessor&) override {} | 461 void setData(const GrGLProgramDataManager&, const GrProcessor&) override {} |
467 | 462 |
468 static void GenKey(const GrFragmentProcessor& proc, const GrGLSLCaps&, GrPro cessorKeyBuilder* b) { | 463 static void GenKey(const GrFragmentProcessor& proc, const GrGLSLCaps&, GrPro cessorKeyBuilder* b) { |
469 // The background may come from the dst or from a texture. | 464 // The background may come from the dst or from a texture. |
470 uint32_t key = proc.numTextures(); | 465 uint32_t key = proc.numTextures(); |
471 SkASSERT(key <= 1); | 466 SkASSERT(key <= 1); |
472 key |= proc.cast<GrCustomXferFP>().mode() << 1; | 467 key |= proc.cast<GrCustomXferFP>().mode() << 1; |
473 b->add32(key); | 468 b->add32(key); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
813 } | 808 } |
814 | 809 |
815 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); | 810 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); |
816 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { | 811 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { |
817 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, | 812 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, |
818 SkXfermode::kLastSeparableMode); | 813 SkXfermode::kLastSeparableMode); |
819 | 814 |
820 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); | 815 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); |
821 } | 816 } |
822 | 817 |
OLD | NEW |