Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
srgb.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "gm/gm.h"
13#include "tools/DecodeUtils.h"
14#include "tools/Resources.h"
15
16DEF_SIMPLE_GM(srgb_colorfilter, canvas, 512, 256*3) {
17 auto img = ToolUtils::GetResourceAsImage("images/mandrill_256.png");
18
19 const float array[] = {
20 1, 0, 0, 0, 0,
21 0, 1, 0, 0, 0,
22 0, 0, 1, 0, 0,
23 -1, 0, 0, 1, 0,
24 };
25 auto cf0 = SkColorFilters::Matrix(array);
28
29 SkSamplingOptions sampling;
30 SkPaint p;
31 p.setColorFilter(cf0);
32 canvas->drawImage(img, 0, 0);
33 canvas->drawImage(img, 256, 0, sampling, &p);
34
35 p.setColorFilter(cf1);
36 canvas->drawImage(img, 0, 256, sampling, &p);
37 p.setColorFilter(cf1->makeComposed(cf0));
38 canvas->drawImage(img, 256, 256, sampling, &p);
39
40 p.setColorFilter(cf2);
41 canvas->drawImage(img, 0, 512, sampling, &p);
42 p.setColorFilter(cf2->makeComposed(cf0));
43 canvas->drawImage(img, 256, 512, sampling, &p);
44}
static sk_sp< SkColorFilter > Matrix(const SkColorMatrix &)
static sk_sp< SkColorFilter > SRGBToLinearGamma()
static sk_sp< SkColorFilter > LinearToSRGBGamma()
#define DEF_SIMPLE_GM(NAME, CANVAS, W, H)
Definition gm.h:50
sk_sp< SkImage > GetResourceAsImage(const char *resource)
Definition DecodeUtils.h:25