| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrPaint.h" | 9 #include "GrPaint.h" |
| 10 | 10 |
| 11 #include "GrBlend.h" | 11 #include "GrBlend.h" |
| 12 #include "effects/GrSimpleTextureEffect.h" | 12 #include "effects/GrSimpleTextureEffect.h" |
| 13 | 13 |
| 14 void GrPaint::addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix)
{ | 14 void GrPaint::addColorTextureProcessor(GrTexture* texture, const SkMatrix& matri
x) { |
| 15 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix))->unref(
); | 15 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unr
ef(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 void GrPaint::addCoverageTextureEffect(GrTexture* texture, const SkMatrix& matri
x) { | 18 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& ma
trix) { |
| 19 this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix))->unr
ef(); | 19 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->
unref(); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void GrPaint::addColorTextureEffect(GrTexture* texture, | 22 void GrPaint::addColorTextureProcessor(GrTexture* texture, |
| 23 const SkMatrix& matrix, | 23 const SkMatrix& matrix, |
| 24 const GrTextureParams& params) { | 24 const GrTextureParams& params) { |
| 25 this->addColorEffect(GrSimpleTextureEffect::Create(texture, matrix, params))
->unref(); | 25 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, param
s))->unref(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void GrPaint::addCoverageTextureEffect(GrTexture* texture, | 28 void GrPaint::addCoverageTextureProcessor(GrTexture* texture, |
| 29 const SkMatrix& matrix, | 29 const SkMatrix& matrix, |
| 30 const GrTextureParams& params) { | 30 const GrTextureParams& params) { |
| 31 this->addCoverageEffect(GrSimpleTextureEffect::Create(texture, matrix, param
s))->unref(); | 31 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, pa
rams))->unref(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 bool GrPaint::isOpaque() const { | 34 bool GrPaint::isOpaque() const { |
| 35 return this->getOpaqueAndKnownColor(NULL, NULL); | 35 return this->getOpaqueAndKnownColor(NULL, NULL); |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const { | 38 bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const { |
| 39 GrColor tempColor; | 39 GrColor tempColor; |
| 40 uint32_t colorComps; | 40 uint32_t colorComps; |
| 41 if (this->getOpaqueAndKnownColor(&tempColor, &colorComps)) { | 41 if (this->getOpaqueAndKnownColor(&tempColor, &colorComps)) { |
| 42 if (kRGBA_GrColorComponentFlags == colorComps) { | 42 if (kRGBA_GrColorComponentFlags == colorComps) { |
| 43 *color = tempColor; | 43 *color = tempColor; |
| 44 return true; | 44 return true; |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, | 50 bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor, |
| 51 uint32_t* solidColorKnownComponents) const
{ | 51 uint32_t* solidColorKnownComponents) const
{ |
| 52 | 52 |
| 53 // TODO: Share this implementation with GrDrawState | 53 // TODO: Share this implementation with GrDrawState |
| 54 | 54 |
| 55 GrColor coverage = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverag
e); | 55 GrColor coverage = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverag
e); |
| 56 uint32_t coverageComps = kRGBA_GrColorComponentFlags; | 56 uint32_t coverageComps = kRGBA_GrColorComponentFlags; |
| 57 int count = fCoverageStages.count(); | 57 int count = fCoverageStages.count(); |
| 58 for (int i = 0; i < count; ++i) { | 58 for (int i = 0; i < count; ++i) { |
| 59 fCoverageStages[i].getEffect()->getConstantColorComponents(&coverage, &c
overageComps); | 59 fCoverageStages[i].getProcessor()->getConstantColorComponents(&coverage,
&coverageComps); |
| 60 } | 60 } |
| 61 if (kRGBA_GrColorComponentFlags != coverageComps || 0xffffffff != coverage)
{ | 61 if (kRGBA_GrColorComponentFlags != coverageComps || 0xffffffff != coverage)
{ |
| 62 return false; | 62 return false; |
| 63 } | 63 } |
| 64 | 64 |
| 65 GrColor color = fColor; | 65 GrColor color = fColor; |
| 66 uint32_t colorComps = kRGBA_GrColorComponentFlags; | 66 uint32_t colorComps = kRGBA_GrColorComponentFlags; |
| 67 count = fColorStages.count(); | 67 count = fColorStages.count(); |
| 68 for (int i = 0; i < count; ++i) { | 68 for (int i = 0; i < count; ++i) { |
| 69 fColorStages[i].getEffect()->getConstantColorComponents(&color, &colorCo
mps); | 69 fColorStages[i].getProcessor()->getConstantColorComponents(&color, &colo
rComps); |
| 70 } | 70 } |
| 71 | 71 |
| 72 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents)); | 72 SkASSERT((NULL == solidColor) == (NULL == solidColorKnownComponents)); |
| 73 | 73 |
| 74 GrBlendCoeff srcCoeff = fSrcBlendCoeff; | 74 GrBlendCoeff srcCoeff = fSrcBlendCoeff; |
| 75 GrBlendCoeff dstCoeff = fDstBlendCoeff; | 75 GrBlendCoeff dstCoeff = fDstBlendCoeff; |
| 76 GrSimplifyBlend(&srcCoeff, &dstCoeff, color, colorComps, 0, 0, 0); | 76 GrSimplifyBlend(&srcCoeff, &dstCoeff, color, colorComps, 0, 0, 0); |
| 77 | 77 |
| 78 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef
f); | 78 bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoef
f); |
| 79 if (solidColor) { | 79 if (solidColor) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 110 case kIConstA_GrBlendCoeff: | 110 case kIConstA_GrBlendCoeff: |
| 111 *solidColorKnownComponents = 0; | 111 *solidColorKnownComponents = 0; |
| 112 break; | 112 break; |
| 113 } | 113 } |
| 114 } else { | 114 } else { |
| 115 solidColorKnownComponents = 0; | 115 solidColorKnownComponents = 0; |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 return opaque; | 118 return opaque; |
| 119 } | 119 } |
| OLD | NEW |