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 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 void onDraw(SkCanvas* canvas) override { | 32 void onDraw(SkCanvas* canvas) override { |
33 canvas->drawBitmap(fBM, 0, 0); | 33 canvas->drawBitmap(fBM, 0, 0); |
34 | 34 |
35 SkRect r = SkRect::MakeIWH(64, 64); | 35 SkRect r = SkRect::MakeIWH(64, 64); |
36 | 36 |
37 // UL corner: replace white with black with a tight tolerance | 37 // UL corner: replace white with black with a tight tolerance |
38 SkPaint p1; | 38 SkPaint p1; |
39 p1.setColor(SK_ColorBLACK); | 39 p1.setColor(SK_ColorBLACK); |
40 p1.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE, | 40 p1.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 5, SkAvoidXfermode::
kTargetColor_Mode)); |
41 5, | |
42 SkAvoidXfermode::kTargetColor_Mod
e))->unref(); | |
43 | 41 |
44 canvas->drawRect(r, p1); | 42 canvas->drawRect(r, p1); |
45 | 43 |
46 r.offsetTo(64, 0.0f); | 44 r.offsetTo(64, 0.0f); |
47 | 45 |
48 // UR corner: draw black everywhere except white with a tight tolerance | 46 // UR corner: draw black everywhere except white with a tight tolerance |
49 SkPaint p2; | 47 SkPaint p2; |
50 p2.setColor(SK_ColorBLACK); | 48 p2.setColor(SK_ColorBLACK); |
51 p2.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE, | 49 p2.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 250, |
52 250, | 50 SkAvoidXfermode::kAvoidColor_Mode))
; |
53 SkAvoidXfermode::kAvoidColor_Mode
))->unref(); | |
54 | 51 |
55 canvas->drawRect(r, p2); | 52 canvas->drawRect(r, p2); |
56 | 53 |
57 r.offsetTo(0.0f, 64); | 54 r.offsetTo(0.0f, 64); |
58 | 55 |
59 // LL corner: replace red with transparent blue with a loose tolerance | 56 // LL corner: replace red with transparent blue with a loose tolerance |
60 SkPaint p3; | 57 SkPaint p3; |
61 p3.setColor(0x7F0000FF); | 58 p3.setColor(0x7F0000FF); |
62 p3.setXfermode(SkAvoidXfermode::Create(SK_ColorRED, | 59 p3.setXfermode(SkAvoidXfermode::Make(SK_ColorRED, 250, SkAvoidXfermode::
kTargetColor_Mode)); |
63 250, | |
64 SkAvoidXfermode::kTargetColor_Mod
e))->unref(); | |
65 | 60 |
66 canvas->drawRect(r, p3); | 61 canvas->drawRect(r, p3); |
67 | 62 |
68 r.offsetTo(64, 64); | 63 r.offsetTo(64, 64); |
69 | 64 |
70 // LR corner: draw black everywhere except red with a loose tolerance | 65 // LR corner: draw black everywhere except red with a loose tolerance |
71 SkPaint p4; | 66 SkPaint p4; |
72 p4.setColor(SK_ColorBLACK); | 67 p4.setColor(SK_ColorBLACK); |
73 p4.setXfermode(SkAvoidXfermode::Create(SK_ColorRED, | 68 p4.setXfermode(SkAvoidXfermode::Make(SK_ColorRED, 5, SkAvoidXfermode::kA
voidColor_Mode)); |
74 5, | |
75 SkAvoidXfermode::kAvoidColor_Mode
))->unref(); | |
76 | 69 |
77 canvas->drawRect(r, p4); | 70 canvas->drawRect(r, p4); |
78 } | 71 } |
79 | 72 |
80 private: | 73 private: |
81 SkBitmap fBM; | 74 SkBitmap fBM; |
82 | 75 |
83 typedef GM INHERITED; | 76 typedef GM INHERITED; |
84 }; | 77 }; |
85 | 78 |
86 ////////////////////////////////////////////////////////////////////////////// | 79 ////////////////////////////////////////////////////////////////////////////// |
87 | 80 |
88 DEF_GM(return new AvoidXfermodeGM;) | 81 DEF_GM(return new AvoidXfermodeGM;) |
OLD | NEW |