Chromium Code Reviews| Index: tests/CanvasStateTest.cpp |
| diff --git a/tests/CanvasStateTest.cpp b/tests/CanvasStateTest.cpp |
| index f1c35929d60875186018003a2e57fe8d78cb60a4..3cb6b9dde9eb48d61ff57e0bbb9d507b8c48f3f3 100644 |
| --- a/tests/CanvasStateTest.cpp |
| +++ b/tests/CanvasStateTest.cpp |
| @@ -226,9 +226,45 @@ 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.setConfig(SkBitmap::kARGB_8888_Config, WIDTH, HEIGHT); |
|
reed1
2014/02/13 18:57:40
nit: try using the new pattern for this:
bitmap.a
|
| + bitmap.allocPixels(); |
| + |
| + 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(); |
| + |
| + // 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); |
| } |