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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 return this->INHERITED::onQuery(evt); | 28 return this->INHERITED::onQuery(evt); |
29 } | 29 } |
30 | 30 |
31 void drawMask(SkCanvas* canvas, const SkRect& r) { | 31 void drawMask(SkCanvas* canvas, const SkRect& r) { |
32 SkPaint paint; | 32 SkPaint paint; |
33 paint.setAntiAlias(true); | 33 paint.setAntiAlias(true); |
34 | 34 |
35 if (true) { | 35 if (true) { |
36 SkBitmap mask; | 36 SkBitmap mask; |
37 int w = SkScalarRound(r.width()); | 37 int w = SkScalarRoundToInt(r.width()); |
38 int h = SkScalarRound(r.height()); | 38 int h = SkScalarRoundToInt(r.height()); |
39 mask.setConfig(SkBitmap::kARGB_8888_Config, w, h); | 39 mask.setConfig(SkBitmap::kARGB_8888_Config, w, h); |
40 mask.allocPixels(); | 40 mask.allocPixels(); |
41 mask.eraseColor(SK_ColorTRANSPARENT); | 41 mask.eraseColor(SK_ColorTRANSPARENT); |
42 SkCanvas c(mask); | 42 SkCanvas c(mask); |
43 SkRect bounds = r; | 43 SkRect bounds = r; |
44 bounds.offset(-bounds.fLeft, -bounds.fTop); | 44 bounds.offset(-bounds.fLeft, -bounds.fTop); |
45 c.drawOval(bounds, paint); | 45 c.drawOval(bounds, paint); |
46 | 46 |
47 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); | 47 paint.setXfermodeMode(SkXfermode::kDstIn_Mode); |
48 canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint); | 48 canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint); |
(...skipping 16 matching lines...) Expand all Loading... |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 typedef SampleView INHERITED; | 68 typedef SampleView INHERITED; |
69 }; | 69 }; |
70 | 70 |
71 /////////////////////////////////////////////////////////////////////////////// | 71 /////////////////////////////////////////////////////////////////////////////// |
72 | 72 |
73 static SkView* MyFactory() { return new LayerMaskView; } | 73 static SkView* MyFactory() { return new LayerMaskView; } |
74 static SkViewRegister reg(MyFactory); | 74 static SkViewRegister reg(MyFactory); |
OLD | NEW |