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

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

Issue 1428543003: Create GLSL base class for ProgramDataManager (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add space Created 5 years, 1 month 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/GrOvalEffect.cpp ('k') | src/gpu/effects/GrRRectEffect.cpp » ('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/GrGLSLBlend.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 #include "glsl/GrGLSLProgramDataManager.h"
20 21
21 /** 22 /**
22 * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage. 23 * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage.
23 */ 24 */
24 struct BlendFormula { 25 struct BlendFormula {
25 public: 26 public:
26 /** 27 /**
27 * Values the shader can write to primary and secondary outputs. These must all be modulated by 28 * Values the shader can write to primary and secondary outputs. These must all be modulated by
28 * coverage to support mixed samples. The XP will ignore the multiplies when not using coverage. 29 * coverage to support mixed samples. The XP will ignore the multiplies when not using coverage.
29 */ 30 */
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 444
444 BlendFormula blendFormula = xp.getBlendFormula(); 445 BlendFormula blendFormula = xp.getBlendFormula();
445 if (blendFormula.hasSecondaryOutput()) { 446 if (blendFormula.hasSecondaryOutput()) {
446 append_color_output(xp, fsBuilder, blendFormula.fSecondaryOutputType , 447 append_color_output(xp, fsBuilder, blendFormula.fSecondaryOutputType ,
447 args.fOutputSecondary, args.fInputColor, args.fI nputCoverage); 448 args.fOutputSecondary, args.fInputColor, args.fI nputCoverage);
448 } 449 }
449 append_color_output(xp, fsBuilder, blendFormula.fPrimaryOutputType, 450 append_color_output(xp, fsBuilder, blendFormula.fPrimaryOutputType,
450 args.fOutputPrimary, args.fInputColor, args.fInputCo verage); 451 args.fOutputPrimary, args.fInputColor, args.fInputCo verage);
451 } 452 }
452 453
453 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {} 454 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {}
454 455
455 typedef GrGLXferProcessor INHERITED; 456 typedef GrGLXferProcessor INHERITED;
456 }; 457 };
457 458
458 /////////////////////////////////////////////////////////////////////////////// 459 ///////////////////////////////////////////////////////////////////////////////
459 460
460 void PorterDuffXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&, 461 void PorterDuffXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&,
461 GrProcessorKeyBuilder* b) cons t { 462 GrProcessorKeyBuilder* b) cons t {
462 GLPorterDuffXferProcessor::GenKey(*this, b); 463 GLPorterDuffXferProcessor::GenKey(*this, b);
463 } 464 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 544
544 private: 545 private:
545 void emitBlendCodeForDstRead(GrGLXPBuilder* pb, const char* srcColor, const char* dstColor, 546 void emitBlendCodeForDstRead(GrGLXPBuilder* pb, const char* srcColor, const char* dstColor,
546 const char* outColor, const GrXferProcessor& pr oc) override { 547 const char* outColor, const GrXferProcessor& pr oc) override {
547 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>(); 548 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>();
548 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); 549 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder();
549 550
550 GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.getX fermode()); 551 GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.getX fermode());
551 } 552 }
552 553
553 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {} 554 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {}
554 555
555 typedef GrGLXferProcessor INHERITED; 556 typedef GrGLXferProcessor INHERITED;
556 }; 557 };
557 558
558 /////////////////////////////////////////////////////////////////////////////// 559 ///////////////////////////////////////////////////////////////////////////////
559 560
560 void ShaderPDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&, 561 void ShaderPDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&,
561 GrProcessorKeyBuilder* b) cons t { 562 GrProcessorKeyBuilder* b) cons t {
562 GLShaderPDXferProcessor::GenKey(*this, b); 563 GLShaderPDXferProcessor::GenKey(*this, b);
563 } 564 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps, 622 static void GenKey(const GrProcessor& processor, const GrGLSLCaps& caps,
622 GrProcessorKeyBuilder* b) {} 623 GrProcessorKeyBuilder* b) {}
623 624
624 private: 625 private:
625 void emitOutputsForBlendState(const EmitArgs& args) override { 626 void emitOutputsForBlendState(const EmitArgs& args) override {
626 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); 627 GrGLXPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder();
627 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, args.fInput Color, 628 fsBuilder->codeAppendf("%s = %s * %s;", args.fOutputPrimary, args.fInput Color,
628 args.fInputCoverage); 629 args.fInputCoverage);
629 } 630 }
630 631
631 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri de {}; 632 void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) over ride {};
632 633
633 typedef GrGLXferProcessor INHERITED; 634 typedef GrGLXferProcessor INHERITED;
634 }; 635 };
635 636
636 /////////////////////////////////////////////////////////////////////////////// 637 ///////////////////////////////////////////////////////////////////////////////
637 638
638 PDLCDXferProcessor::PDLCDXferProcessor(GrColor blendConstant, uint8_t alpha) 639 PDLCDXferProcessor::PDLCDXferProcessor(GrColor blendConstant, uint8_t alpha)
639 : fBlendConstant(blendConstant) 640 : fBlendConstant(blendConstant)
640 , fAlpha(alpha) { 641 , fAlpha(alpha) {
641 this->initClassID<PDLCDXferProcessor>(); 642 this->initClassID<PDLCDXferProcessor>();
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 int* outPrimary, 819 int* outPrimary,
819 int* outSecondary) { 820 int* outSecondary) {
820 if (!!strcmp(xp->name(), "Porter Duff")) { 821 if (!!strcmp(xp->name(), "Porter Duff")) {
821 *outPrimary = *outSecondary = -1; 822 *outPrimary = *outSecondary = -1;
822 return; 823 return;
823 } 824 }
824 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula(); 825 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula();
825 *outPrimary = blendFormula.fPrimaryOutputType; 826 *outPrimary = blendFormula.fPrimaryOutputType;
826 *outSecondary = blendFormula.fSecondaryOutputType; 827 *outSecondary = blendFormula.fSecondaryOutputType;
827 } 828 }
OLDNEW
« no previous file with comments | « src/gpu/effects/GrOvalEffect.cpp ('k') | src/gpu/effects/GrRRectEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698