Flutter Engine
The Flutter Engine
backdrop_blur_with_rrect_clip.cpp
Go to the documentation of this file.
1// Copyright 2020 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(backdrop_blur_with_rrect_clip, 512, 512, false, 3) {
5void draw(SkCanvas* canvas) {
6 const SkRect r = SkRect::MakeXYWH(128, 128, 256, 256);
7 const SkRRect rr = SkRRect::MakeRectXY(r, 128, 128);
8
9 canvas->drawImage(image, 0, 0);
10
11 canvas->save();
12 canvas->clipRRect(rr, true);
13
14 sk_sp<SkImageFilter> filter = SkImageFilters::Blur(10, 10, nullptr);
15 SkPaint p;
16 p.setImageFilter(std::move(filter));
17
19 canvas->saveLayer(slr);
20 canvas->drawColor(0x40FFFFFF);
21 canvas->restore();
22 canvas->restore();
23}
24} // END FIDDLE
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
REG_FIDDLE(backdrop_blur_with_rrect_clip, 512, 512, false, 3)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
Definition: SkCanvas.cpp:496
void restore()
Definition: SkCanvas.cpp:461
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
Definition: SkCanvas.h:1182
@ kInitWithPrevious_SaveLayerFlag
initializes with previous contents
Definition: SkCanvas.h:672
int save()
Definition: SkCanvas.cpp:447
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
Definition: SkCanvas.h:1528
void clipRRect(const SkRRect &rrect, SkClipOp op, bool doAntiAlias)
Definition: SkCanvas.cpp:1439
static sk_sp< SkImageFilter > Blur(SkScalar sigmaX, SkScalar sigmaY, SkTileMode tileMode, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
Definition: SkRRect.h:180
sk_sp< const SkImage > image
Definition: SkRecords.h:269
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition: SkRect.h:659