mtklein | 4afe21e | 2015-04-17 06:32:13 -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 | |
| 8 | #include "gm.h" |
Mike Klein | 33d2055 | 2017-03-22 13:47:51 -0400 | [diff] [blame] | 9 | #include "sk_tool_utils.h" |
mtklein | 4afe21e | 2015-04-17 06:32:13 -0700 | [diff] [blame] | 10 | |
| 11 | DEF_SIMPLE_GM(blend, canvas, 300, 100) { |
| 12 | SkPaint p; |
| 13 | |
| 14 | // All three of these blocks should be the same color. |
| 15 | canvas->save(); |
| 16 | canvas->scale(100,100); |
| 17 | |
| 18 | p.setColor(SK_ColorRED); |
| 19 | canvas->drawRect(SkRect::MakeXYWH(0,0,1,1), p); |
lsalzman | 40254c2 | 2016-08-05 11:48:45 -0700 | [diff] [blame] | 20 | p.setColor(0xFC208000); |
mtklein | 4afe21e | 2015-04-17 06:32:13 -0700 | [diff] [blame] | 21 | canvas->drawRect(SkRect::MakeXYWH(0,0,1,1), p); |
| 22 | |
| 23 | p.setColor(SK_ColorRED); |
| 24 | canvas->drawRect(SkRect::MakeXYWH(1,0,1,1), p); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 25 | canvas->saveLayer(nullptr, nullptr); |
lsalzman | 40254c2 | 2016-08-05 11:48:45 -0700 | [diff] [blame] | 26 | p.setColor(0xFC208000); |
mtklein | 4afe21e | 2015-04-17 06:32:13 -0700 | [diff] [blame] | 27 | canvas->drawRect(SkRect::MakeXYWH(1,0,1,1), p); |
| 28 | canvas->restore(); |
| 29 | |
| 30 | p.setColor(SK_ColorRED); |
| 31 | canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p); |
halcanary | 96fcdcc | 2015-08-27 07:41:13 -0700 | [diff] [blame] | 32 | canvas->saveLayerAlpha(nullptr, 0xFC); |
lsalzman | 40254c2 | 2016-08-05 11:48:45 -0700 | [diff] [blame] | 33 | p.setColor(sk_tool_utils::color_to_565(0xFF208000)); |
mtklein | 4afe21e | 2015-04-17 06:32:13 -0700 | [diff] [blame] | 34 | canvas->drawRect(SkRect::MakeXYWH(2,0,1,1), p); |
| 35 | canvas->restore(); |
| 36 | canvas->restore(); |
mtklein | 4afe21e | 2015-04-17 06:32:13 -0700 | [diff] [blame] | 37 | } |