| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 setSatFunction); | 291 setSatFunction); |
| 292 | 292 |
| 293 } | 293 } |
| 294 | 294 |
| 295 static void emit_custom_xfermode_code(SkXfermode::Mode mode, | 295 static void emit_custom_xfermode_code(SkXfermode::Mode mode, |
| 296 GrGLFragmentBuilder* fsBuilder, | 296 GrGLFragmentBuilder* fsBuilder, |
| 297 const char* outputColor, | 297 const char* outputColor, |
| 298 const char* inputColor, | 298 const char* inputColor, |
| 299 const char* dstColor) { | 299 const char* dstColor) { |
| 300 // We don't try to optimize for this case at all | 300 // We don't try to optimize for this case at all |
| 301 if (NULL == inputColor) { | 301 if (nullptr == inputColor) { |
| 302 fsBuilder->codeAppendf("const vec4 ones = vec4(1);"); | 302 fsBuilder->codeAppendf("const vec4 ones = vec4(1);"); |
| 303 inputColor = "ones"; | 303 inputColor = "ones"; |
| 304 } | 304 } |
| 305 fsBuilder->codeAppendf("// SkXfermode::Mode: %s\n", SkXfermode::ModeName(mod
e)); | 305 fsBuilder->codeAppendf("// SkXfermode::Mode: %s\n", SkXfermode::ModeName(mod
e)); |
| 306 | 306 |
| 307 // These all perform src-over on the alpha channel. | 307 // These all perform src-over on the alpha channel. |
| 308 fsBuilder->codeAppendf("%s.a = %s.a + (1.0 - %s.a) * %s.a;", | 308 fsBuilder->codeAppendf("%s.a = %s.a + (1.0 - %s.a) * %s.a;", |
| 309 outputColor, inputColor, inputColor, dstColor); | 309 outputColor, inputColor, inputColor, dstColor); |
| 310 | 310 |
| 311 switch (mode) { | 311 switch (mode) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 /////////////////////////////////////////////////////////////////////////////// | 430 /////////////////////////////////////////////////////////////////////////////// |
| 431 // Fragment Processor | 431 // Fragment Processor |
| 432 /////////////////////////////////////////////////////////////////////////////// | 432 /////////////////////////////////////////////////////////////////////////////// |
| 433 | 433 |
| 434 GrFragmentProcessor* GrCustomXfermode::CreateFP(GrProcessorDataManager* procData
Manager, | 434 GrFragmentProcessor* GrCustomXfermode::CreateFP(GrProcessorDataManager* procData
Manager, |
| 435 SkXfermode::Mode mode, GrTexture
* background) { | 435 SkXfermode::Mode mode, GrTexture
* background) { |
| 436 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 436 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
| 437 return NULL; | 437 return nullptr; |
| 438 } else { | 438 } else { |
| 439 return new GrCustomXferFP(procDataManager, mode, background); | 439 return new GrCustomXferFP(procDataManager, mode, background); |
| 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&) {} |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 const SkXfermode::Mode fMode; | 562 const SkXfermode::Mode fMode; |
| 563 const GrBlendEquation fHWBlendEquation; | 563 const GrBlendEquation fHWBlendEquation; |
| 564 | 564 |
| 565 typedef GrXferProcessor INHERITED; | 565 typedef GrXferProcessor INHERITED; |
| 566 }; | 566 }; |
| 567 | 567 |
| 568 /////////////////////////////////////////////////////////////////////////////// | 568 /////////////////////////////////////////////////////////////////////////////// |
| 569 | 569 |
| 570 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { | 570 GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) { |
| 571 if (!GrCustomXfermode::IsSupportedMode(mode)) { | 571 if (!GrCustomXfermode::IsSupportedMode(mode)) { |
| 572 return NULL; | 572 return nullptr; |
| 573 } else { | 573 } else { |
| 574 return new GrCustomXPFactory(mode); | 574 return new GrCustomXPFactory(mode); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 | 577 |
| 578 /////////////////////////////////////////////////////////////////////////////// | 578 /////////////////////////////////////////////////////////////////////////////// |
| 579 | 579 |
| 580 class GLCustomXP : public GrGLXferProcessor { | 580 class GLCustomXP : public GrGLXferProcessor { |
| 581 public: | 581 public: |
| 582 GLCustomXP(const GrXferProcessor&) {} | 582 GLCustomXP(const GrXferProcessor&) {} |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 } | 805 } |
| 806 | 806 |
| 807 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); | 807 GR_DEFINE_XP_FACTORY_TEST(GrCustomXPFactory); |
| 808 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { | 808 GrXPFactory* GrCustomXPFactory::TestCreate(GrProcessorTestData* d) { |
| 809 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, | 809 int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1, |
| 810 SkXfermode::kLastSeparableMode); | 810 SkXfermode::kLastSeparableMode); |
| 811 | 811 |
| 812 return new GrCustomXPFactory(static_cast<SkXfermode::Mode>(mode)); | 812 return new GrCustomXPFactory(static_cast<SkXfermode::Mode>(mode)); |
| 813 } | 813 } |
| 814 | 814 |
| OLD | NEW |