Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
color_filter_vs_colorFilterImageFilter_saveLayer.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (color_filter_vs_colorFilterImageFilter_saveLayer, 256, 128, false, 3)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( color_filter_vs_colorFilterImageFilter_saveLayer  ,
256  ,
128  ,
false  ,
 
)

Definition at line 4 of file color_filter_vs_colorFilterImageFilter_saveLayer.cpp.

4 {
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
float SkScalar
Definition extension.cpp:12