OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
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 12 matching lines...) Expand all Loading... |
23 #include "SkTime.h" | 23 #include "SkTime.h" |
24 #include "SkTypeface.h" | 24 #include "SkTypeface.h" |
25 #include "SkUtils.h" | 25 #include "SkUtils.h" |
26 #include "SkKey.h" | 26 #include "SkKey.h" |
27 #include "SkXfermode.h" | 27 #include "SkXfermode.h" |
28 #include "SkDrawFilter.h" | 28 #include "SkDrawFilter.h" |
29 | 29 |
30 static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) { | 30 static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) { |
31 SkColor colors[] = { 0, SK_ColorWHITE }; | 31 SkColor colors[] = { 0, SK_ColorWHITE }; |
32 SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } }; | 32 SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } }; |
33 SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader:
:kClamp_TileMode, | 33 SkShader* s = SkGradientShader::CreateLinear(pts, colors, nullptr, 2, SkShad
er::kClamp_TileMode, |
34 0, &localMatrix); | 34 0, &localMatrix); |
35 | 35 |
36 paint->setShader(s)->unref(); | 36 paint->setShader(s)->unref(); |
37 paint->setXfermodeMode(SkXfermode::kDstIn_Mode); | 37 paint->setXfermodeMode(SkXfermode::kDstIn_Mode); |
38 } | 38 } |
39 | 39 |
40 static void dump_layers(const char label[], SkCanvas* canvas) { | 40 static void dump_layers(const char label[], SkCanvas* canvas) { |
41 SkDebugf("Dump Layers(%s)\n", label); | 41 SkDebugf("Dump Layers(%s)\n", label); |
42 | 42 |
43 SkCanvas::LayerIter iter(canvas, true); | 43 SkCanvas::LayerIter iter(canvas, true); |
(...skipping 19 matching lines...) Expand all Loading... |
63 p.setAlpha(0x88); | 63 p.setAlpha(0x88); |
64 | 64 |
65 SkAutoCanvasRestore ar2(canvas, false); | 65 SkAutoCanvasRestore ar2(canvas, false); |
66 | 66 |
67 // create the layers | 67 // create the layers |
68 | 68 |
69 r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100)); | 69 r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100)); |
70 canvas->clipRect(r); | 70 canvas->clipRect(r); |
71 | 71 |
72 r.fBottom = SkIntToScalar(20); | 72 r.fBottom = SkIntToScalar(20); |
73 canvas->saveLayer(&r, NULL); | 73 canvas->saveLayer(&r, nullptr); |
74 | 74 |
75 r.fTop = SkIntToScalar(80); | 75 r.fTop = SkIntToScalar(80); |
76 r.fBottom = SkIntToScalar(100); | 76 r.fBottom = SkIntToScalar(100); |
77 canvas->saveLayer(&r, NULL); | 77 canvas->saveLayer(&r, nullptr); |
78 | 78 |
79 // now draw the "content" | 79 // now draw the "content" |
80 | 80 |
81 if (true) { | 81 if (true) { |
82 r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100)); | 82 r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100)); |
83 | 83 |
84 canvas->saveLayerAlpha(&r, 0x80); | 84 canvas->saveLayerAlpha(&r, 0x80); |
85 | 85 |
86 SkPaint p; | 86 SkPaint p; |
87 p.setColor(SK_ColorRED); | 87 p.setColor(SK_ColorRED); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 p.setColor(SK_ColorBLUE); | 208 p.setColor(SK_ColorBLUE); |
209 canvas->drawOval(r, p); | 209 canvas->drawOval(r, p); |
210 canvas->restore(); | 210 canvas->restore(); |
211 return; | 211 return; |
212 } | 212 } |
213 | 213 |
214 test_fade(canvas); | 214 test_fade(canvas); |
215 } | 215 } |
216 | 216 |
217 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { | 217 SkView::Click* onFindClickHandler(SkScalar x, SkScalar y, unsigned modi) ove
rride { |
218 this->inval(NULL); | 218 this->inval(nullptr); |
219 | 219 |
220 return this->INHERITED::onFindClickHandler(x, y, modi); | 220 return this->INHERITED::onFindClickHandler(x, y, modi); |
221 } | 221 } |
222 | 222 |
223 bool onClick(Click* click) override { | 223 bool onClick(Click* click) override { |
224 return this->INHERITED::onClick(click); | 224 return this->INHERITED::onClick(click); |
225 } | 225 } |
226 | 226 |
227 virtual bool handleKey(SkKey) { | 227 virtual bool handleKey(SkKey) { |
228 this->inval(NULL); | 228 this->inval(nullptr); |
229 return true; | 229 return true; |
230 } | 230 } |
231 | 231 |
232 private: | 232 private: |
233 typedef SkView INHERITED; | 233 typedef SkView INHERITED; |
234 }; | 234 }; |
235 | 235 |
236 ////////////////////////////////////////////////////////////////////////////// | 236 ////////////////////////////////////////////////////////////////////////////// |
237 | 237 |
238 static SkView* MyFactory() { return new LayersView; } | 238 static SkView* MyFactory() { return new LayersView; } |
239 static SkViewRegister reg(MyFactory); | 239 static SkViewRegister reg(MyFactory); |
OLD | NEW |