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 "Resources.h" | 9 #include "Resources.h" |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 SkPaint p2; | 60 SkPaint p2; |
61 p2.setColor(SK_ColorBLACK); | 61 p2.setColor(SK_ColorBLACK); |
62 p2.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE, | 62 p2.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE, |
63 250, | 63 250, |
64 SkAvoidXfermode::kAvoidColor_Mode
))->unref(); | 64 SkAvoidXfermode::kAvoidColor_Mode
))->unref(); |
65 | 65 |
66 canvas->drawRect(r, p2); | 66 canvas->drawRect(r, p2); |
67 | 67 |
68 r.offsetTo(0.0f, 64); | 68 r.offsetTo(0.0f, 64); |
69 | 69 |
70 // LL corner: replace red with blue with a loose tolerance | 70 // LL corner: replace red with transparent blue with a loose tolerance |
71 SkPaint p3; | 71 SkPaint p3; |
72 p3.setColor(SK_ColorBLUE); | 72 p3.setColor(0x7F0000FF); |
73 p3.setXfermode(SkAvoidXfermode::Create(SK_ColorRED, | 73 p3.setXfermode(SkAvoidXfermode::Create(SK_ColorRED, |
74 250, | 74 250, |
75 SkAvoidXfermode::kTargetColor_Mod
e))->unref(); | 75 SkAvoidXfermode::kTargetColor_Mod
e))->unref(); |
76 | 76 |
77 canvas->drawRect(r, p3); | 77 canvas->drawRect(r, p3); |
78 | 78 |
79 r.offsetTo(64, 64); | 79 r.offsetTo(64, 64); |
80 | 80 |
81 // LR corner: draw black everywhere except red with a loose tolerance | 81 // LR corner: draw black everywhere except red with a loose tolerance |
82 SkPaint p4; | 82 SkPaint p4; |
83 p4.setColor(SK_ColorBLACK); | 83 p4.setColor(SK_ColorBLACK); |
84 p4.setXfermode(SkAvoidXfermode::Create(SK_ColorRED, | 84 p4.setXfermode(SkAvoidXfermode::Create(SK_ColorRED, |
85 5, | 85 5, |
86 SkAvoidXfermode::kAvoidColor_Mode
))->unref(); | 86 SkAvoidXfermode::kAvoidColor_Mode
))->unref(); |
87 | 87 |
88 canvas->drawRect(r, p4); | 88 canvas->drawRect(r, p4); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 SkBitmap fBM; | 92 SkBitmap fBM; |
93 | 93 |
94 typedef GM INHERITED; | 94 typedef GM INHERITED; |
95 }; | 95 }; |
96 | 96 |
97 ////////////////////////////////////////////////////////////////////////////// | 97 ////////////////////////////////////////////////////////////////////////////// |
98 | 98 |
99 DEF_GM(return new AvoidXfermodeGM;) | 99 DEF_GM(return new AvoidXfermodeGM;) |
OLD | NEW |