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