Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
color_filter_vs_colorFilterImageFilter_saveLayer.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(color_filter_vs_colorFilterImageFilter_saveLayer, 256, 128, false, 3) {
5sk_sp<SkColorFilter> saturate() {
6 SkScalar colorMatrix[20] = {1.75, 0, 0, 0, 0,
7 0, 1.75, 0, 0, 0,
8 0, 0, 1.75, 0, 0,
9 0, 0, 0, 1, 0};
10 return SkColorFilters::Matrix(colorMatrix);
11}
12
13void draw(SkCanvas* canvas) {
15 paint.setColorFilter(saturate());
16 canvas->drawImageRect(image, {0, 0, 128, 128}, SkSamplingOptions(), &paint);
17
18 SkPaint paint2;
19 paint2.setImageFilter(SkImageFilters::ColorFilter(saturate(), nullptr));
20 SkAutoCanvasRestore autoCanvasRestore(canvas, false);
21 canvas->saveLayer(nullptr, &paint2);
22 canvas->drawImageRect(image, {128, 0, 256, 128}, SkSamplingOptions());
23}
24} // END FIDDLE
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:500
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
static sk_sp< SkImageFilter > ColorFilter(sk_sp< SkColorFilter > cf, sk_sp< SkImageFilter > input, const CropRect &cropRect={})
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
const Paint & paint
sk_sp< SkImage > image
Definition examples.cpp:29
#define REG_FIDDLE(NAME, W, H, TEXT, I)
Definition examples.h:60
float SkScalar
Definition extension.cpp:12