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 "SkBlurMask.h" | 9 #include "SkBlurMask.h" |
10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkColorPriv.h" | 12 #include "SkColorPriv.h" |
13 #include "SkGradientShader.h" | 13 #include "SkGradientShader.h" |
14 #include "SkUtils.h" | 14 #include "SkUtils.h" |
15 #include "SkView.h" | 15 #include "SkView.h" |
16 | 16 |
17 static SkBitmap make_bitmap() { | 17 static SkBitmap make_bitmap() { |
18 SkPMColor c[256]; | 18 SkPMColor c[256]; |
19 for (int i = 0; i < 256; i++) { | 19 for (int i = 0; i < 256; i++) { |
20 c[i] = SkPackARGB32(255 - i, 0, 0, 0); | 20 c[i] = SkPackARGB32(255 - i, 0, 0, 0); |
21 } | 21 } |
22 | 22 |
23 SkBitmap bm; | 23 SkBitmap bm; |
24 SkColorTable* ctable = new SkColorTable(c, 256); | 24 SkColorTable* ctable = new SkColorTable(c, 256); |
25 | 25 |
26 bm.setConfig(SkBitmap::kIndex8_Config, 256, 256); | 26 bm.allocPixels(SkImageInfo::Make(256, 256, kIndex_8_SkColorType, |
27 bm.allocPixels(ctable); | 27 kPremul_SkAlphaType), |
| 28 NULL, ctable); |
28 ctable->unref(); | 29 ctable->unref(); |
29 | 30 |
30 bm.lockPixels(); | 31 bm.lockPixels(); |
31 const float cx = bm.width() * 0.5f; | 32 const float cx = bm.width() * 0.5f; |
32 const float cy = bm.height() * 0.5f; | 33 const float cy = bm.height() * 0.5f; |
33 for (int y = 0; y < bm.height(); y++) { | 34 for (int y = 0; y < bm.height(); y++) { |
34 float dy = y - cy; | 35 float dy = y - cy; |
35 dy *= dy; | 36 dy *= dy; |
36 uint8_t* p = bm.getAddr8(0, y); | 37 uint8_t* p = bm.getAddr8(0, y); |
37 for (int x = 0; x < 256; x++) { | 38 for (int x = 0; x < 256; x++) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } | 133 } |
133 | 134 |
134 private: | 135 private: |
135 typedef SkView INHERITED; | 136 typedef SkView INHERITED; |
136 }; | 137 }; |
137 | 138 |
138 ////////////////////////////////////////////////////////////////////////////// | 139 ////////////////////////////////////////////////////////////////////////////// |
139 | 140 |
140 static SkView* MyFactory() { return new BlurView; } | 141 static SkView* MyFactory() { return new BlurView; } |
141 static SkViewRegister reg(MyFactory); | 142 static SkViewRegister reg(MyFactory); |
OLD | NEW |