Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: src/core/SkPaint.cpp

Issue 683003003: modify nothingToDraw to notice filters (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | tests/PaintTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPaint.cpp
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index ebdc866d653b5b787862ae3d5ebd86524cb09b4e..4ccfce235acc228c1690545bbba9f56bbf186334 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:
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | tests/PaintTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698