Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: src/gpu/effects/GrPorterDuffXferProcessor.cpp

Issue 1488213002: Add in shader blending for CoverageSetOp XP (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebased Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | src/gpu/glsl/GrGLSLBlend.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 public: 541 public:
542 static void GenKey(const GrProcessor& processor, GrProcessorKeyBuilder* b) { 542 static void GenKey(const GrProcessor& processor, GrProcessorKeyBuilder* b) {
543 const ShaderPDXferProcessor& xp = processor.cast<ShaderPDXferProcessor>( ); 543 const ShaderPDXferProcessor& xp = processor.cast<ShaderPDXferProcessor>( );
544 b->add32(xp.getXfermode()); 544 b->add32(xp.getXfermode());
545 } 545 }
546 546
547 private: 547 private:
548 void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb, 548 void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
549 GrGLSLXPFragmentBuilder* fragBuilder, 549 GrGLSLXPFragmentBuilder* fragBuilder,
550 const char* srcColor, 550 const char* srcColor,
551 const char* srcCoverage,
551 const char* dstColor, 552 const char* dstColor,
552 const char* outColor, 553 const char* outColor,
554 const char* outColorSecondary,
553 const GrXferProcessor& proc) override { 555 const GrXferProcessor& proc) override {
554 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>(); 556 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>();
555 557
556 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.ge tXfermode()); 558 GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.ge tXfermode());
559
560 // Apply coverage.
561 if (xp.dstReadUsesMixedSamples()) {
562 if (srcCoverage) {
563 fragBuilder->codeAppendf("%s *= %s;", outColor, srcCoverage);
564 fragBuilder->codeAppendf("%s = %s;", outColorSecondary, srcCover age);
565 } else {
566 fragBuilder->codeAppendf("%s = vec4(1.0);", outColorSecondary);
567 }
568 } else if (srcCoverage) {
569 fragBuilder->codeAppendf("%s = %s * %s + (vec4(1.0) - %s) * %s;",
570 outColor, srcCoverage, outColor, srcCoverag e, dstColor);
571 }
557 } 572 }
558 573
559 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {} 574 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {}
560 575
561 typedef GrGLSLXferProcessor INHERITED; 576 typedef GrGLSLXferProcessor INHERITED;
562 }; 577 };
563 578
564 /////////////////////////////////////////////////////////////////////////////// 579 ///////////////////////////////////////////////////////////////////////////////
565 580
566 void ShaderPDXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&, 581 void ShaderPDXferProcessor::onGetGLSLProcessorKey(const GrGLSLCaps&,
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 911 }
897 return get_lcd_blend_formula(optimizations.fCoveragePOI, 912 return get_lcd_blend_formula(optimizations.fCoveragePOI,
898 SkXfermode::kSrcOver_Mode).hasSecondaryOutp ut(); 913 SkXfermode::kSrcOver_Mode).hasSecondaryOutp ut();
899 } 914 }
900 // We fallback on the shader XP when the blend formula would use dual source blending but we 915 // We fallback on the shader XP when the blend formula would use dual source blending but we
901 // don't have support for it. 916 // don't have support for it.
902 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI , 917 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI ,
903 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco ndaryOutput(); 918 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco ndaryOutput();
904 } 919 }
905 920
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCustomXfermode.cpp ('k') | src/gpu/glsl/GrGLSLBlend.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698