Flutter Engine
The Flutter Engine
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.
4REG_FIDDLE(State_Stack_a, 256, 160, false, 0) {
5void draw(SkCanvas* canvas) {
7 canvas->save(); // records stack depth to restore
8 canvas->clipRect(SkRect::MakeWH(100, 100)); // constrains drawing to clip
9 canvas->clear(SK_ColorRED); // draws to limit of clip
10 canvas->save(); // records stack depth to restore
11 canvas->clipRect(SkRect::MakeWH(50, 150)); // Rect below 100 is ignored
12 canvas->clear(SK_ColorBLUE); // draws to smaller clip
13 canvas->restore(); // enlarges clip
14 canvas->drawLine(20, 20, 150, 150, paint); // line below 100 is not drawn
15 canvas->restore(); // enlarges clip
16 canvas->drawLine(150, 20, 50, 120, paint); // line below 100 is drawn
17}
18} // END FIDDLE
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
REG_FIDDLE(State_Stack_a, 256, 160, false, 0)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
void clear(SkColor color)
Definition: SkCanvas.h:1199
int save()
Definition: SkCanvas.cpp:447
const Paint & paint
Definition: color_source.cc:38
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609