blob: 7750c089d295f95f35d4edc0ad9a7ab4edaf6ead [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001// 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.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05003#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04004// HASH=bb1dbfdca3aedf716beb6f07e2aab065
Hal Canarya7181e7c2019-03-18 16:06:34 -04005REG_FIDDLE(State_Stack_a, 256, 160, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04006void draw(SkCanvas* canvas) {
7 SkPaint paint;
8 canvas->save(); // records stack depth to restore
9 canvas->clipRect(SkRect::MakeWH(100, 100)); // constrains drawing to clip
10 canvas->clear(SK_ColorRED); // draws to limit of clip
11 canvas->save(); // records stack depth to restore
12 canvas->clipRect(SkRect::MakeWH(50, 150)); // Rect below 100 is ignored
13 canvas->clear(SK_ColorBLUE); // draws to smaller clip
14 canvas->restore(); // enlarges clip
15 canvas->drawLine(20, 20, 150, 150, paint); // line below 100 is not drawn
16 canvas->restore(); // enlarges clip
17 canvas->drawLine(150, 20, 50, 120, paint); // line below 100 is drawn
18}
19} // END FIDDLE