halcanary | 86e5ab6 | 2015-04-14 06:25:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkCanvas.h" |
| 10 | #include "include/core/SkColorFilter.h" |
| 11 | #include "include/core/SkImageFilter.h" |
| 12 | #include "include/core/SkPaint.h" |
| 13 | #include "include/core/SkRect.h" |
| 14 | #include "include/core/SkRefCnt.h" |
Michael Ludwig | 898bbfa | 2019-08-02 15:21:23 -0400 | [diff] [blame] | 15 | #include "include/effects/SkImageFilters.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 16 | |
| 17 | #include <utility> |
halcanary | 86e5ab6 | 2015-04-14 06:25:19 -0700 | [diff] [blame] | 18 | |
| 19 | // This GM renders correctly in 8888, but fails in PDF |
| 20 | DEF_SIMPLE_GM(fadefilter, canvas, 256, 256) { |
Mike Reed | e869a1e | 2019-04-30 12:18:54 -0400 | [diff] [blame] | 21 | float matrix[20] = { 1, 0, 0, 0, 0.5f, |
| 22 | 0, 1, 0, 0, 0.5f, |
| 23 | 0, 0, 1, 0, 0.5f, |
| 24 | 0, 0, 0, 1, 0 }; |
| 25 | sk_sp<SkColorFilter> colorFilter(SkColorFilters::Matrix(matrix)); |
halcanary | 86e5ab6 | 2015-04-14 06:25:19 -0700 | [diff] [blame] | 26 | SkPaint layerPaint; |
Michael Ludwig | 898bbfa | 2019-08-02 15:21:23 -0400 | [diff] [blame] | 27 | layerPaint.setImageFilter(SkImageFilters::ColorFilter(std::move(colorFilter), nullptr)); |
halcanary | 86e5ab6 | 2015-04-14 06:25:19 -0700 | [diff] [blame] | 28 | canvas->drawRect(SkRect::MakeLTRB(64, 64, 192, 192), layerPaint); |
| 29 | } |