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 "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
10 #include "SkShader.h" | 10 #include "SkShader.h" |
11 #include "SkView.h" | 11 #include "SkView.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkUtils.h" | 13 #include "SkUtils.h" |
14 | 14 |
15 static SkBitmap make_bitmap() { | 15 static SkBitmap make_bitmap() { |
16 const int N = 1; | 16 const int N = 1; |
17 | 17 |
18 SkPMColor c[N]; | 18 SkPMColor c[N]; |
19 for (int i = 0; i < N; i++) { | 19 for (int i = 0; i < N; i++) { |
20 c[i] = SkPackARGB32(0x80, 0x80, 0, 0); | 20 c[i] = SkPackARGB32(0x80, 0x80, 0, 0); |
21 } | 21 } |
22 SkColorTable* ctable = new SkColorTable(c, N); | 22 SkColorTable* ctable = new SkColorTable(c, N); |
23 | 23 |
24 SkBitmap bm; | 24 SkBitmap bm; |
25 bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType, | 25 bm.allocPixels(SkImageInfo::Make(1, 1, kIndex_8_SkColorType, |
26 kPremul_SkAlphaType), | 26 kPremul_SkAlphaType), |
27 NULL, ctable); | 27 nullptr, ctable); |
28 ctable->unref(); | 28 ctable->unref(); |
29 | 29 |
30 bm.lockPixels(); | 30 bm.lockPixels(); |
31 for (int y = 0; y < bm.height(); y++) { | 31 for (int y = 0; y < bm.height(); y++) { |
32 uint8_t* p = bm.getAddr8(0, y); | 32 uint8_t* p = bm.getAddr8(0, y); |
33 for (int x = 0; x < bm.width(); x++) { | 33 for (int x = 0; x < bm.width(); x++) { |
34 p[x] = 0; | 34 p[x] = 0; |
35 } | 35 } |
36 } | 36 } |
37 bm.unlockPixels(); | 37 bm.unlockPixels(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 | 71 |
72 private: | 72 private: |
73 typedef SkView INHERITED; | 73 typedef SkView INHERITED; |
74 }; | 74 }; |
75 | 75 |
76 ////////////////////////////////////////////////////////////////////////////// | 76 ////////////////////////////////////////////////////////////////////////////// |
77 | 77 |
78 static SkView* MyFactory() { return new TinyBitmapView; } | 78 static SkView* MyFactory() { return new TinyBitmapView; } |
79 static SkViewRegister reg(MyFactory); | 79 static SkViewRegister reg(MyFactory); |
OLD | NEW |