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 "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 path.getBounds().round(&bounds); | 50 path.getBounds().round(&bounds); |
51 SkRegion clip(bounds); | 51 SkRegion clip(bounds); |
52 return region.setPath(path, clip); // <-- !! DOWN !! | 52 return region.setPath(path, clip); // <-- !! DOWN !! |
53 } | 53 } |
54 | 54 |
55 static SkBitmap make_bitmap() { | 55 static SkBitmap make_bitmap() { |
56 SkPMColor c[256]; | 56 SkPMColor c[256]; |
57 for (int i = 0; i < 256; i++) { | 57 for (int i = 0; i < 256; i++) { |
58 c[i] = SkPackARGB32(0xFF, i, 0, 0); | 58 c[i] = SkPackARGB32(0xFF, i, 0, 0); |
59 } | 59 } |
60 SkColorTable* ctable = new SkColorTable(c, 256, kOpaque_SkAlphaType); | 60 SkColorTable* ctable = new SkColorTable(c, 256); |
61 | 61 |
62 SkBitmap bm; | 62 SkBitmap bm; |
63 bm.allocPixels(SkImageInfo::Make(256, 32, kIndex_8_SkColorType, | 63 bm.allocPixels(SkImageInfo::Make(256, 32, kIndex_8_SkColorType, kPremul_SkAl
phaType), |
64 kPremul_SkAlphaType), | |
65 NULL, ctable); | 64 NULL, ctable); |
66 ctable->unref(); | 65 ctable->unref(); |
67 | 66 |
68 bm.lockPixels(); | 67 bm.lockPixels(); |
69 for (int y = 0; y < bm.height(); y++) { | 68 for (int y = 0; y < bm.height(); y++) { |
70 uint8_t* p = bm.getAddr8(0, y); | 69 uint8_t* p = bm.getAddr8(0, y); |
71 for (int x = 0; x < 256; x++) { | 70 for (int x = 0; x < 256; x++) { |
72 p[x] = x; | 71 p[x] = x; |
73 } | 72 } |
74 } | 73 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 141 } |
143 | 142 |
144 private: | 143 private: |
145 typedef SampleView INHERITED; | 144 typedef SampleView INHERITED; |
146 }; | 145 }; |
147 | 146 |
148 ////////////////////////////////////////////////////////////////////////////// | 147 ////////////////////////////////////////////////////////////////////////////// |
149 | 148 |
150 static SkView* MyFactory() { return new DitherBitmapView; } | 149 static SkView* MyFactory() { return new DitherBitmapView; } |
151 static SkViewRegister reg(MyFactory); | 150 static SkViewRegister reg(MyFactory); |
OLD | NEW |