blob: a20f19cff5f24ca0e40beed845e4b196636f76a3 [file] [log] [blame]
mtklein4afe21e2015-04-17 06:32:13 -07001/*
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 Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
Ben Wagner6a34f3a2019-05-01 10:59:30 -04009#include "include/core/SkCanvas.h"
10#include "include/core/SkColor.h"
11#include "include/core/SkPaint.h"
12#include "include/core/SkRect.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050013#include "tools/ToolUtils.h"
mtklein4afe21e2015-04-17 06:32:13 -070014
15DEF_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);
lsalzman40254c22016-08-05 11:48:45 -070024 p.setColor(0xFC208000);
mtklein4afe21e2015-04-17 06:32:13 -070025 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);
halcanary96fcdcc2015-08-27 07:41:13 -070029 canvas->saveLayer(nullptr, nullptr);
lsalzman40254c22016-08-05 11:48:45 -070030 p.setColor(0xFC208000);
mtklein4afe21e2015-04-17 06:32:13 -070031 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);
halcanary96fcdcc2015-08-27 07:41:13 -070036 canvas->saveLayerAlpha(nullptr, 0xFC);
Mike Kleinea3f0142019-03-20 11:12:10 -050037 p.setColor(ToolUtils::color_to_565(0xFF208000));
38 canvas->drawRect(SkRect::MakeXYWH(2, 0, 1, 1), p);
mtklein4afe21e2015-04-17 06:32:13 -070039 canvas->restore();
40 canvas->restore();
mtklein4afe21e2015-04-17 06:32:13 -070041}