aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PaintTest.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2014-11-11 12:51:33 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-11 12:51:33 -0800
commitf539b8cdee0204985edca028eec826ee94a0c472 (patch)
treecfea9a3650bcbcbebf91844faa75532b0d858b36 /tests/PaintTest.cpp
parent842ab70966a344e8e9bdcb43ae41548c8e0f924b (diff)
modify nothingToDraw to notice filters
Diffstat (limited to 'tests/PaintTest.cpp')
-rw-r--r--tests/PaintTest.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
index 4c45eed761..c307aa94bc 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());
+}
+