2017-07-06 02:40:23 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "gm/gm.h"
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
|
|
#include "include/core/SkColorFilter.h"
|
2019-05-01 21:28:53 +00:00
|
|
|
#include "include/core/SkPaint.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/Resources.h"
|
2017-07-06 02:40:23 +00:00
|
|
|
|
|
|
|
DEF_SIMPLE_GM(srgb_colorfilter, canvas, 512, 256*3) {
|
2017-12-08 15:21:31 +00:00
|
|
|
auto img = GetResourceAsImage("images/mandrill_256.png");
|
2017-07-06 02:40:23 +00:00
|
|
|
|
|
|
|
const float array[] = {
|
|
|
|
1, 0, 0, 0, 0,
|
|
|
|
0, 1, 0, 0, 0,
|
|
|
|
0, 0, 1, 0, 0,
|
|
|
|
-1, 0, 0, 1, 0,
|
|
|
|
};
|
2019-04-30 16:18:54 +00:00
|
|
|
auto cf0 = SkColorFilters::Matrix(array);
|
2019-04-08 20:23:20 +00:00
|
|
|
auto cf1 = SkColorFilters::LinearToSRGBGamma();
|
|
|
|
auto cf2 = SkColorFilters::SRGBToLinearGamma();
|
2017-07-06 02:40:23 +00:00
|
|
|
|
2021-01-23 17:23:23 +00:00
|
|
|
SkSamplingOptions sampling;
|
2017-07-06 02:40:23 +00:00
|
|
|
SkPaint p;
|
|
|
|
p.setColorFilter(cf0);
|
2021-01-23 17:23:23 +00:00
|
|
|
canvas->drawImage(img, 0, 0);
|
|
|
|
canvas->drawImage(img, 256, 0, sampling, &p);
|
2017-07-06 02:40:23 +00:00
|
|
|
|
|
|
|
p.setColorFilter(cf1);
|
2021-01-23 17:23:23 +00:00
|
|
|
canvas->drawImage(img, 0, 256, sampling, &p);
|
2018-02-19 19:10:57 +00:00
|
|
|
p.setColorFilter(cf1->makeComposed(cf0));
|
2021-01-23 17:23:23 +00:00
|
|
|
canvas->drawImage(img, 256, 256, sampling, &p);
|
2017-07-06 02:40:23 +00:00
|
|
|
|
|
|
|
p.setColorFilter(cf2);
|
2021-01-23 17:23:23 +00:00
|
|
|
canvas->drawImage(img, 0, 512, sampling, &p);
|
2018-02-19 19:10:57 +00:00
|
|
|
p.setColorFilter(cf2->makeComposed(cf0));
|
2021-01-23 17:23:23 +00:00
|
|
|
canvas->drawImage(img, 256, 512, sampling, &p);
|
2017-07-06 02:40:23 +00:00
|
|
|
}
|