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" |
11 #include "SkGraphics.h" | 11 #include "SkGraphics.h" |
12 #include "SkRandom.h" | 12 #include "SkRandom.h" |
13 #include "SkDashPathEffect.h" | 13 #include "SkDashPathEffect.h" |
14 #include "SkShader.h" | 14 #include "SkShader.h" |
15 | 15 |
16 static void setBitmapDash(SkPaint* paint, int width) { | 16 static void setBitmapDash(SkPaint* paint, int width) { |
17 SkColor c = paint->getColor(); | 17 SkColor c = paint->getColor(); |
18 | 18 |
19 SkBitmap bm; | 19 SkBitmap bm; |
20 bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 1); | 20 bm.allocN32Pixels(2, 1); |
21 bm.allocPixels(); | |
22 bm.lockPixels(); | 21 bm.lockPixels(); |
23 *bm.getAddr32(0, 0) = SkPreMultiplyARGB(0xFF, SkColorGetR(c), | 22 *bm.getAddr32(0, 0) = SkPreMultiplyARGB(0xFF, SkColorGetR(c), |
24 SkColorGetG(c), SkColorGetB(c)); | 23 SkColorGetG(c), SkColorGetB(c)); |
25 *bm.getAddr32(1, 0) = 0; | 24 *bm.getAddr32(1, 0) = 0; |
26 bm.unlockPixels(); | 25 bm.unlockPixels(); |
27 | 26 |
28 SkMatrix matrix; | 27 SkMatrix matrix; |
29 matrix.setScale(SkIntToScalar(width), SK_Scalar1); | 28 matrix.setScale(SkIntToScalar(width), SK_Scalar1); |
30 | 29 |
31 SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, | 30 SkShader* s = SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 84 } |
86 | 85 |
87 private: | 86 private: |
88 typedef SampleView INHERITED; | 87 typedef SampleView INHERITED; |
89 }; | 88 }; |
90 | 89 |
91 ////////////////////////////////////////////////////////////////////////////// | 90 ////////////////////////////////////////////////////////////////////////////// |
92 | 91 |
93 static SkView* MyFactory() { return new DashView; } | 92 static SkView* MyFactory() { return new DashView; } |
94 static SkViewRegister reg(MyFactory); | 93 static SkViewRegister reg(MyFactory); |
OLD | NEW |