diff options
author | Mike Reed <reed@google.com> | 2018-04-12 17:26:40 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-12 22:02:11 +0000 |
commit | 59af19f6203490547f53932171f05c8857f927ed (patch) | |
tree | 990b0136b36f11adad14e69107f8ac493fcc3372 /tests | |
parent | 92cbf3fc0112c99ec4aea9d8b7550a2573463262 (diff) |
can't abort looper loop, as saveCount won't be balanced
This is triggered by a recent change to clear the looper from the paint we return.
That change made the call to nothingToDraw() return true, which in turn meant
we didn't get the balancing call to restore in the looper's next() call.
Follow-up to https://skia-review.googlesource.com/c/skia/+/121062
Bug: skia:
Change-Id: I3ba7d487e4193103fb1d223d34c9c6eb486eca09
Reviewed-on: https://skia-review.googlesource.com/121220
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/QuickRejectTest.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/QuickRejectTest.cpp b/tests/QuickRejectTest.cpp index 24b199c8f1..103a31d936 100644 --- a/tests/QuickRejectTest.cpp +++ b/tests/QuickRejectTest.cpp @@ -174,3 +174,29 @@ DEF_TEST(QuickReject_MatrixState, reporter) { // quickReject() will assert if the matrix is out of sync. canvas.quickReject(SkRect::MakeWH(100.0f, 100.0f)); } + +#include "SkLayerDrawLooper.h" +#include "SkSurface.h" +DEF_TEST(looper_nothingtodraw, reporter) { + auto surf = SkSurface::MakeRasterN32Premul(20, 20); + + SkPaint paint; + paint.setColor(0); + REPORTER_ASSERT(reporter, paint.nothingToDraw()); + + SkLayerDrawLooper::Builder builder; + builder.addLayer(); + paint.setDrawLooper(builder.detach()); + // the presence of the looper fools this predicate, so we think it might draw + REPORTER_ASSERT(reporter, !paint.nothingToDraw()); + + // Before fixing, this would assert in ~AutoDrawLooper() in SkCanvas.cpp as it checked for + // a balance in the save/restore count after handling the looper. Before the fix, this + // code would call nothingToDraw() and since it now clears the looper, that predicate will + // return true, aborting the sequence prematurely, and not finishing the iterator on the looper + // which handles the final "restore". This was a bug -- we *must* call the looper's iterator + // until it returns done to keep the canvas balanced. The fix was to remove this early-exit + // in the autodrawlooper. Now this call won't assert. + // See https://skia-review.googlesource.com/c/skia/+/121220 + surf->getCanvas()->drawRect({1, 1, 10, 10}, paint); +} |