aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-02-04 11:35:27 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-04 11:35:27 -0800
commitf7cdb06d62bd732599c7ee407dfd76d32d671755 (patch)
tree52cd10f9671d35d50713f6ca3156f52f5a4e687a /gm
parenteb10ed40905173586fc7a926aa2fe405bab66573 (diff)
extend compose-colorfilter to 4f
Diffstat (limited to 'gm')
-rw-r--r--gm/color4f.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/gm/color4f.cpp b/gm/color4f.cpp
index 98ce0824cc..e912654bc9 100644
--- a/gm/color4f.cpp
+++ b/gm/color4f.cpp
@@ -32,10 +32,23 @@ static SkColorFilter* make_cf0() {
return SkColorMatrixFilter::Create(cm);
}
+static SkColorFilter* make_cf1() {
+ SkColorMatrix cm;
+ cm.setSaturation(0.75f);
+ SkAutoTUnref<SkColorFilter> a(SkColorMatrixFilter::Create(cm));
+ // CreateComposedFilter will try to concat these two matrices, resulting in a single
+ // filter (which is good for speed). For this test, we want to force a real compose of
+ // these two, so our inner filter has a scale-up, which disables the optimization of
+ // combining the two matrices.
+ cm.setScale(1.1f, 0.9f, 1);
+ SkAutoTUnref<SkColorFilter> b(SkColorMatrixFilter::Create(cm));
+ return SkColorFilter::CreateComposeFilter(a, b);
+}
+
static void draw_into_canvas(SkCanvas* canvas) {
const SkRect r = SkRect::MakeWH(100, 100);
SkShader* (*shaders[])() { make_opaque_color, make_alpha_color };
- SkColorFilter* (*filters[])() { make_cf_null, make_cf0 };
+ SkColorFilter* (*filters[])() { make_cf_null, make_cf0, make_cf1 };
SkPaint paint;
for (auto shProc : shaders) {
@@ -48,7 +61,7 @@ static void draw_into_canvas(SkCanvas* canvas) {
}
}
-DEF_SIMPLE_GM(color4f, canvas, 510, 250) {
+DEF_SIMPLE_GM(color4f, canvas, 620, 260) {
canvas->translate(20, 20);
SkPaint bg;
@@ -58,7 +71,7 @@ DEF_SIMPLE_GM(color4f, canvas, 510, 250) {
SkColorProfileType const profiles[] { kLinear_SkColorProfileType, kSRGB_SkColorProfileType };
for (auto profile : profiles) {
- const SkImageInfo info = SkImageInfo::Make(500, 100, kN32_SkColorType, kPremul_SkAlphaType,
+ const SkImageInfo info = SkImageInfo::Make(600, 100, kN32_SkColorType, kPremul_SkAlphaType,
profile);
SkAutoTUnref<SkSurface> surface(SkSurface::NewRaster(info));
surface->getCanvas()->drawPaint(bg);