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

Unified Diff: tests/PaintTest.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 | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PaintTest.cpp
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index 4c45eed7614c368e270c47f3f1249f22b1223575..c307aa94bcd9d67a58e316c165aca4c50e3175f2 100644
--- a/tests/PaintTest.cpp
+++ b/tests/PaintTest.cpp
@@ -344,3 +344,30 @@ DEF_TEST(Paint_getHash, r) {
paint.setHinting(SkPaint::kNormal_Hinting);
REPORTER_ASSERT(r, paint.getHash() == defaultHash);
}
+
+#include "SkColorMatrixFilter.h"
+
+DEF_TEST(Paint_nothingToDraw, r) {
+ SkPaint paint;
+
+ REPORTER_ASSERT(r, !paint.nothingToDraw());
+ paint.setAlpha(0);
+ REPORTER_ASSERT(r, paint.nothingToDraw());
+
+ paint.setAlpha(0xFF);
+ paint.setXfermodeMode(SkXfermode::kDst_Mode);
+ REPORTER_ASSERT(r, paint.nothingToDraw());
+
+ paint.setAlpha(0);
+ paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
+
+ SkColorMatrix cm;
+ cm.setIdentity(); // does not change alpha
+ paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref();
+ REPORTER_ASSERT(r, paint.nothingToDraw());
+
+ cm.postTranslate(0, 0, 0, 1); // wacks alpha
+ paint.setColorFilter(SkColorMatrixFilter::Create(cm))->unref();
+ REPORTER_ASSERT(r, !paint.nothingToDraw());
+}
+
« no previous file with comments | « src/core/SkPaint.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698