Flutter Engine
The Flutter Engine
Canvas_kInitWithPrevious_SaveLayerFlag.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_kInitWithPrevious_SaveLayerFlag, 256, 160, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkPaint redPaint, bluePaint, scalePaint;
7 redPaint.setColor(SK_ColorRED);
8 canvas->drawCircle(21, 21, 8, redPaint);
9 bluePaint.setColor(SK_ColorBLUE);
10 canvas->drawCircle(31, 21, 8, bluePaint);
12 matrix.setScale(4, 4);
13 scalePaint.setAlpha(0x40);
14 scalePaint.setImageFilter(
16 SkCanvas::SaveLayerRec saveLayerRec(nullptr, &scalePaint,
18 canvas->saveLayer(saveLayerRec);
19 canvas->restore();
20}
21} // END FIDDLE
REG_FIDDLE(Canvas_kInitWithPrevious_SaveLayerFlag, 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
@ kInitWithPrevious_SaveLayerFlag
initializes with previous contents
Definition: SkCanvas.h:672
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 setImageFilter(sk_sp< SkImageFilter > imageFilter)
void setAlpha(U8CPU a)
Definition: SkPaint.h:279
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
SkSamplingOptions(SkFilterMode::kLinear))