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

Unified Diff: skia/ext/analysis_canvas_unittest.cc

Issue 1001833005: Update from https://crrev.com/320343 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Supress Created 5 years, 9 months 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 | « skia/ext/analysis_canvas.cc ('k') | skia/ext/benchmarking_canvas.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/analysis_canvas_unittest.cc
diff --git a/skia/ext/analysis_canvas_unittest.cc b/skia/ext/analysis_canvas_unittest.cc
index 5bb18eb84c9d0f7a257deffb714c671760539d66..8263075be0fd62b2d67006a3ff8ffe1d330a28f3 100644
--- a/skia/ext/analysis_canvas_unittest.cc
+++ b/skia/ext/analysis_canvas_unittest.cc
@@ -222,6 +222,49 @@ TEST(AnalysisCanvasTest, ClipPath) {
EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
}
+TEST(AnalysisCanvasTest, SaveLayerWithXfermode) {
+ skia::AnalysisCanvas canvas(255, 255);
+ SkRect bounds = SkRect::MakeWH(255, 255);
+ SkColor outputColor;
+
+ EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor));
+ EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor);
+ SkPaint paint;
+
+ // Note: nothing is draw to the the save layer, but solid color
+ // and transparency are handled conservatively in case the layer's
+ // SkPaint draws something. For example, there could be an
+ // SkPictureImageFilter. If someday analysis_canvas starts doing
+ // a deeper analysis of the SkPaint, this test may need to be
+ // redesigned.
+ TransparentFill(canvas);
+ EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor));
+ EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor);
+ paint.setXfermodeMode(SkXfermode::kSrc_Mode);
+ canvas.saveLayer(&bounds, &paint);
+ canvas.restore();
+ EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
+
+ TransparentFill(canvas);
+ EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor));
+ EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor);
+ paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
+ canvas.saveLayer(&bounds, &paint);
+ canvas.restore();
+ EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
+
+ // Layer with dst xfermode is a no-op, so this is the only case
+ // where solid color is unaffected by the layer.
+ TransparentFill(canvas);
+ EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor));
+ EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor);
+ paint.setXfermodeMode(SkXfermode::kDst_Mode);
+ canvas.saveLayer(&bounds, &paint);
+ canvas.restore();
+ EXPECT_TRUE(canvas.GetColorIfSolid(&outputColor));
+ EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), outputColor);
+}
+
TEST(AnalysisCanvasTest, SaveLayerRestore) {
skia::AnalysisCanvas canvas(255, 255);
« no previous file with comments | « skia/ext/analysis_canvas.cc ('k') | skia/ext/benchmarking_canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698