blob: 70fc6c683e6fd54e67b8f1fd3ce4a81d114b32c1 [file] [log] [blame]
Hal Canary6c8422c2020-01-10 15:22:09 -05001// 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.
3#include "tools/fiddle/examples.h"
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) {
14 SkPaint paint;
15 paint.setColorFilter(saturate());
16 canvas->drawImageRect(image, {0, 0, 128, 128}, &paint);
17
18 SkPaint paint2;
19 paint2.setImageFilter(SkColorFilterImageFilter::Make(saturate(), nullptr));
20 SkAutoCanvasRestore autoCanvasRestore(canvas, false);
21 canvas->saveLayer(nullptr, &paint2);
22 canvas->drawImageRect(image, {128, 0, 256, 128}, nullptr);
23}
24} // END FIDDLE