| 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 20 matching lines...) Expand all Loading... |
| 31 kISA_GrBlendCoeff == dstCoeff || | 31 kISA_GrBlendCoeff == dstCoeff || |
| 32 kISC_GrBlendCoeff == dstCoeff; | 32 kISC_GrBlendCoeff == dstCoeff; |
| 33 } | 33 } |
| 34 | 34 |
| 35 class GrGLPorterDuffXferProcessor : public GrGLXferProcessor { | 35 class GrGLPorterDuffXferProcessor : public GrGLXferProcessor { |
| 36 public: | 36 public: |
| 37 GrGLPorterDuffXferProcessor(const GrProcessor&) {} | 37 GrGLPorterDuffXferProcessor(const GrProcessor&) {} |
| 38 | 38 |
| 39 virtual ~GrGLPorterDuffXferProcessor() {} | 39 virtual ~GrGLPorterDuffXferProcessor() {} |
| 40 | 40 |
| 41 virtual void emitCode(const EmitArgs& args) SK_OVERRIDE { | 41 void emitCode(const EmitArgs& args) SK_OVERRIDE { |
| 42 const GrPorterDuffXferProcessor& xp = args.fXP.cast<GrPorterDuffXferProc
essor>(); | 42 const GrPorterDuffXferProcessor& xp = args.fXP.cast<GrPorterDuffXferProc
essor>(); |
| 43 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 43 GrGLFPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 44 if (xp.hasSecondaryOutput()) { | 44 if (xp.hasSecondaryOutput()) { |
| 45 switch(xp.secondaryOutputType()) { | 45 switch(xp.secondaryOutputType()) { |
| 46 case GrPorterDuffXferProcessor::kCoverage_SecondaryOutputType: | 46 case GrPorterDuffXferProcessor::kCoverage_SecondaryOutputType: |
| 47 fsBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, ar
gs.fInputCoverage); | 47 fsBuilder->codeAppendf("%s = %s;", args.fOutputSecondary, ar
gs.fInputCoverage); |
| 48 break; | 48 break; |
| 49 case GrPorterDuffXferProcessor::kCoverageISA_SecondaryOutputType
: | 49 case GrPorterDuffXferProcessor::kCoverageISA_SecondaryOutputType
: |
| 50 fsBuilder->codeAppendf("%s = (1.0 - %s.a) * %s;", | 50 fsBuilder->codeAppendf("%s = (1.0 - %s.a) * %s;", |
| 51 args.fOutputSecondary, args.fInputCol
or, | 51 args.fOutputSecondary, args.fInputCol
or, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 xp.primaryOutputType()){ | 79 xp.primaryOutputType()){ |
| 80 fsBuilder->codeAppendf("%s += (vec4(1.0) - %s) * %s;", args.
fOutputPrimary, | 80 fsBuilder->codeAppendf("%s += (vec4(1.0) - %s) * %s;", args.
fOutputPrimary, |
| 81 args.fInputCoverage, fsBuilder->dstCo
lor()); | 81 args.fInputCoverage, fsBuilder->dstCo
lor()); |
| 82 } | 82 } |
| 83 break; | 83 break; |
| 84 default: | 84 default: |
| 85 SkFAIL("Unexpected Primary Output"); | 85 SkFAIL("Unexpected Primary Output"); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 virtual void setData(const GrGLProgramDataManager&, const GrXferProcessor&)
SK_OVERRIDE {}; | 89 void setData(const GrGLProgramDataManager&, const GrXferProcessor&) SK_OVERR
IDE {}; |
| 90 | 90 |
| 91 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, | 91 static void GenKey(const GrProcessor& processor, const GrGLCaps& caps, |
| 92 GrProcessorKeyBuilder* b) { | 92 GrProcessorKeyBuilder* b) { |
| 93 const GrPorterDuffXferProcessor& xp = processor.cast<GrPorterDuffXferPro
cessor>(); | 93 const GrPorterDuffXferProcessor& xp = processor.cast<GrPorterDuffXferPro
cessor>(); |
| 94 b->add32(xp.primaryOutputType()); | 94 b->add32(xp.primaryOutputType()); |
| 95 b->add32(xp.secondaryOutputType()); | 95 b->add32(xp.secondaryOutputType()); |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 typedef GrGLXferProcessor INHERITED; | 99 typedef GrGLXferProcessor INHERITED; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 } while (GrBlendCoeffRefsSrc(src)); | 525 } while (GrBlendCoeffRefsSrc(src)); |
| 526 | 526 |
| 527 GrBlendCoeff dst; | 527 GrBlendCoeff dst; |
| 528 do { | 528 do { |
| 529 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
licGrBlendCoeff)); | 529 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
licGrBlendCoeff)); |
| 530 } while (GrBlendCoeffRefsDst(dst)); | 530 } while (GrBlendCoeffRefsDst(dst)); |
| 531 | 531 |
| 532 return GrPorterDuffXPFactory::Create(src, dst); | 532 return GrPorterDuffXPFactory::Create(src, dst); |
| 533 } | 533 } |
| 534 | 534 |
| OLD | NEW |