1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 // HASH=32d51e959d6cc720a74ec4822511e2cd
5 REG_FIDDLE(Region_Iterator_rewind, 256, 256, true, 0) {
draw(SkCanvas * canvas)6 void draw(SkCanvas* canvas) {
7 auto debugster = [](const char* label, SkRegion::Iterator& iter, bool addRewind) -> void {
8 if (addRewind) {
9 bool success = iter.rewind();
10 SkDebugf("%14s rewind success=%s\n", label, success ? "true" : "false");
11 }
12 auto r = iter.rect();
13 SkDebugf("%14s rect={%d,%d,%d,%d}\n", label, r.fLeft, r.fTop, r.fRight, r.fBottom);
14 };
15 SkRegion::Iterator iter;
16 debugster("empty iter", iter, true);
17 SkRegion region;
18 iter.reset(region);
19 debugster("empty region", iter, true);
20 region.setRect({1, 2, 3, 4});
21 iter.reset(region);
22 debugster("after set rect", iter, false);
23 debugster("after rewind", iter, true);
24 }
25 } // END FIDDLE
26