diff options
author | reed <reed@google.com> | 2014-11-11 12:51:33 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-11-11 12:51:33 -0800 |
commit | f539b8cdee0204985edca028eec826ee94a0c472 (patch) | |
tree | cfea9a3650bcbcbebf91844faa75532b0d858b36 /src | |
parent | 842ab70966a344e8e9bdcb43ae41548c8e0f924b (diff) |
modify nothingToDraw to notice filters
This reverts commit c71ffd4e76d1abcd28ac74463349970f60a3350f.
TBR=
Review URL: https://codereview.chromium.org/683003003
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPaint.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index ebdc866d65..4ccfce235a 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -2377,6 +2377,18 @@ bool SkTextToPathIter::next(const SkPath** path, SkScalar* xpos) { /////////////////////////////////////////////////////////////////////////////// +// return true if the filter exists, and may affect alpha +static bool affects_alpha(const SkColorFilter* cf) { + return cf && !(cf->getFlags() & SkColorFilter::kAlphaUnchanged_Flag); +} + +// return true if the filter exists, and may affect alpha +static bool affects_alpha(const SkImageFilter* imf) { + // TODO: check if we should allow imagefilters to broadcast that they don't affect alpha + // ala colorfilters + return imf != NULL; +} + bool SkPaint::nothingToDraw() const { if (fLooper) { return false; @@ -2389,7 +2401,10 @@ bool SkPaint::nothingToDraw() const { case SkXfermode::kDstOut_Mode: case SkXfermode::kDstOver_Mode: case SkXfermode::kPlus_Mode: - return 0 == this->getAlpha(); + if (0 == this->getAlpha()) { + return !affects_alpha(fColorFilter) && !affects_alpha(fImageFilter); + } + break; case SkXfermode::kDst_Mode: return true; default: |