Flutter Engine
The Flutter Engine
Clip.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(Clip, 256, 90, false, 0) {
5void draw(SkCanvas* canvas) {
6 SkPaint redPaint, scalePaint;
7 redPaint.setAntiAlias(true);
8 redPaint.setColor(SK_ColorRED);
9 canvas->save();
10 for (bool antialias : { false, true } ) {
11 canvas->save();
12 canvas->clipRect(SkRect::MakeWH(19.5f, 11.5f), antialias);
13 canvas->drawCircle(17, 11, 8, redPaint);
14 canvas->restore();
15 canvas->translate(16, 0);
16 }
17 canvas->restore();
19 matrix.setScale(6, 6);
20 scalePaint.setImageFilter(
22 SkCanvas::SaveLayerRec saveLayerRec(
23 nullptr, &scalePaint, SkCanvas::kInitWithPrevious_SaveLayerFlag);
24 canvas->saveLayer(saveLayerRec);
25 canvas->restore();
26}
27} // END FIDDLE
REG_FIDDLE(Clip, 256, 90, false, 0)
Definition: Clip.cpp:4
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 clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1361
void restore()
Definition: SkCanvas.cpp:461
void translate(SkScalar dx, SkScalar dy)
Definition: SkCanvas.cpp:1278
@ kInitWithPrevious_SaveLayerFlag
initializes with previous contents
Definition: SkCanvas.h:672
int save()
Definition: SkCanvas.cpp:447
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
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Clip
Definition: layer.h:53
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkRect MakeWH(float w, float h)
Definition: SkRect.h:609