OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "SkUtils.h" | 24 #include "SkUtils.h" |
25 #include "SkKey.h" | 25 #include "SkKey.h" |
26 #include "SkXfermode.h" | 26 #include "SkXfermode.h" |
27 #include "SkDrawFilter.h" | 27 #include "SkDrawFilter.h" |
28 | 28 |
29 static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) { | 29 static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) { |
30 SkColor colors[] = { 0, SK_ColorWHITE }; | 30 SkColor colors[] = { 0, SK_ColorWHITE }; |
31 SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } }; | 31 SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } }; |
32 paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, | 32 paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, |
33 SkShader::kClamp_TileMode, 0,
&localMatrix)); | 33 SkShader::kClamp_TileMode, 0,
&localMatrix)); |
34 paint->setXfermodeMode(SkXfermode::kDstIn_Mode); | 34 paint->setBlendMode(SkBlendMode::kDstIn); |
35 } | 35 } |
36 | 36 |
37 // test drawing with strips of fading gradient above and below | 37 // test drawing with strips of fading gradient above and below |
38 static void test_fade(SkCanvas* canvas) { | 38 static void test_fade(SkCanvas* canvas) { |
39 SkAutoCanvasRestore ar(canvas, true); | 39 SkAutoCanvasRestore ar(canvas, true); |
40 | 40 |
41 SkRect r; | 41 SkRect r; |
42 | 42 |
43 SkPaint p; | 43 SkPaint p; |
44 p.setAlpha(0x88); | 44 p.setAlpha(0x88); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 this->drawBG(canvas); | 134 this->drawBG(canvas); |
135 | 135 |
136 if (true) { | 136 if (true) { |
137 SkRect r; | 137 SkRect r; |
138 r.set(SkIntToScalar(0), SkIntToScalar(0), | 138 r.set(SkIntToScalar(0), SkIntToScalar(0), |
139 SkIntToScalar(220), SkIntToScalar(120)); | 139 SkIntToScalar(220), SkIntToScalar(120)); |
140 SkPaint p; | 140 SkPaint p; |
141 canvas->saveLayer(&r, &p); | 141 canvas->saveLayer(&r, &p); |
142 canvas->drawColor(0xFFFF0000); | 142 canvas->drawColor(0xFFFF0000); |
143 p.setAlpha(0); // or 0 | 143 p.setAlpha(0); // or 0 |
144 p.setXfermodeMode(SkXfermode::kSrc_Mode); | 144 p.setBlendMode(SkBlendMode::kSrc); |
145 canvas->drawOval(r, p); | 145 canvas->drawOval(r, p); |
146 canvas->restore(); | 146 canvas->restore(); |
147 return; | 147 return; |
148 } | 148 } |
149 | 149 |
150 if (false) { | 150 if (false) { |
151 SkRect r; | 151 SkRect r; |
152 r.set(SkIntToScalar(0), SkIntToScalar(0), | 152 r.set(SkIntToScalar(0), SkIntToScalar(0), |
153 SkIntToScalar(220), SkIntToScalar(120)); | 153 SkIntToScalar(220), SkIntToScalar(120)); |
154 SkPaint p; | 154 SkPaint p; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 bool onClick(Click* click) override { | 278 bool onClick(Click* click) override { |
279 this->inval(nullptr); | 279 this->inval(nullptr); |
280 fCenter = click->fCurr; | 280 fCenter = click->fCurr; |
281 return this->INHERITED::onClick(click); | 281 return this->INHERITED::onClick(click); |
282 } | 282 } |
283 | 283 |
284 private: | 284 private: |
285 typedef SampleView INHERITED; | 285 typedef SampleView INHERITED; |
286 }; | 286 }; |
287 DEF_SAMPLE( return new BackdropView; ) | 287 DEF_SAMPLE( return new BackdropView; ) |
OLD | NEW |