OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 SkShader* s2) { | 31 SkShader* s2) { |
32 SkPaint paint; | 32 SkPaint paint; |
33 paint.setAntiAlias(true); | 33 paint.setAntiAlias(true); |
34 SkRect r, c, bounds = SkRect::MakeWH(kSize, kSize); | 34 SkRect r, c, bounds = SkRect::MakeWH(kSize, kSize); |
35 | 35 |
36 c = bounds; | 36 c = bounds; |
37 c.fRight = bounds.centerX(); | 37 c.fRight = bounds.centerX(); |
38 paint.setARGB(0x20, 0, 0, 0xff); | 38 paint.setARGB(0x20, 0, 0, 0xff); |
39 canvas->drawRect(bounds, paint); | 39 canvas->drawRect(bounds, paint); |
40 | 40 |
41 canvas->saveLayer(&bounds, NULL); | 41 canvas->saveLayer(&bounds, nullptr); |
42 | 42 |
43 r = bounds; | 43 r = bounds; |
44 r.inset(kInset, 0); | 44 r.inset(kInset, 0); |
45 paint.setShader(s1); | 45 paint.setShader(s1); |
46 paint.setColor(s1 ? SK_ColorBLACK : SkColorSetA(kColor1, 0x80)); | 46 paint.setColor(s1 ? SK_ColorBLACK : SkColorSetA(kColor1, 0x80)); |
47 canvas->drawOval(r, paint); | 47 canvas->drawOval(r, paint); |
48 if (!s1) { | 48 if (!s1) { |
49 canvas->save(); | 49 canvas->save(); |
50 canvas->clipRect(c); | 50 canvas->clipRect(c); |
51 paint.setColor(kColor1); | 51 paint.setColor(kColor1); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 SkXfermode::kDstOver_Mode, | 112 SkXfermode::kDstOver_Mode, |
113 SkXfermode::kSrcATop_Mode, | 113 SkXfermode::kSrcATop_Mode, |
114 SkXfermode::kDstATop_Mode, | 114 SkXfermode::kDstATop_Mode, |
115 SkXfermode::kSrcIn_Mode, | 115 SkXfermode::kSrcIn_Mode, |
116 SkXfermode::kDstIn_Mode, | 116 SkXfermode::kDstIn_Mode, |
117 }; | 117 }; |
118 struct { | 118 struct { |
119 SkShader* fShader1; | 119 SkShader* fShader1; |
120 SkShader* fShader2; | 120 SkShader* fShader2; |
121 } shaders[] = { | 121 } shaders[] = { |
122 { NULL, NULL }, | 122 { nullptr, nullptr }, |
123 { NULL, fGr2 }, | 123 { nullptr, fGr2 }, |
124 { fGr1, NULL }, | 124 { fGr1, nullptr }, |
125 { fGr1, fGr2 }, | 125 { fGr1, fGr2 }, |
126 }; | 126 }; |
127 | 127 |
128 SkScalar gridStep = kSize + 2 * kInset; | 128 SkScalar gridStep = kSize + 2 * kInset; |
129 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) { | 129 for (size_t i = 0; i < SK_ARRAY_COUNT(modes); ++i) { |
130 draw_label(canvas, SkXfermode::ModeName(modes[i]), | 130 draw_label(canvas, SkXfermode::ModeName(modes[i]), |
131 SkPoint::Make(gridStep * (0.5f + i), 20)); | 131 SkPoint::Make(gridStep * (0.5f + i), 20)); |
132 } | 132 } |
133 | 133 |
134 for (size_t i = 0; i < SK_ARRAY_COUNT(shaders); ++i) { | 134 for (size_t i = 0; i < SK_ARRAY_COUNT(shaders); ++i) { |
(...skipping 11 matching lines...) Expand all Loading... |
146 private: | 146 private: |
147 SkAutoTUnref<SkColorFilter> fFilter; | 147 SkAutoTUnref<SkColorFilter> fFilter; |
148 SkAutoTUnref<SkShader> fGr1, fGr2; | 148 SkAutoTUnref<SkShader> fGr1, fGr2; |
149 | 149 |
150 typedef skiagm::GM INHERITED; | 150 typedef skiagm::GM INHERITED; |
151 }; | 151 }; |
152 | 152 |
153 ////////////////////////////////////////////////////////////////////////////// | 153 ////////////////////////////////////////////////////////////////////////////// |
154 | 154 |
155 DEF_GM(return new LumaFilterGM;) | 155 DEF_GM(return new LumaFilterGM;) |
OLD | NEW |