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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Writes coverage * (1 - colorRGBA) as the secondary output. Only set i
f dual source | 77 // Writes coverage * (1 - colorRGBA) as the secondary output. Only set i
f dual source |
78 // blending is supported and primary output is kModulate. | 78 // blending is supported and primary output is kModulate. |
79 kCoverageISC_SecondaryOutputType, | 79 kCoverageISC_SecondaryOutputType, |
80 | 80 |
81 kSecondaryOutputTypeCnt, | 81 kSecondaryOutputTypeCnt, |
82 }; | 82 }; |
83 | 83 |
84 PrimaryOutputType primaryOutputType() const { return fPrimaryOutputType; } | 84 PrimaryOutputType primaryOutputType() const { return fPrimaryOutputType; } |
85 SecondaryOutputType secondaryOutputType() const { return fSecondaryOutputTyp
e; } | 85 SecondaryOutputType secondaryOutputType() const { return fSecondaryOutputTyp
e; } |
86 | 86 |
87 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | |
88 const GrProcOptInfo& coveragePOI, | |
89 bool doesStencilWrite, | |
90 GrColor* overrideColor, | |
91 const GrDrawTargetCaps& caps) ove
rride; | |
92 | |
93 GrBlendCoeff getSrcBlend() const { return fSrcBlend; } | 87 GrBlendCoeff getSrcBlend() const { return fSrcBlend; } |
94 GrBlendCoeff getDstBlend() const { return fDstBlend; } | 88 GrBlendCoeff getDstBlend() const { return fDstBlend; } |
95 | 89 |
96 private: | 90 private: |
97 PorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrColo
r constant, | 91 PorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrColo
r constant, |
98 const GrDeviceCoordTexture* dstCopy, bool willReadDs
tColor); | 92 const GrDeviceCoordTexture* dstCopy, bool willReadDs
tColor); |
99 | 93 |
| 94 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
| 95 const GrProcOptInfo& coveragePO
I, |
| 96 bool doesStencilWrite, |
| 97 GrColor* overrideColor, |
| 98 const GrDrawTargetCaps& caps) o
verride; |
| 99 |
100 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | 100 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
101 | 101 |
102 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { | 102 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { |
103 if (!this->willReadDstColor()) { | 103 if (!this->willReadDstColor()) { |
104 blendInfo->fSrcBlend = fSrcBlend; | 104 blendInfo->fSrcBlend = fSrcBlend; |
105 blendInfo->fDstBlend = fDstBlend; | 105 blendInfo->fDstBlend = fDstBlend; |
106 } else { | 106 } else { |
107 blendInfo->fSrcBlend = kOne_GrBlendCoeff; | 107 blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
108 blendInfo->fDstBlend = kZero_GrBlendCoeff; | 108 blendInfo->fDstBlend = kZero_GrBlendCoeff; |
109 } | 109 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 void PorterDuffXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps, | 294 void PorterDuffXferProcessor::onGetGLProcessorKey(const GrGLSLCaps& caps, |
295 GrProcessorKeyBuilder* b) cons
t { | 295 GrProcessorKeyBuilder* b) cons
t { |
296 GLPorterDuffXferProcessor::GenKey(*this, caps, b); | 296 GLPorterDuffXferProcessor::GenKey(*this, caps, b); |
297 } | 297 } |
298 | 298 |
299 GrGLXferProcessor* PorterDuffXferProcessor::createGLInstance() const { | 299 GrGLXferProcessor* PorterDuffXferProcessor::createGLInstance() const { |
300 return SkNEW_ARGS(GLPorterDuffXferProcessor, (*this)); | 300 return SkNEW_ARGS(GLPorterDuffXferProcessor, (*this)); |
301 } | 301 } |
302 | 302 |
303 GrXferProcessor::OptFlags | 303 GrXferProcessor::OptFlags |
304 PorterDuffXferProcessor::getOptimizations(const GrProcOptInfo& colorPOI, | 304 PorterDuffXferProcessor::onGetOptimizations(const GrProcOptInfo& colorPOI, |
305 const GrProcOptInfo& coveragePOI, | 305 const GrProcOptInfo& coveragePOI, |
306 bool doesStencilWrite, | 306 bool doesStencilWrite, |
307 GrColor* overrideColor, | 307 GrColor* overrideColor, |
308 const GrDrawTargetCaps& caps) { | 308 const GrDrawTargetCaps& caps) { |
309 GrXferProcessor::OptFlags optFlags; | 309 GrXferProcessor::OptFlags optFlags; |
310 // Optimizations when doing RGB Coverage | 310 // Optimizations when doing RGB Coverage |
311 if (coveragePOI.isFourChannelOutput()) { | 311 if (coveragePOI.isFourChannelOutput()) { |
312 // We want to force our primary output to be alpha * Coverage, where alp
ha is the alpha | 312 // We want to force our primary output to be alpha * Coverage, where alp
ha is the alpha |
313 // value of the blend the constant. We should already have valid blend c
oeff's if we are at | 313 // value of the blend the constant. We should already have valid blend c
oeff's if we are at |
314 // a point where we have RGB coverage. We don't need any color stages si
nce the known color | 314 // a point where we have RGB coverage. We don't need any color stages si
nce the known color |
315 // output is already baked into the blendConstant. | 315 // output is already baked into the blendConstant. |
316 uint8_t alpha = GrColorUnpackA(fBlendConstant); | 316 uint8_t alpha = GrColorUnpackA(fBlendConstant); |
317 *overrideColor = GrColorPackRGBA(alpha, alpha, alpha, alpha); | 317 *overrideColor = GrColorPackRGBA(alpha, alpha, alpha, alpha); |
318 optFlags = GrXferProcessor::kOverrideColor_OptFlag; | 318 optFlags = GrXferProcessor::kOverrideColor_OptFlag; |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 698 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |
699 | 699 |
700 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, | 700 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, |
701 GrContext*, | 701 GrContext*, |
702 const GrDrawTargetCaps&, | 702 const GrDrawTargetCaps&, |
703 GrTexture*[]) { | 703 GrTexture*[]) { |
704 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); | 704 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); |
705 return GrPorterDuffXPFactory::Create(mode); | 705 return GrPorterDuffXPFactory::Create(mode); |
706 } | 706 } |
707 | 707 |
OLD | NEW |