OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkAvoidXfermode.h" | 9 #include "SkAvoidXfermode.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 p0.setColor(SK_ColorGREEN); | 28 p0.setColor(SK_ColorGREEN); |
29 p0.setAntiAlias(false); | 29 p0.setAntiAlias(false); |
30 | 30 |
31 canvas->drawRect(r, p0); | 31 canvas->drawRect(r, p0); |
32 | 32 |
33 r = SkRect::MakeIWH(64, 64); | 33 r = SkRect::MakeIWH(64, 64); |
34 | 34 |
35 // UL corner: replace the green with a tight tolerance | 35 // UL corner: replace the green with a tight tolerance |
36 SkPaint p1; | 36 SkPaint p1; |
37 p1.setColor(SK_ColorRED); | 37 p1.setColor(SK_ColorRED); |
38 p1.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN, | 38 p1.setXfermode(SkAvoidXfermode::Make(SK_ColorGREEN, 55, |
39 55, | 39 SkAvoidXfermode::kTargetColor_Mode)
); |
40 SkAvoidXfermode::kTargetColor_Mod
e))->unref(); | |
41 | 40 |
42 canvas->drawRect(r, p1); | 41 canvas->drawRect(r, p1); |
43 | 42 |
44 r.offsetTo(64, 0.0f); | 43 r.offsetTo(64, 0.0f); |
45 | 44 |
46 // UR corner: avoid the green with a tight tolerance | 45 // UR corner: avoid the green with a tight tolerance |
47 SkPaint p2; | 46 SkPaint p2; |
48 p2.setColor(SK_ColorRED); | 47 p2.setColor(SK_ColorRED); |
49 p2.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN, | 48 p2.setXfermode(SkAvoidXfermode::Make(SK_ColorGREEN, 200, |
50 200, | 49 SkAvoidXfermode::kAvoidColor_Mode))
; |
51 SkAvoidXfermode::kAvoidColor_Mode
))->unref(); | |
52 | 50 |
53 canvas->drawRect(r, p2); | 51 canvas->drawRect(r, p2); |
54 | 52 |
55 r.offsetTo(0.0f, 64); | 53 r.offsetTo(0.0f, 64); |
56 | 54 |
57 // LL corner: replace the green with a loose tolerance | 55 // LL corner: replace the green with a loose tolerance |
58 SkPaint p3; | 56 SkPaint p3; |
59 p3.setColor(SK_ColorRED); | 57 p3.setColor(SK_ColorRED); |
60 p3.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN, | 58 p3.setXfermode(SkAvoidXfermode::Make(SK_ColorGREEN, 200, |
61 200, | 59 SkAvoidXfermode::kTargetColor_Mode)
); |
62 SkAvoidXfermode::kTargetColor_Mod
e))->unref(); | |
63 | 60 |
64 canvas->drawRect(r, p3); | 61 canvas->drawRect(r, p3); |
65 | 62 |
66 r.offsetTo(64, 64); | 63 r.offsetTo(64, 64); |
67 | 64 |
68 // LR corner: avoid the green with a loose tolerance | 65 // LR corner: avoid the green with a loose tolerance |
69 SkPaint p4; | 66 SkPaint p4; |
70 p4.setColor(SK_ColorRED); | 67 p4.setColor(SK_ColorRED); |
71 p4.setXfermode(SkAvoidXfermode::Create(SK_ColorGREEN, | 68 p4.setXfermode(SkAvoidXfermode::Make(SK_ColorGREEN, 55, SkAvoidXfermode:
:kAvoidColor_Mode)); |
72 55, | |
73 SkAvoidXfermode::kAvoidColor_Mode
))->unref(); | |
74 | 69 |
75 canvas->drawRect(r, p4); | 70 canvas->drawRect(r, p4); |
76 } | 71 } |
77 | 72 |
78 private: | 73 private: |
79 typedef GM INHERITED; | 74 typedef GM INHERITED; |
80 }; | 75 }; |
81 | 76 |
82 ////////////////////////////////////////////////////////////////////////////// | 77 ////////////////////////////////////////////////////////////////////////////// |
83 | 78 |
84 DEF_GM(return new AvoidXfermode2GM;) | 79 DEF_GM(return new AvoidXfermode2GM;) |
OLD | NEW |