diff options
author | piotaixr <piotaixr@chromium.org> | 2014-10-22 08:35:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-22 08:35:45 -0700 |
commit | 46c248da267d315d500d2296a205cf22077b3e87 (patch) | |
tree | 6bf842b92148763fdfe72f268e665eaf51677d3c /src/core/SkPaintPriv.cpp | |
parent | d2ae72858eaa568e7f2511484f506140dc684a46 (diff) |
More genericity: overload isPaintOpaque(SkPaint, SkBitmap)
Instead of taking a Bitmap as an argument this version
takes only the type of content (None/Opaque/Transparent).
This will be used to check the opaqueness of a SkPaint
that draws a SkImage.
BUG=skia:3042
Review URL: https://codereview.chromium.org/663233002
Diffstat (limited to 'src/core/SkPaintPriv.cpp')
-rw-r--r-- | src/core/SkPaintPriv.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/core/SkPaintPriv.cpp b/src/core/SkPaintPriv.cpp index ce05389019..e82c4045aa 100644 --- a/src/core/SkPaintPriv.cpp +++ b/src/core/SkPaintPriv.cpp @@ -12,13 +12,12 @@ #include "SkPaint.h" #include "SkShader.h" -bool isPaintOpaque(const SkPaint* paint, - const SkBitmap* bmpReplacesShader) { +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 bmpReplacesShader ? bmpReplacesShader->isOpaque() : true; + return contentType != kUnknown_SkPaintBitmapOpacity; } SkXfermode::Coeff srcCoeff, dstCoeff; @@ -34,10 +33,8 @@ bool isPaintOpaque(const SkPaint* paint, if (paint->getAlpha() != 255) { break; } - if (bmpReplacesShader) { - if (!bmpReplacesShader->isOpaque()) { - break; - } + if (contentType == kUnknown_SkPaintBitmapOpacity) { + break; } else if (paint->getShader() && !paint->getShader()->isOpaque()) { break; } @@ -61,7 +58,7 @@ bool isPaintOpaque(const SkPaint* paint, if (paint->getColor() != 0) { // all components must be 0 break; } - if (bmpReplacesShader || paint->getShader()) { + if (contentType != kNoBitmap_SkPaintBitmapOpacity || paint->getShader()) { break; } if (paint->getColorFilter() && ( @@ -76,3 +73,16 @@ bool isPaintOpaque(const SkPaint* paint, } return false; } + +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); +} |