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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, | 87 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
88 const GrProcOptInfo& coveragePOI, | 88 const GrProcOptInfo& coveragePOI, |
89 bool doesStencilWrite, | 89 bool doesStencilWrite, |
90 GrColor* overrideColor, | 90 GrColor* overrideColor, |
91 const GrDrawTargetCaps& caps) ove
rride; | 91 const GrDrawTargetCaps& caps) ove
rride; |
92 | 92 |
93 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { | 93 GrBlendCoeff getSrcBlend() const { return fSrcBlend; } |
| 94 GrBlendCoeff getDstBlend() const { return fDstBlend; } |
| 95 |
| 96 private: |
| 97 PorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrColo
r constant, |
| 98 const GrDeviceCoordTexture* dstCopy, bool willReadDs
tColor); |
| 99 |
| 100 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st override; |
| 101 |
| 102 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override { |
94 if (!this->willReadDstColor()) { | 103 if (!this->willReadDstColor()) { |
95 blendInfo->fSrcBlend = fSrcBlend; | 104 blendInfo->fSrcBlend = fSrcBlend; |
96 blendInfo->fDstBlend = fDstBlend; | 105 blendInfo->fDstBlend = fDstBlend; |
97 } else { | 106 } else { |
98 blendInfo->fSrcBlend = kOne_GrBlendCoeff; | 107 blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
99 blendInfo->fDstBlend = kZero_GrBlendCoeff; | 108 blendInfo->fDstBlend = kZero_GrBlendCoeff; |
100 } | 109 } |
101 blendInfo->fBlendConstant = fBlendConstant; | 110 blendInfo->fBlendConstant = fBlendConstant; |
102 } | 111 } |
103 | 112 |
104 GrBlendCoeff getSrcBlend() const { return fSrcBlend; } | |
105 GrBlendCoeff getDstBlend() const { return fDstBlend; } | |
106 | |
107 private: | |
108 PorterDuffXferProcessor(GrBlendCoeff srcBlend, GrBlendCoeff dstBlend, GrColo
r constant, | |
109 const GrDeviceCoordTexture* dstCopy, bool willReadDs
tColor); | |
110 | |
111 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st override; | |
112 | |
113 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 113 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
114 const PorterDuffXferProcessor& xp = xpBase.cast<PorterDuffXferProcessor>
(); | 114 const PorterDuffXferProcessor& xp = xpBase.cast<PorterDuffXferProcessor>
(); |
115 if (fSrcBlend != xp.fSrcBlend || | 115 if (fSrcBlend != xp.fSrcBlend || |
116 fDstBlend != xp.fDstBlend || | 116 fDstBlend != xp.fDstBlend || |
117 fBlendConstant != xp.fBlendConstant || | 117 fBlendConstant != xp.fBlendConstant || |
118 fPrimaryOutputType != xp.fPrimaryOutputType || | 118 fPrimaryOutputType != xp.fPrimaryOutputType || |
119 fSecondaryOutputType != xp.fSecondaryOutputType) { | 119 fSecondaryOutputType != xp.fSecondaryOutputType) { |
120 return false; | 120 return false; |
121 } | 121 } |
122 return true; | 122 return true; |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 700 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |
701 | 701 |
702 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, | 702 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, |
703 GrContext*, | 703 GrContext*, |
704 const GrDrawTargetCaps&, | 704 const GrDrawTargetCaps&, |
705 GrTexture*[]) { | 705 GrTexture*[]) { |
706 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); | 706 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); |
707 return GrPorterDuffXPFactory::Create(mode); | 707 return GrPorterDuffXPFactory::Create(mode); |
708 } | 708 } |
709 | 709 |
OLD | NEW |