Chromium Code Reviews| Index: tests/PictureTest.cpp |
| diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp |
| index 1827fdcb5a28ceb0a33541825c58a0fe57914790..30eb6bb26d9f5ed1a9e37634797d6348c4320250 100644 |
| --- a/tests/PictureTest.cpp |
| +++ b/tests/PictureTest.cpp |
| @@ -8,6 +8,7 @@ |
| #include "SkCanvas.h" |
| #include "SkColorPriv.h" |
| #include "SkData.h" |
| +#include "SkDevice.h" |
| #include "SkError.h" |
| #include "SkPaint.h" |
| #include "SkPicture.h" |
| @@ -550,6 +551,45 @@ static void test_clip_bound_opt(skiatest::Reporter* reporter) { |
| } |
| } |
|
robertphillips
2013/08/27 15:08:56
// Comment
// This canvas ...
|
| +class ClipCountingCanvas : public SkCanvas { |
| +public: |
| + explicit ClipCountingCanvas(SkDevice* device) |
| + : SkCanvas(device) |
| + , fClipCount(0){ |
| + } |
| + |
|
robertphillips
2013/08/27 15:08:56
clipPath
fmalita's clipX
clipRRect
|
| + virtual bool clipRect(const SkRect& r, SkRegion::Op op, bool doAA) |
| + SK_OVERRIDE { |
| + fClipCount += 1; |
| + return SkCanvas::clipRect(r, op, doAA); |
| + } |
| + |
| + unsigned getClipCount() const { return fClipCount; } |
| + |
| +private: |
| + unsigned fClipCount; |
|
robertphillips
2013/08/27 15:08:56
inherited
|
| +}; |
| + |
| +static void test_clip_expansion(skiatest::Reporter* reporter) { |
| + SkPicture picture; |
| + SkCanvas* canvas = picture.beginRecording(10, 10, 0); |
| + |
| + canvas->clipRect(SkRect::MakeEmpty(), SkRegion::kReplace_Op); |
| + // The following expanding clip should not be skipped. |
| + canvas->clipRect(SkRect::MakeXYWH(4, 4, 3, 3), SkRegion::kUnion_Op); |
| + // Draw something so the optimizer doesn't just fold the world. |
| + SkPaint p; |
| + p.setColor(SK_ColorBLUE); |
| + canvas->drawPaint(p); |
| + |
| + SkDevice testDevice(SkBitmap::kNo_Config, 10, 10); |
| + ClipCountingCanvas testCanvas(&testDevice); |
| + picture.draw(&testCanvas); |
| + |
| + // Both clips should be present on playback. |
| + REPORTER_ASSERT(reporter, testCanvas.getClipCount() == 2); |
| +} |
| + |
| static void TestPicture(skiatest::Reporter* reporter) { |
| #ifdef SK_DEBUG |
| test_deleting_empty_playback(); |
| @@ -562,6 +602,7 @@ static void TestPicture(skiatest::Reporter* reporter) { |
| test_bitmap_with_encoded_data(reporter); |
| test_clone_empty(reporter); |
| test_clip_bound_opt(reporter); |
| + test_clip_expansion(reporter); |
| } |
| #include "TestClassDef.h" |