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" |
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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 const ShaderPDXferProcessor& xp = processor.cast<ShaderPDXferProcessor>(
); | 495 const ShaderPDXferProcessor& xp = processor.cast<ShaderPDXferProcessor>(
); |
496 b->add32(xp.getXfermode()); | 496 b->add32(xp.getXfermode()); |
497 } | 497 } |
498 | 498 |
499 private: | 499 private: |
500 void emitBlendCodeForDstRead(GrGLXPBuilder* pb, const char* srcColor, const
char* dstColor, | 500 void emitBlendCodeForDstRead(GrGLXPBuilder* pb, const char* srcColor, const
char* dstColor, |
501 const char* outColor, const GrXferProcessor& pr
oc) override { | 501 const char* outColor, const GrXferProcessor& pr
oc) override { |
502 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>(); | 502 const ShaderPDXferProcessor& xp = proc.cast<ShaderPDXferProcessor>(); |
503 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); | 503 GrGLXPFragmentBuilder* fsBuilder = pb->getFragmentShaderBuilder(); |
504 | 504 |
505 GrGLBlend::AppendPorterDuffBlend(fsBuilder, srcColor, dstColor, outColor
, xp.getXfermode()); | 505 GrGLSLBlend::AppendMode(fsBuilder, srcColor, dstColor, outColor, xp.getX
fermode()); |
506 } | 506 } |
507 | 507 |
508 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {} | 508 void onSetData(const GrGLProgramDataManager&, const GrXferProcessor&) overri
de {} |
509 | 509 |
510 typedef GrGLXferProcessor INHERITED; | 510 typedef GrGLXferProcessor INHERITED; |
511 }; | 511 }; |
512 | 512 |
513 /////////////////////////////////////////////////////////////////////////////// | 513 /////////////////////////////////////////////////////////////////////////////// |
514 | 514 |
515 void ShaderPDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&, | 515 void ShaderPDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps&, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 GrXferProcessor* PDLCDXferProcessor::Create(SkXfermode::Mode xfermode, | 600 GrXferProcessor* PDLCDXferProcessor::Create(SkXfermode::Mode xfermode, |
601 const GrProcOptInfo& colorPOI) { | 601 const GrProcOptInfo& colorPOI) { |
602 if (SkXfermode::kSrcOver_Mode != xfermode) { | 602 if (SkXfermode::kSrcOver_Mode != xfermode) { |
603 return nullptr; | 603 return nullptr; |
604 } | 604 } |
605 | 605 |
606 if (kRGBA_GrColorComponentFlags != colorPOI.validFlags()) { | 606 if (kRGBA_GrColorComponentFlags != colorPOI.validFlags()) { |
607 return nullptr; | 607 return nullptr; |
608 } | 608 } |
609 | 609 |
610 GrColor blendConstant = GrUnPreMulColor(colorPOI.color()); | 610 GrColor blendConstant = GrUnpremulColor(colorPOI.color()); |
611 uint8_t alpha = GrColorUnpackA(blendConstant); | 611 uint8_t alpha = GrColorUnpackA(blendConstant); |
612 blendConstant |= (0xff << GrColor_SHIFT_A); | 612 blendConstant |= (0xff << GrColor_SHIFT_A); |
613 | 613 |
614 return new PDLCDXferProcessor(blendConstant, alpha); | 614 return new PDLCDXferProcessor(blendConstant, alpha); |
615 } | 615 } |
616 | 616 |
617 PDLCDXferProcessor::~PDLCDXferProcessor() { | 617 PDLCDXferProcessor::~PDLCDXferProcessor() { |
618 } | 618 } |
619 | 619 |
620 void PDLCDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps, | 620 void PDLCDXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 int* outPrimary, | 764 int* outPrimary, |
765 int* outSecondary) { | 765 int* outSecondary) { |
766 if (!!strcmp(xp->name(), "Porter Duff")) { | 766 if (!!strcmp(xp->name(), "Porter Duff")) { |
767 *outPrimary = *outSecondary = -1; | 767 *outPrimary = *outSecondary = -1; |
768 return; | 768 return; |
769 } | 769 } |
770 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); | 770 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)-
>getBlendFormula(); |
771 *outPrimary = blendFormula.fPrimaryOutputType; | 771 *outPrimary = blendFormula.fPrimaryOutputType; |
772 *outSecondary = blendFormula.fSecondaryOutputType; | 772 *outSecondary = blendFormula.fSecondaryOutputType; |
773 } | 773 } |
OLD | NEW |