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(
), |
| 456 args.fCoords[0].getType()); |
461 fsBuilder->codeAppendf(";"); | 457 fsBuilder->codeAppendf(";"); |
462 | 458 |
463 emit_custom_xfermode_code(mode, fsBuilder, outputColor, inputColor, dstC
olor); | 459 emit_custom_xfermode_code(mode, fsBuilder, args.fOutputColor, args.fInpu
tColor, dstColor); |
464 } | 460 } |
465 | 461 |
466 void setData(const GrGLProgramDataManager&, const GrProcessor&) override {} | 462 void setData(const GrGLProgramDataManager&, const GrProcessor&) override {} |
467 | 463 |
468 static void GenKey(const GrFragmentProcessor& proc, const GrGLSLCaps&, GrPro
cessorKeyBuilder* b) { | 464 static void GenKey(const GrFragmentProcessor& proc, const GrGLSLCaps&, GrPro
cessorKeyBuilder* b) { |
469 // The background may come from the dst or from a texture. | 465 // The background may come from the dst or from a texture. |
470 uint32_t key = proc.numTextures(); | 466 uint32_t key = proc.numTextures(); |
471 SkASSERT(key <= 1); | 467 SkASSERT(key <= 1); |
472 key |= proc.cast<GrCustomXferFP>().mode() << 1; | 468 key |= proc.cast<GrCustomXferFP>().mode() << 1; |
473 b->add32(key); | 469 b->add32(key); |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 } | 809 } |
814 | 810 |
815 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); | 811 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); |
816 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { | 812 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { |
817 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, | 813 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, |
818 SkXfermode::kLastSeparableMode); | 814 SkXfermode::kLastSeparableMode); |
819 | 815 |
820 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); | 816 return SkNEW_ARGS(GrCustomXPFactory, (static_cast<SkXfermode::Mode>(mode))); |
821 } | 817 } |
822 | 818 |
OLD | NEW |