| Index: src/gpu/GrPaint.cpp
 | 
| diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp
 | 
| index d67f2e8707124d034003a7a170826c26e48a685a..898a32ff70f53ac2e4aaf9f9537eb214d1aebecf 100644
 | 
| --- a/src/gpu/GrPaint.cpp
 | 
| +++ b/src/gpu/GrPaint.cpp
 | 
| @@ -8,6 +8,7 @@
 | 
|  
 | 
|  #include "GrPaint.h"
 | 
|  
 | 
| +#include "GrBlend.h"
 | 
|  #include "effects/GrSimpleTextureEffect.h"
 | 
|  
 | 
|  void GrPaint::addColorTextureEffect(GrTexture* texture, const SkMatrix& matrix) {
 | 
| @@ -33,3 +34,96 @@ void GrPaint::addCoverageTextureEffect(GrTexture* texture,
 | 
|      GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params);
 | 
|      this->addCoverageEffect(effect)->unref();
 | 
|  }
 | 
| +
 | 
| +bool GrPaint::isOpaque() const {
 | 
| +    return this->getOpaqueAndKnownColor(NULL, NULL);
 | 
| +}
 | 
| +
 | 
| +bool GrPaint::isOpaqueAndConstantColor(GrColor* color) const {
 | 
| +    GrColor tempColor;
 | 
| +    uint32_t colorComps;
 | 
| +    if (this->getOpaqueAndKnownColor(&tempColor, &colorComps)) {
 | 
| +        if (kRGBA_GrColorComponentFlags == colorComps) {
 | 
| +            *color = tempColor;
 | 
| +            return true;
 | 
| +        }
 | 
| +    }
 | 
| +    return false;
 | 
| +}
 | 
| +
 | 
| +bool GrPaint::getOpaqueAndKnownColor(GrColor* solidColor,
 | 
| +                                     uint32_t* solidColorKnownComponents) const {
 | 
| +
 | 
| +    // TODO: Share this implementation with GrDrawState
 | 
| +
 | 
| +    // Since fColorFilterXfermode is going away soon, we aren't attempting to handle anything but
 | 
| +    // the default setting.
 | 
| +    if (SkXfermode::kDst_Mode != fColorFilterXfermode) {
 | 
| +        return false;
 | 
| +    }
 | 
| +
 | 
| +    GrColor coverage = GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage);
 | 
| +    uint32_t coverageComps = kRGBA_GrColorComponentFlags;
 | 
| +    int count = fCoverageStages.count();
 | 
| +    for (int i = 0; i < count; ++i) {
 | 
| +        (*fCoverageStages[i].getEffect())->getConstantColorComponents(&coverage, &coverageComps);
 | 
| +    }
 | 
| +    if (kRGBA_GrColorComponentFlags != coverageComps || 0xffffffff != coverage) {
 | 
| +        return false;
 | 
| +    }
 | 
| +
 | 
| +    GrColor color = fColor;
 | 
| +    uint32_t colorComps = kRGBA_GrColorComponentFlags;
 | 
| +    count = fColorStages.count();
 | 
| +    for (int i = 0; i < count; ++i) {
 | 
| +        (*fColorStages[i].getEffect())->getConstantColorComponents(&color, &colorComps);
 | 
| +    }
 | 
| +
 | 
| +    GrAssert((NULL == solidColor) == (NULL == solidColorKnownComponents));
 | 
| +
 | 
| +    GrBlendCoeff srcCoeff = fSrcBlendCoeff;
 | 
| +    GrBlendCoeff dstCoeff = fDstBlendCoeff;
 | 
| +    GrSimplifyBlend(&srcCoeff, &dstCoeff, color, colorComps, 0, 0, 0);
 | 
| +
 | 
| +    bool opaque = kZero_GrBlendCoeff == dstCoeff && !GrBlendCoeffRefsDst(srcCoeff);
 | 
| +    if (NULL != solidColor) {
 | 
| +        if (opaque) {
 | 
| +            switch (srcCoeff) {
 | 
| +                case kZero_GrBlendCoeff:
 | 
| +                    *solidColor = 0;
 | 
| +                    *solidColorKnownComponents = kRGBA_GrColorComponentFlags;
 | 
| +                    break;
 | 
| +
 | 
| +                case kOne_GrBlendCoeff:
 | 
| +                    *solidColor = color;
 | 
| +                    *solidColorKnownComponents = colorComps;
 | 
| +                    break;
 | 
| +
 | 
| +                // The src coeff should never refer to the src and if it refers to dst then opaque
 | 
| +                // should have been false.
 | 
| +                case kSC_GrBlendCoeff:
 | 
| +                case kISC_GrBlendCoeff:
 | 
| +                case kDC_GrBlendCoeff:
 | 
| +                case kIDC_GrBlendCoeff:
 | 
| +                case kSA_GrBlendCoeff:
 | 
| +                case kISA_GrBlendCoeff:
 | 
| +                case kDA_GrBlendCoeff:
 | 
| +                case kIDA_GrBlendCoeff:
 | 
| +                default:
 | 
| +                    GrCrash("srcCoeff should not refer to src or dst.");
 | 
| +                    break;
 | 
| +
 | 
| +                // TODO: update this once GrPaint actually has a const color.
 | 
| +                case kConstC_GrBlendCoeff:
 | 
| +                case kIConstC_GrBlendCoeff:
 | 
| +                case kConstA_GrBlendCoeff:
 | 
| +                case kIConstA_GrBlendCoeff:
 | 
| +                    *solidColorKnownComponents = 0;
 | 
| +                    break;
 | 
| +            }
 | 
| +        } else {
 | 
| +            solidColorKnownComponents = 0;
 | 
| +        }
 | 
| +    }
 | 
| +    return opaque;
 | 
| +}
 | 
| 
 |