Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: gm/avoidxfermode3.cpp

Issue 1832223002: switch xfermodes over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 9
10 #include "SkAvoidXfermode.h" 10 #include "SkAvoidXfermode.h"
(...skipping 20 matching lines...) Expand all
31 p0.setAntiAlias(true); 31 p0.setAntiAlias(true);
32 32
33 canvas->drawRect(r, p0); 33 canvas->drawRect(r, p0);
34 34
35 r = SkRect::MakeXYWH(3.5f, 3.5f, 59.0f, 59.0f); 35 r = SkRect::MakeXYWH(3.5f, 3.5f, 59.0f, 59.0f);
36 36
37 // UL corner: replace white with green with a tight tolerance 37 // UL corner: replace white with green with a tight tolerance
38 SkPaint p1; 38 SkPaint p1;
39 p1.setColor(SK_ColorGREEN); 39 p1.setColor(SK_ColorGREEN);
40 p1.setAntiAlias(true); 40 p1.setAntiAlias(true);
41 p1.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE, 41 p1.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 5, SkAvoidXfermode:: kTargetColor_Mode));
42 5,
43 SkAvoidXfermode::kTargetColor_Mod e))->unref();
44 42
45 canvas->drawRect(r, p1); 43 canvas->drawRect(r, p1);
46 44
47 r.offsetTo(65.5f, 3.5f); 45 r.offsetTo(65.5f, 3.5f);
48 46
49 // UR corner: draw red everywhere except white with a tight tolerance 47 // UR corner: draw red everywhere except white with a tight tolerance
50 SkPaint p2; 48 SkPaint p2;
51 p2.setColor(SK_ColorRED); 49 p2.setColor(SK_ColorRED);
52 p2.setAntiAlias(true); 50 p2.setAntiAlias(true);
53 p2.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE, 51 p2.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 250,
54 250, 52 SkAvoidXfermode::kAvoidColor_Mode)) ;
55 SkAvoidXfermode::kAvoidColor_Mode ))->unref();
56 53
57 canvas->drawRect(r, p2); 54 canvas->drawRect(r, p2);
58 55
59 r.offsetTo(3.5f, 65.5f); 56 r.offsetTo(3.5f, 65.5f);
60 57
61 // LL corner: replace white with blue with a loose tolerance 58 // LL corner: replace white with blue with a loose tolerance
62 SkPaint p3; 59 SkPaint p3;
63 p3.setColor(SK_ColorBLUE); 60 p3.setColor(SK_ColorBLUE);
64 p3.setAntiAlias(true); 61 p3.setAntiAlias(true);
65 p3.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE, 62 p3.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 250,
66 250, 63 SkAvoidXfermode::kTargetColor_Mode) );
67 SkAvoidXfermode::kTargetColor_Mod e))->unref();
68 64
69 canvas->drawRect(r, p3); 65 canvas->drawRect(r, p3);
70 66
71 r.offsetTo(65.5f, 65.5f); 67 r.offsetTo(65.5f, 65.5f);
72 68
73 // LR corner: draw yellow everywhere except white with a loose tolerance 69 // LR corner: draw yellow everywhere except white with a loose tolerance
74 SkPaint p4; 70 SkPaint p4;
75 p4.setColor(SK_ColorYELLOW); 71 p4.setColor(SK_ColorYELLOW);
76 p4.setAntiAlias(true); 72 p4.setAntiAlias(true);
77 p4.setXfermode(SkAvoidXfermode::Create(SK_ColorWHITE, 73 p4.setXfermode(SkAvoidXfermode::Make(SK_ColorWHITE, 5, SkAvoidXfermode:: kAvoidColor_Mode));
78 5,
79 SkAvoidXfermode::kAvoidColor_Mode ))->unref();
80 74
81 canvas->drawRect(r, p4); 75 canvas->drawRect(r, p4);
82 } 76 }
83 77
84 private: 78 private:
85 typedef GM INHERITED; 79 typedef GM INHERITED;
86 }; 80 };
87 81
88 ////////////////////////////////////////////////////////////////////////////// 82 //////////////////////////////////////////////////////////////////////////////
89 83
90 DEF_GM(return new AvoidXfermode3GM;) 84 DEF_GM(return new AvoidXfermode3GM;)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698