OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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/GrPorterDuffXferProcessor.h" | 8 #include "effects/GrPorterDuffXferProcessor.h" |
9 | 9 |
10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 const char* srcCoverage, | 552 const char* srcCoverage, |
553 const char* dstColor, | 553 const char* dstColor, |
554 const char* outColor, | 554 const char* outColor, |
555 const char* outColorSecondary, | 555 const char* outColorSecondary, |
556 const GrXferProcessor& proc) override { | 556 const GrXferProcessor& proc) override { |
557 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>(); | 557 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>(); |
558 | 558 |
559 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.ge
tXfermode()); | 559 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.ge
tXfermode()); |
560 | 560 |
561 // Apply coverage. | 561 // Apply coverage. |
562 INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor,
outColor, | 562 if (xp.dstReadUsesMixedSamples()) { |
563 outColorSecondary, xp); | 563 if (srcCoverage) { |
| 564 fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage); |
| 565 fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCover
age); |
| 566 } else { |
| 567 fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary); |
| 568 } |
| 569 } else if (srcCoverage) { |
| 570 fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;", |
| 571 outColor, srcCoverage, outColor, srcCoverag
e, dstColor); |
| 572 } |
564 } | 573 } |
565 | 574 |
566 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} | 575 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over
ride {} |
567 | 576 |
568 typedef GrGLSLXferProcessor INHERITED; | 577 typedef GrGLSLXferProcessor INHERITED; |
569 }; | 578 }; |
570 | 579 |
571 /////////////////////////////////////////////////////////////////////////////// | 580 /////////////////////////////////////////////////////////////////////////////// |
572 | 581 |
573 void ShaderPDXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&, | 582 void ShaderPDXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&, |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 } | 917 } |
909 return get_lcd_blend_formula(optimizations.fCoveragePOI, | 918 return get_lcd_blend_formula(optimizations.fCoveragePOI, |
910 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); | 919 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); |
911 } | 920 } |
912 // We fallback on the shader XP when the blend formula would use dual source
blending but we | 921 // We fallback on the shader XP when the blend formula would use dual source
blending but we |
913 // don't have support for it. | 922 // don't have support for it. |
914 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, | 923 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, |
915 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); | 924 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); |
916 } | 925 } |
917 | 926 |
OLD | NEW |