diff options
author | reed <reed@google.com> | 2015-03-11 08:47:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-11 08:47:12 -0700 |
commit | 9b3aa54bc9605257c701cf465813f5fb1d7ba39e (patch) | |
tree | 5a94c62d3059853151de7d34b2410864c40917e0 /tests/QuickRejectTest.cpp | |
parent | cc99dbc57be301a890140d74cff8d167838947af (diff) |
optimization/fix: dirty the clip-bounds when we mod the clip in savelayer
Before the fix, we could use a stale cache of the clipbounds in quickReject. Often this could return false negatives, meaning we would try to draw more than we should (it would eventually be really clipped). Occasionally this could also report false positives (if the layer were outside of the normal canvas bounds, e.g. a layer with an offset imagefilter).
BUG=skia:
NOTREECHECKS=True
Review URL: https://codereview.chromium.org/983243003
Diffstat (limited to 'tests/QuickRejectTest.cpp')
-rw-r--r-- | tests/QuickRejectTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/QuickRejectTest.cpp b/tests/QuickRejectTest.cpp index cefde12354..447d81615b 100644 --- a/tests/QuickRejectTest.cpp +++ b/tests/QuickRejectTest.cpp @@ -87,6 +87,23 @@ static void test_drawBitmap(skiatest::Reporter* reporter) { REPORTER_ASSERT(reporter, 0xFFFFFFFF == *dst.getAddr32(5, 5)); } +static void test_layers(skiatest::Reporter* reporter) { + SkCanvas canvas(100, 100); + + SkRect r = SkRect::MakeWH(10, 10); + REPORTER_ASSERT(reporter, false == canvas.quickReject(r)); + + r.offset(300, 300); + REPORTER_ASSERT(reporter, true == canvas.quickReject(r)); + + // Test that saveLayer updates quickReject + SkRect bounds = SkRect::MakeLTRB(50, 50, 70, 70); + canvas.saveLayer(&bounds, NULL); + REPORTER_ASSERT(reporter, true == canvas.quickReject(SkRect::MakeWH(10, 10))); + REPORTER_ASSERT(reporter, false == canvas.quickReject(SkRect::MakeWH(60, 60))); +} + DEF_TEST(QuickReject, reporter) { test_drawBitmap(reporter); + test_layers(reporter); } |