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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 p.setAlpha(0x88); | 62 p.setAlpha(0x88); |
63 | 63 |
64 SkAutoCanvasRestore ar2(canvas, false); | 64 SkAutoCanvasRestore ar2(canvas, false); |
65 | 65 |
66 // create the layers | 66 // create the layers |
67 | 67 |
68 r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100)); | 68 r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100)); |
69 canvas->clipRect(r); | 69 canvas->clipRect(r); |
70 | 70 |
71 r.fBottom = SkIntToScalar(20); | 71 r.fBottom = SkIntToScalar(20); |
72 canvas->saveLayer(&r, NULL, (SkCanvas::SaveFlags)(SkCanvas::kHasAlphaLayer_S
aveFlag | SkCanvas::kFullColorLayer_SaveFlag)); | 72 canvas->saveLayer(&r, NULL); |
73 | 73 |
74 r.fTop = SkIntToScalar(80); | 74 r.fTop = SkIntToScalar(80); |
75 r.fBottom = SkIntToScalar(100); | 75 r.fBottom = SkIntToScalar(100); |
76 canvas->saveLayer(&r, NULL, (SkCanvas::SaveFlags)(SkCanvas::kHasAlphaLayer_S
aveFlag | SkCanvas::kFullColorLayer_SaveFlag)); | 76 canvas->saveLayer(&r, NULL); |
77 | 77 |
78 // now draw the "content" | 78 // now draw the "content" |
79 | 79 |
80 if (true) { | 80 if (true) { |
81 r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100)); | 81 r.set(0, 0, SkIntToScalar(100), SkIntToScalar(100)); |
82 | 82 |
83 canvas->saveLayerAlpha(&r, 0x80); | 83 canvas->saveLayerAlpha(&r, 0x80); |
84 | 84 |
85 SkPaint p; | 85 SkPaint p; |
86 p.setColor(SK_ColorRED); | 86 p.setColor(SK_ColorRED); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 SkPaint p; | 196 SkPaint p; |
197 p.setAlpha(0x88); | 197 p.setAlpha(0x88); |
198 p.setAntiAlias(true); | 198 p.setAntiAlias(true); |
199 | 199 |
200 canvas->translate(SkIntToScalar(300), 0); | 200 canvas->translate(SkIntToScalar(300), 0); |
201 | 201 |
202 SkRect r; | 202 SkRect r; |
203 r.set(SkIntToScalar(0), SkIntToScalar(0), | 203 r.set(SkIntToScalar(0), SkIntToScalar(0), |
204 SkIntToScalar(220), SkIntToScalar(60)); | 204 SkIntToScalar(220), SkIntToScalar(60)); |
205 | 205 |
206 canvas->saveLayer(&r, &p, (SkCanvas::SaveFlags)(SkCanvas::kHasAlphaL
ayer_SaveFlag | SkCanvas::kFullColorLayer_SaveFlag)); | 206 canvas->saveLayer(&r, &p); |
207 | 207 |
208 r.set(SkIntToScalar(0), SkIntToScalar(0), | 208 r.set(SkIntToScalar(0), SkIntToScalar(0), |
209 SkIntToScalar(220), SkIntToScalar(120)); | 209 SkIntToScalar(220), SkIntToScalar(120)); |
210 p.setColor(SK_ColorBLUE); | 210 p.setColor(SK_ColorBLUE); |
211 canvas->drawOval(r, p); | 211 canvas->drawOval(r, p); |
212 canvas->restore(); | 212 canvas->restore(); |
213 return; | 213 return; |
214 } | 214 } |
215 | 215 |
216 test_fade(canvas); | 216 test_fade(canvas); |
(...skipping 16 matching lines...) Expand all Loading... |
233 } | 233 } |
234 | 234 |
235 private: | 235 private: |
236 typedef SkView INHERITED; | 236 typedef SkView INHERITED; |
237 }; | 237 }; |
238 | 238 |
239 ////////////////////////////////////////////////////////////////////////////// | 239 ////////////////////////////////////////////////////////////////////////////// |
240 | 240 |
241 static SkView* MyFactory() { return new LayersView; } | 241 static SkView* MyFactory() { return new LayersView; } |
242 static SkViewRegister reg(MyFactory); | 242 static SkViewRegister reg(MyFactory); |
OLD | NEW |