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

Unified Diff: tests/CanvasStateTest.cpp

Issue 164203002: Don't modify the clipstack in saveLayer() if the kClipToLayer_SaveFlag is (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use allocN32Pixels() shortcut. Created 6 years, 10 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 | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CanvasStateTest.cpp
diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp
index f1c35929d60875186018003a2e57fe8d78cb60a4..32b650af6449031fa293423d7057ab8d84834ef9 100644
--- a/tests/CanvasStateTest.cpp
+++ b/tests/CanvasStateTest.cpp
@@ -226,9 +226,43 @@ static void test_soft_clips(skiatest::Reporter* reporter) {
SkClearLastError();
}
+static void test_saveLayer_clip(skiatest::Reporter* reporter) {
+ const int WIDTH = 100;
+ const int HEIGHT = 100;
+ const int LAYER_WIDTH = 50;
+ const int LAYER_HEIGHT = 50;
+
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(WIDTH, HEIGHT);
+ SkCanvas canvas(bitmap);
+
+ SkRect bounds = SkRect::MakeWH(SkIntToScalar(LAYER_WIDTH), SkIntToScalar(LAYER_HEIGHT));
+ canvas.clipRect(SkRect::MakeWH(SkIntToScalar(WIDTH), SkIntToScalar(HEIGHT)));
+
+ // Check that saveLayer without the kClipToLayer_SaveFlag leaves the
+ // clip stack unchanged.
+ canvas.saveLayer(&bounds, NULL, SkCanvas::kARGB_NoClipLayer_SaveFlag);
+ SkRect clipStackBounds;
+ SkClipStack::BoundsType boundsType;
+ canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType);
+ REPORTER_ASSERT(reporter, clipStackBounds.width() == WIDTH);
+ REPORTER_ASSERT(reporter, clipStackBounds.height() == HEIGHT);
+ canvas.restore();
+
robertphillips 2014/02/13 19:12:34 without -> with in comment?
+ // Check that saveLayer without the kClipToLayer_SaveFlag sets the clip
+ // stack to the layer bounds.
+ canvas.saveLayer(&bounds, NULL, SkCanvas::kARGB_ClipLayer_SaveFlag);
+ canvas.getClipStack()->getBounds(&clipStackBounds, &boundsType);
+ REPORTER_ASSERT(reporter, clipStackBounds.width() == LAYER_WIDTH);
+ REPORTER_ASSERT(reporter, clipStackBounds.height() == LAYER_HEIGHT);
+
+ canvas.restore();
+}
+
DEF_TEST(CanvasState, reporter) {
test_complex_layers(reporter);
test_complex_clips(reporter);
test_draw_filters(reporter);
test_soft_clips(reporter);
+ test_saveLayer_clip(reporter);
}
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698