Chromium Code Reviews| Index: src/core/SkPaintPriv.cpp |
| diff --git a/src/core/SkPaintPriv.cpp b/src/core/SkPaintPriv.cpp |
| index 3ced57392934e1f5b6a5fbb993c9c7f7be9acab9..4249f83281b892eefe8b2f0bb89fcdc54f0ed80c 100644 |
| --- a/src/core/SkPaintPriv.cpp |
| +++ b/src/core/SkPaintPriv.cpp |
| @@ -13,45 +13,45 @@ |
| #include "SkPaint.h" |
| #include "SkShader.h" |
| -bool isPaintOpaque(const SkPaint* paint, SkPaintBitmapOpacity contentType) { |
| +static bool changes_alpha(const SkPaint& paint) { |
| + SkColorFilter* cf = paint.getColorFilter(); |
| + return cf && !(cf->getFlags() & SkColorFilter::kAlphaUnchanged_Flag); |
| +} |
| + |
| +bool SkPaintPriv::Overwrites(const SkPaint* paint, ShaderOverrideOpacity overrideOpacity) { |
| if (!paint) { |
| - return contentType != kUnknown_SkPaintBitmapOpacity; |
| + // No paint means we default to SRC_OVER, so we overwrite iff our shader-override |
| + // is opaque, or we don't have one. |
| + return overrideOpacity != kNotOpaque_ShaderOverrideOpacity; |
| } |
| + |
| 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())) { |
| + if (!changes_alpha(*paint)) { |
| + const unsigned paintAlpha = paint->getAlpha(); |
| + if (0xff == paintAlpha && |
|
robertphillips
2015/07/15 15:53:51
Can this go on the prior line ?
reed1
2015/07/15 18:03:03
Done.
|
| + overrideOpacity != kNotOpaque_ShaderOverrideOpacity && |
| + (!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; |
| + } else if (0 == paintAlpha) { |
| + if (overrideOpacity == kNone_ShaderOverrideOpacity && !paint->getShader()) { |
| + opacityType = SkXfermode::kTransparentBlack_SrcColorOpacity; |
| + } else { |
| + opacityType = SkXfermode::kTransparentAlpha_SrcColorOpacity; |
| + } |
| } |
| } |
| return SkXfermode::IsOpaque(paint->getXfermode(), opacityType); |
| } |
| -bool isPaintOpaque(const SkPaint* paint, const SkBitmap* bmpReplacesShader) { |
| - SkPaintBitmapOpacity contentType; |
| - |
| - if(!bmpReplacesShader) |
| - contentType = kNoBitmap_SkPaintBitmapOpacity; |
| - else if(bmpReplacesShader->isOpaque()) |
| - contentType = kOpaque_SkPaintBitmapOpacity; |
| - else |
| - contentType = kUnknown_SkPaintBitmapOpacity; |
| - |
| - return isPaintOpaque(paint, contentType); |
| +bool SkPaintPriv::Overwrites(const SkPaint* paint, const SkBitmap& bitmap) { |
| + return Overwrites(paint, bitmap.isOpaque() ? kOpaque_ShaderOverrideOpacity |
| + : kNotOpaque_ShaderOverrideOpacity); |
| } |
| -bool isPaintOpaque(const SkPaint* paint, const SkImage* image) { |
| - return isPaintOpaque(paint, image->isOpaque() ? |
| - kOpaque_SkPaintBitmapOpacity : kUnknown_SkPaintBitmapOpacity); |
| +bool SkPaintPriv::Overwrites(const SkPaint* paint, const SkImage* image) { |
| + return Overwrites(paint, image->isOpaque() ? kOpaque_ShaderOverrideOpacity |
| + : kNotOpaque_ShaderOverrideOpacity); |
| } |