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

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

Issue 1334293003: Create fragment processor for performing input color blend with child processor (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix Created 5 years, 3 months 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/GrCustomXfermodePriv.h ('k') | src/gpu/effects/GrSimpleTextureEffect.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"
11 #include "GrCaps.h" 11 #include "GrCaps.h"
12 #include "GrProcessor.h" 12 #include "GrProcessor.h"
13 #include "GrProcOptInfo.h" 13 #include "GrProcOptInfo.h"
14 #include "GrTypes.h" 14 #include "GrTypes.h"
15 #include "GrXferProcessor.h" 15 #include "GrXferProcessor.h"
16 #include "gl/GrGLBlend.h" 16 #include "gl/GrGLSLBlend.h"
17 #include "gl/GrGLXferProcessor.h" 17 #include "gl/GrGLXferProcessor.h"
18 #include "gl/builders/GrGLFragmentShaderBuilder.h" 18 #include "gl/builders/GrGLFragmentShaderBuilder.h"
19 #include "gl/builders/GrGLProgramBuilder.h" 19 #include "gl/builders/GrGLProgramBuilder.h"
20 20
21 /** 21 /**
22 * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage. 22 * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage.
23 */ 23 */
24 struct BlendFormula { 24 struct BlendFormula {
25 public: 25 public:
26 /** 26 /**
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 const ShaderPDXferProcessor& xp = processor.cast<ShaderPDXferProcessor>( ); 540 const ShaderPDXferProcessor& xp = processor.cast<ShaderPDXferProcessor>( );
541 b->add32(xp.getXfermode()); 541 b->add32(xp.getXfermode());
542 } 542 }
543 543
544 private: 544 private:
545 void emitBlendCodeForDstRead(GrGLXPBuilder* pb, const char* srcColor, const char* dstColor, 545 void emitBlendCodeForDstRead(GrGLXPBuilder* pb, const char* srcColor, const char* dstColor,
546 const char* outColor, const GrXferProcessor& pr oc) override { 546 const char* outColor, const GrXferProcessor& pr oc) override {
547 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>(); 547 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>();
548 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); 548 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
549 549
550 GrGLBlend::AppendPorterDuffBlend(fsBuilder, srcColor, dstColor, outColor , xp.getXfermode()); 550 GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.getX fermode());
551 } 551 }
552 552
553 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {} 553 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {}
554 554
555 typedef GrGLXferProcessor INHERITED; 555 typedef GrGLXferProcessor INHERITED;
556 }; 556 };
557 557
558 /////////////////////////////////////////////////////////////////////////////// 558 ///////////////////////////////////////////////////////////////////////////////
559 559
560 void ShaderPDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&, 560 void ShaderPDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 GrXferProcessor* PDLCDXferProcessor::Create(SkXfermode::Mode xfermode, 644 GrXferProcessor* PDLCDXferProcessor::Create(SkXfermode::Mode xfermode,
645 const GrProcOptInfo& colorPOI) { 645 const GrProcOptInfo& colorPOI) {
646 if (SkXfermode::kSrcOver_Mode != xfermode) { 646 if (SkXfermode::kSrcOver_Mode != xfermode) {
647 return nullptr; 647 return nullptr;
648 } 648 }
649 649
650 if (kRGBA_GrColorComponentFlags != colorPOI.validFlags()) { 650 if (kRGBA_GrColorComponentFlags != colorPOI.validFlags()) {
651 return nullptr; 651 return nullptr;
652 } 652 }
653 653
654 GrColor blendConstant = GrUnPreMulColor(colorPOI.color()); 654 GrColor blendConstant = GrUnpremulColor(colorPOI.color());
655 uint8_t alpha = GrColorUnpackA(blendConstant); 655 uint8_t alpha = GrColorUnpackA(blendConstant);
656 blendConstant |= (0xff << GrColor_SHIFT_A); 656 blendConstant |= (0xff << GrColor_SHIFT_A);
657 657
658 return new PDLCDXferProcessor(blendConstant, alpha); 658 return new PDLCDXferProcessor(blendConstant, alpha);
659 } 659 }
660 660
661 PDLCDXferProcessor::~PDLCDXferProcessor() { 661 PDLCDXferProcessor::~PDLCDXferProcessor() {
662 } 662 }
663 663
664 void PDLCDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps, 664 void PDLCDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps,
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 int* outPrimary, 813 int* outPrimary,
814 int* outSecondary) { 814 int* outSecondary) {
815 if (!!strcmp(xp->name(), "Porter Duff")) { 815 if (!!strcmp(xp->name(), "Porter Duff")) {
816 *outPrimary = *outSecondary = -1; 816 *outPrimary = *outSecondary = -1;
817 return; 817 return;
818 } 818 }
819 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula(); 819 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula();
820 *outPrimary = blendFormula.fPrimaryOutputType; 820 *outPrimary = blendFormula.fPrimaryOutputType;
821 *outSecondary = blendFormula.fSecondaryOutputType; 821 *outSecondary = blendFormula.fSecondaryOutputType;
822 } 822 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrCustomXfermodePriv.h ('k') | src/gpu/effects/GrSimpleTextureEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698