Flutter Engine
The Flutter Engine
Canvas_SaveLayerRec.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(Canvas_SaveLayerRec, 256, 160, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkPaint redPaint, bluePaint;
7 redPaint.setAntiAlias(true);
8 redPaint.setColor(SK_ColorRED);
9 canvas->drawCircle(21, 21, 8, redPaint);
10 bluePaint.setColor(SK_ColorBLUE);
11 canvas->drawCircle(31, 21, 8, bluePaint);
13 matrix.setScale(4, 4);
15 SkCanvas::SaveLayerRec saveLayerRec(nullptr, nullptr, scaler.get(), 0);
16 canvas->saveLayer(saveLayerRec);
17 canvas->drawCircle(125, 85, 8, redPaint);
18 canvas->restore();
19}
20} // END FIDDLE
REG_FIDDLE(Canvas_SaveLayerRec, 256, 160, false, 0)
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
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void restore()
Definition: SkCanvas.cpp:461
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
static sk_sp< SkImageFilter > MatrixTransform(const SkMatrix &matrix, const SkSamplingOptions &sampling, sk_sp< SkImageFilter > input)
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
SkSamplingOptions(SkFilterMode::kLinear))