aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PictureBBHTest.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2014-11-20 08:01:09 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-20 08:01:09 -0800
commit7cc1a34fbf5506e3a9e6834f0dcd988aa7c94084 (patch)
treef947a516b3f8cf92dae9b6fef53e8c1af2ec410f /tests/PictureBBHTest.cpp
parent9176e2c159089458b1e2226a94fab1af0fba32ac (diff)
Make sure pictures draw Clears even when the clip is empty.
We fix this by rewriting empty queries to very tiny queries, which will certainly hit ops that span the entire picture (like Clear) and hopefully not much more. (This doesn't quite work in the full cull rect world if [0,0,ε,ε] doesn't overlap the picture. Let's cross that bridge when we get there.) BUG=432991 Review URL: https://codereview.chromium.org/732723004
Diffstat (limited to 'tests/PictureBBHTest.cpp')
-rw-r--r--tests/PictureBBHTest.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/PictureBBHTest.cpp b/tests/PictureBBHTest.cpp
index 3ff5625686..fa02437432 100644
--- a/tests/PictureBBHTest.cpp
+++ b/tests/PictureBBHTest.cpp
@@ -49,7 +49,9 @@ private:
SkCanvas playbackCanvas(fResultBitmap);
playbackCanvas.clear(SK_ColorGREEN);
SkPictureRecorder recorder;
- SkCanvas* recordCanvas = recorder.beginRecording(SkIntToScalar(fPictureWidth), SkIntToScalar(fPictureHeight), factory);
+ SkCanvas* recordCanvas = recorder.beginRecording(SkIntToScalar(fPictureWidth),
+ SkIntToScalar(fPictureHeight),
+ factory);
this->doTest(playbackCanvas, *recordCanvas);
SkAutoTUnref<SkPicture> picture(recorder.endRecording());
playbackCanvas.drawPicture(picture);
@@ -99,3 +101,34 @@ DEF_TEST(PictureBBH, reporter) {
EmptyClipPictureBBHTest emptyClipPictureTest;
emptyClipPictureTest.run(reporter);
}
+
+static void test_clear(skiatest::Reporter* r, SkBBHFactory* factory) {
+ // SkPicture should always call clear()s on the target canvas, even if its clip is empty.
+ SkPictureRecorder src, dst;
+
+ // A picture that's just clear().
+ src.beginRecording(1,1, factory)
+ ->clear(SK_ColorGREEN);
+ SkAutoTDelete<SkPicture> srcPic(src.endRecording());
+
+ // A target canvas with an empty clip.
+ SkCanvas* c = dst.beginRecording(1,1, NULL);
+ c->clipRect(SkRect::MakeEmpty());
+ srcPic->playback(c);
+ SkAutoTDelete<SkPicture> dstPic(dst.endRecording());
+
+ // Should be Clip - Save - Clear - Restore.
+ // Buggy implementations might return 1 (just Clip) or 3 (Clip - Save - Restore).
+ REPORTER_ASSERT(r, dstPic->approximateOpCount() == 4);
+}
+
+DEF_TEST(PictureBBH_Clear, r) {
+ test_clear(r, NULL);
+
+ SkTileGridFactory::TileGridInfo grid = { {1,1}, {0,0}, {0,0} };
+ SkTileGridFactory tilegrid(grid);
+ test_clear(r, &tilegrid);
+
+ SkRTreeFactory rtree;
+ test_clear(r, &rtree);
+}