mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2011 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.h" |
Mike Klein | 33d2055 | 2017-03-22 13:47:51 -0400 | [diff] [blame^] | 9 | #include "sk_tool_utils.h" |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 10 | #include "SkCanvas.h" |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 11 | #include "SkColorFilterImageFilter.h" |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 12 | #include "SkGradientShader.h" |
| 13 | #include "SkTableColorFilter.h" |
| 14 | |
reed | 1a9b964 | 2016-03-13 14:13:58 -0700 | [diff] [blame] | 15 | static sk_sp<SkShader> make_shader0(int w, int h) { |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 16 | SkPoint pts[] = { {0, 0}, {SkIntToScalar(w), SkIntToScalar(h)} }; |
| 17 | SkColor colors[] = { |
| 18 | SK_ColorBLACK, SK_ColorGREEN, SK_ColorCYAN, |
| 19 | SK_ColorRED, 0, SK_ColorBLUE, SK_ColorWHITE |
| 20 | }; |
reed | 1a9b964 | 2016-03-13 14:13:58 -0700 | [diff] [blame] | 21 | return SkGradientShader::MakeLinear(pts, colors, nullptr, SK_ARRAY_COUNT(colors), |
| 22 | SkShader::kClamp_TileMode); |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 23 | } |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 24 | static void make_bm0(SkBitmap* bm) { |
| 25 | int W = 120; |
| 26 | int H = 120; |
reed@google.com | eb9a46c | 2014-01-25 16:46:20 +0000 | [diff] [blame] | 27 | bm->allocN32Pixels(W, H); |
junov@google.com | dbfac8a | 2012-12-06 21:47:40 +0000 | [diff] [blame] | 28 | bm->eraseColor(SK_ColorTRANSPARENT); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 29 | |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 30 | SkCanvas canvas(*bm); |
| 31 | SkPaint paint; |
reed | 1a9b964 | 2016-03-13 14:13:58 -0700 | [diff] [blame] | 32 | paint.setShader(make_shader0(W, H)); |
reed | 5bd055c | 2015-03-01 19:16:38 -0800 | [diff] [blame] | 33 | canvas.drawPaint(paint); |
reed | b675a73 | 2015-03-01 18:00:47 -0800 | [diff] [blame] | 34 | } |
reed | 1a9b964 | 2016-03-13 14:13:58 -0700 | [diff] [blame] | 35 | static sk_sp<SkShader> make_shader1(int w, int h) { |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 36 | SkScalar cx = SkIntToScalar(w)/2; |
| 37 | SkScalar cy = SkIntToScalar(h)/2; |
| 38 | SkColor colors[] = { |
| 39 | SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, |
| 40 | }; |
reed | 1a9b964 | 2016-03-13 14:13:58 -0700 | [diff] [blame] | 41 | return SkGradientShader::MakeRadial(SkPoint::Make(cx, cy), cx, colors, nullptr, |
| 42 | SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode); |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 43 | } |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 44 | static void make_bm1(SkBitmap* bm) { |
| 45 | int W = 120; |
| 46 | int H = 120; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 47 | SkScalar cx = SkIntToScalar(W)/2; |
| 48 | SkScalar cy = SkIntToScalar(H)/2; |
reed@google.com | eb9a46c | 2014-01-25 16:46:20 +0000 | [diff] [blame] | 49 | bm->allocN32Pixels(W, H); |
junov@google.com | dbfac8a | 2012-12-06 21:47:40 +0000 | [diff] [blame] | 50 | bm->eraseColor(SK_ColorTRANSPARENT); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 51 | |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 52 | SkCanvas canvas(*bm); |
| 53 | SkPaint paint; |
reed | 1a9b964 | 2016-03-13 14:13:58 -0700 | [diff] [blame] | 54 | paint.setShader(make_shader1(W, H)); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 55 | paint.setAntiAlias(true); |
| 56 | canvas.drawCircle(cx, cy, cx, paint); |
| 57 | } |
| 58 | |
| 59 | static void make_table0(uint8_t table[]) { |
| 60 | for (int i = 0; i < 256; ++i) { |
| 61 | int n = i >> 5; |
| 62 | table[i] = (n << 5) | (n << 2) | (n >> 1); |
| 63 | } |
| 64 | } |
| 65 | static void make_table1(uint8_t table[]) { |
| 66 | for (int i = 0; i < 256; ++i) { |
| 67 | table[i] = i * i / 255; |
| 68 | } |
| 69 | } |
| 70 | static void make_table2(uint8_t table[]) { |
| 71 | for (int i = 0; i < 256; ++i) { |
| 72 | float fi = i / 255.0f; |
robertphillips@google.com | 6853e80 | 2012-04-16 15:50:18 +0000 | [diff] [blame] | 73 | table[i] = static_cast<uint8_t>(sqrtf(fi) * 255); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 74 | } |
| 75 | } |
| 76 | |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 77 | static sk_sp<SkColorFilter> make_null_cf() { |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 78 | return nullptr; |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 79 | } |
| 80 | |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 81 | static sk_sp<SkColorFilter> make_cf0() { |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 82 | uint8_t table[256]; make_table0(table); |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 83 | return SkTableColorFilter::Make(table); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 84 | } |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 85 | static sk_sp<SkColorFilter> make_cf1() { |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 86 | uint8_t table[256]; make_table1(table); |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 87 | return SkTableColorFilter::Make(table); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 88 | } |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 89 | static sk_sp<SkColorFilter> make_cf2() { |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 90 | uint8_t table[256]; make_table2(table); |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 91 | return SkTableColorFilter::Make(table); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 92 | } |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 93 | static sk_sp<SkColorFilter> make_cf3() { |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 94 | uint8_t table0[256]; make_table0(table0); |
| 95 | uint8_t table1[256]; make_table1(table1); |
| 96 | uint8_t table2[256]; make_table2(table2); |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 97 | return SkTableColorFilter::MakeARGB(nullptr, table0, table1, table2); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | class TableColorFilterGM : public skiagm::GM { |
| 101 | public: |
| 102 | TableColorFilterGM() {} |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 103 | |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 104 | protected: |
| 105 | virtual SkString onShortName() { |
| 106 | return SkString("tablecolorfilter"); |
| 107 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 108 | |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 109 | virtual SkISize onISize() { |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 110 | return SkISize::Make(700, 1650); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 111 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 112 | |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 113 | virtual void onDraw(SkCanvas* canvas) { |
caryclark | 1259601 | 2015-07-29 05:27:47 -0700 | [diff] [blame] | 114 | canvas->drawColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 115 | canvas->translate(20, 20); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 116 | |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 117 | |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 118 | static sk_sp<SkColorFilter> (*gColorFilterMakers[])() = { |
| 119 | make_null_cf, make_cf0, make_cf1, make_cf2, make_cf3 |
| 120 | }; |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 121 | static void (*gBitmapMakers[])(SkBitmap*) = { make_bm0, make_bm1 }; |
| 122 | |
| 123 | // This test will be done once for each bitmap with the results stacked vertically. |
| 124 | // For a single bitmap the resulting image will be the following: |
| 125 | // - A first line with the original bitmap, followed by the image drawn once |
| 126 | // with each of the N color filters |
| 127 | // - N lines of the bitmap drawn N times, this will cover all N*N combinations of |
| 128 | // pair of color filters in order to test the collpsing of consecutive table |
| 129 | // color filters. |
| 130 | // |
| 131 | // Here is a graphical representation of the result for 2 bitmaps and 2 filters |
| 132 | // with the number corresponding to the number of filters the bitmap goes through: |
| 133 | // |
| 134 | // --bitmap1 |
| 135 | // 011 |
| 136 | // 22 |
| 137 | // 22 |
| 138 | // --bitmap2 |
| 139 | // 011 |
| 140 | // 22 |
| 141 | // 22 |
| 142 | |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 143 | SkScalar x = 0, y = 0; |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 144 | for (size_t bitmapMaker = 0; bitmapMaker < SK_ARRAY_COUNT(gBitmapMakers); ++bitmapMaker) { |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 145 | SkBitmap bm; |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 146 | gBitmapMakers[bitmapMaker](&bm); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 147 | |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 148 | SkScalar xOffset = SkScalar(bm.width() * 9 / 8); |
| 149 | SkScalar yOffset = SkScalar(bm.height() * 9 / 8); |
| 150 | |
| 151 | // Draw the first element of the first line |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 152 | x = 0; |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 153 | SkPaint paint; |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 154 | canvas->drawBitmap(bm, x, y, &paint); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 155 | |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 156 | // Draws the rest of the first line for this bitmap |
| 157 | // each draw being at xOffset of the previous one |
| 158 | for (unsigned i = 1; i < SK_ARRAY_COUNT(gColorFilterMakers); ++i) { |
| 159 | x += xOffset; |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 160 | paint.setColorFilter(gColorFilterMakers[i]()); |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 161 | canvas->drawBitmap(bm, x, y, &paint); |
| 162 | } |
| 163 | |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 164 | paint.setColorFilter(nullptr); |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 165 | |
| 166 | for (unsigned i = 0; i < SK_ARRAY_COUNT(gColorFilterMakers); ++i) { |
robertphillips | 5605b56 | 2016-04-05 11:50:42 -0700 | [diff] [blame] | 167 | sk_sp<SkColorFilter> colorFilter1(gColorFilterMakers[i]()); |
| 168 | sk_sp<SkImageFilter> imageFilter1(SkColorFilterImageFilter::Make( |
| 169 | std::move(colorFilter1), nullptr)); |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 170 | |
| 171 | // Move down to the next line and draw it |
| 172 | // each draw being at xOffset of the previous one |
| 173 | y += yOffset; |
| 174 | x = 0; |
| 175 | for (unsigned j = 1; j < SK_ARRAY_COUNT(gColorFilterMakers); ++j) { |
robertphillips | 5605b56 | 2016-04-05 11:50:42 -0700 | [diff] [blame] | 176 | sk_sp<SkColorFilter> colorFilter2(gColorFilterMakers[j]()); |
| 177 | sk_sp<SkImageFilter> imageFilter2(SkColorFilterImageFilter::Make( |
| 178 | std::move(colorFilter2), imageFilter1, nullptr)); |
| 179 | paint.setImageFilter(std::move(imageFilter2)); |
cwallez | c12b74d | 2015-01-26 07:45:53 -0800 | [diff] [blame] | 180 | canvas->drawBitmap(bm, x, y, &paint); |
| 181 | x += xOffset; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | // Move down one line to the beginning of the block for next bitmap |
| 186 | y += yOffset; |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 187 | } |
| 188 | } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 189 | |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 190 | private: |
| 191 | typedef GM INHERITED; |
| 192 | }; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 193 | DEF_GM( return new TableColorFilterGM; ) |
mike@reedtribe.org | a69b48c | 2011-12-28 20:31:00 +0000 | [diff] [blame] | 194 | |
| 195 | ////////////////////////////////////////////////////////////////////////////// |
| 196 | |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 197 | class ComposeColorFilterGM : public skiagm::GM { |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 198 | enum { |
| 199 | COLOR_COUNT = 3, |
| 200 | MODE_COUNT = 4, |
| 201 | }; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 202 | const SkColor* fColors; |
| 203 | const SkBlendMode* fModes; |
| 204 | SkString fName; |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 205 | |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 206 | public: |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 207 | ComposeColorFilterGM(const SkColor colors[], const SkBlendMode modes[], |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 208 | const char suffix[]) |
| 209 | : fColors(colors), fModes(modes) |
| 210 | { |
| 211 | fName.printf("colorcomposefilter_%s", suffix); |
| 212 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 213 | |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 214 | protected: |
| 215 | virtual SkString onShortName() { |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 216 | return fName; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 217 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 218 | |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 219 | virtual SkISize onISize() { |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 220 | return SkISize::Make(790, 790); |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | virtual void onDraw(SkCanvas* canvas) { |
| 224 | SkBitmap bm; |
| 225 | make_bm1(&bm); |
| 226 | |
caryclark | 1259601 | 2015-07-29 05:27:47 -0700 | [diff] [blame] | 227 | canvas->drawColor(sk_tool_utils::color_to_565(0xFFDDDDDD)); |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 228 | |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 229 | const int MODES = MODE_COUNT * COLOR_COUNT; |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 230 | sk_sp<SkColorFilter> filters[MODES]; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 231 | int index = 0; |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 232 | for (int i = 0; i < MODE_COUNT; ++i) { |
| 233 | for (int j = 0; j < COLOR_COUNT; ++j) { |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 234 | filters[index++] = SkColorFilter::MakeModeFilter(fColors[j], fModes[i]); |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
| 238 | SkPaint paint; |
reed | 1a9b964 | 2016-03-13 14:13:58 -0700 | [diff] [blame] | 239 | paint.setShader(make_shader1(50, 50)); |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 240 | SkRect r = SkRect::MakeWH(50, 50); |
| 241 | const SkScalar spacer = 10; |
| 242 | |
| 243 | canvas->translate(spacer, spacer); |
| 244 | |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 245 | canvas->drawRect(r, paint); // orig |
| 246 | |
| 247 | for (int i = 0; i < MODES; ++i) { |
| 248 | paint.setColorFilter(filters[i]); |
| 249 | |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 250 | canvas->save(); |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 251 | canvas->translate((i + 1) * (r.width() + spacer), 0); |
| 252 | canvas->drawRect(r, paint); |
| 253 | canvas->restore(); |
| 254 | |
| 255 | canvas->save(); |
| 256 | canvas->translate(0, (i + 1) * (r.width() + spacer)); |
| 257 | canvas->drawRect(r, paint); |
| 258 | canvas->restore(); |
| 259 | } |
| 260 | |
| 261 | canvas->translate(r.width() + spacer, r.width() + spacer); |
| 262 | |
| 263 | for (int y = 0; y < MODES; ++y) { |
| 264 | canvas->save(); |
| 265 | for (int x = 0; x < MODES; ++x) { |
reed | d053ce9 | 2016-03-22 10:17:23 -0700 | [diff] [blame] | 266 | paint.setColorFilter(SkColorFilter::MakeComposeFilter(filters[y], filters[x])); |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 267 | canvas->drawRect(r, paint); |
| 268 | canvas->translate(r.width() + spacer, 0); |
| 269 | } |
| 270 | canvas->restore(); |
| 271 | canvas->translate(0, r.height() + spacer); |
| 272 | } |
| 273 | } |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 274 | |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 275 | private: |
| 276 | typedef GM INHERITED; |
| 277 | }; |
reed | db873d8 | 2015-03-01 19:53:47 -0800 | [diff] [blame] | 278 | |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 279 | const SkColor gColors0[] = { SK_ColorCYAN, SK_ColorMAGENTA, SK_ColorYELLOW }; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 280 | const SkBlendMode gModes0[] = { |
| 281 | SkBlendMode::kOverlay, |
| 282 | SkBlendMode::kDarken, |
| 283 | SkBlendMode::kColorBurn, |
| 284 | SkBlendMode::kExclusion, |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 285 | }; |
| 286 | DEF_GM( return new ComposeColorFilterGM(gColors0, gModes0, "wacky"); ) |
| 287 | |
| 288 | const SkColor gColors1[] = { 0x80FF0000, 0x8000FF00, 0x800000FF }; |
Mike Reed | 7d954ad | 2016-10-28 15:42:34 -0400 | [diff] [blame] | 289 | const SkBlendMode gModes1[] = { |
| 290 | SkBlendMode::kSrcOver, |
| 291 | SkBlendMode::kXor, |
| 292 | SkBlendMode::kDstOut, |
| 293 | SkBlendMode::kSrcATop, |
reed | cff10b2 | 2015-03-03 06:41:45 -0800 | [diff] [blame] | 294 | }; |
| 295 | DEF_GM( return new ComposeColorFilterGM(gColors1, gModes1, "alpha"); ) |