Index: src/core/SkPaintPriv.cpp |
diff --git a/src/core/SkPaintPriv.cpp b/src/core/SkPaintPriv.cpp |
index e82c4045aa1371a8d0c0bc1f0765d43eed0dd608..c6957cd1cafe29ba19b76937a3d10999c7680927 100644 |
--- a/src/core/SkPaintPriv.cpp |
+++ b/src/core/SkPaintPriv.cpp |
@@ -13,65 +13,28 @@ |
#include "SkShader.h" |
bool isPaintOpaque(const SkPaint* paint, SkPaintBitmapOpacity contentType) { |
- // TODO: SkXfermode should have a virtual isOpaque method, which would |
- // make it possible to test modes that do not have a Coeff representation. |
- |
if (!paint) { |
return contentType != kUnknown_SkPaintBitmapOpacity; |
} |
- |
- SkXfermode::Coeff srcCoeff, dstCoeff; |
- if (SkXfermode::AsCoeff(paint->getXfermode(), &srcCoeff, &dstCoeff)){ |
- if (SkXfermode::kDA_Coeff == srcCoeff || SkXfermode::kDC_Coeff == srcCoeff || |
- SkXfermode::kIDA_Coeff == srcCoeff || SkXfermode::kIDC_Coeff == srcCoeff) { |
- return false; |
- } |
- switch (dstCoeff) { |
- case SkXfermode::kZero_Coeff: |
- return true; |
- case SkXfermode::kISA_Coeff: |
- if (paint->getAlpha() != 255) { |
- break; |
- } |
- if (contentType == kUnknown_SkPaintBitmapOpacity) { |
- break; |
- } else if (paint->getShader() && !paint->getShader()->isOpaque()) { |
- break; |
- } |
- if (paint->getColorFilter() && |
- ((paint->getColorFilter()->getFlags() & |
- SkColorFilter::kAlphaUnchanged_Flag) == 0)) { |
- break; |
- } |
- return true; |
- case SkXfermode::kSA_Coeff: |
- if (paint->getAlpha() != 0) { |
- break; |
- } |
- if (paint->getColorFilter() && |
- ((paint->getColorFilter()->getFlags() & |
- SkColorFilter::kAlphaUnchanged_Flag) == 0)) { |
- break; |
- } |
- return true; |
- case SkXfermode::kSC_Coeff: |
- if (paint->getColor() != 0) { // all components must be 0 |
- break; |
- } |
- if (contentType != kNoBitmap_SkPaintBitmapOpacity || paint->getShader()) { |
- break; |
- } |
- if (paint->getColorFilter() && ( |
- (paint->getColorFilter()->getFlags() & |
- SkColorFilter::kAlphaUnchanged_Flag) == 0)) { |
- break; |
- } |
- return true; |
- default: |
- break; |
+ SkXfermode::SrcColorOpacity opacityType = SkXfermode::kUnknown_SrcColorOpacity; |
+ |
+ if (!paint->getColorFilter() || |
+ ((paint->getColorFilter()->getFlags() & |
+ SkColorFilter::kAlphaUnchanged_Flag) != 0)) { |
+ if (0xff == paint->getAlpha() && |
+ contentType != kUnknown_SkPaintBitmapOpacity && |
+ (!paint->getShader() || paint->getShader()->isOpaque())) { |
+ opacityType = SkXfermode::kOpaque_SrcColorOpacity; |
+ } else if (0 == paint->getColor() && |
+ contentType == kNoBitmap_SkPaintBitmapOpacity && |
+ !paint->getShader()) { |
+ opacityType = SkXfermode::kTransparentBlack_SrcColorOpacity; |
+ } else if (0 == paint->getAlpha()) { |
+ opacityType = SkXfermode::kTransparentAlpha_SrcColorOpacity; |
} |
} |
- return false; |
+ |
+ return SkXfermode::IsOpaque(paint->getXfermode(), opacityType); |
} |
bool isPaintOpaque(const SkPaint* paint, const SkBitmap* bmpReplacesShader) { |