Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
State_Stack_a.cpp
Go to the documentation of this file.
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.
4// HASH=bb1dbfdca3aedf716beb6f07e2aab065
5REG_FIDDLE(State_Stack_a, 256, 160, false, 0) {
6void draw(SkCanvas* canvas) {
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
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition aaclip.cpp:27
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void restore()
Definition SkCanvas.cpp:465
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void clear(SkColor color)
Definition SkCanvas.h:1199
int save()
Definition SkCanvas.cpp:451
const Paint & paint
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
static constexpr SkRect MakeWH(float w, float h)
Definition SkRect.h:609