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" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "SkColorFilter.h" | 21 #include "SkColorFilter.h" |
22 #include "SkTime.h" | 22 #include "SkTime.h" |
23 #include "SkTypeface.h" | 23 #include "SkTypeface.h" |
24 | 24 |
25 #include "SkOSFile.h" | 25 #include "SkOSFile.h" |
26 #include "SkStream.h" | 26 #include "SkStream.h" |
27 | 27 |
28 static SkShader* make_shader0(SkIPoint* size) { | 28 static SkShader* make_shader0(SkIPoint* size) { |
29 SkBitmap bm; | 29 SkBitmap bm; |
30 size->set(2, 2); | 30 size->set(2, 2); |
31 bm.setConfig(SkBitmap::kARGB_8888_Config, size->fX, size->fY); | |
32 SkPMColor color0 = SkPreMultiplyARGB(0x80, 0x80, 0xff, 0x80); | 31 SkPMColor color0 = SkPreMultiplyARGB(0x80, 0x80, 0xff, 0x80); |
33 SkPMColor color1 = SkPreMultiplyARGB(0x40, 0xff, 0x00, 0xff); | 32 SkPMColor color1 = SkPreMultiplyARGB(0x40, 0xff, 0x00, 0xff); |
34 bm.allocPixels(); | 33 bm.allocN32Pixels(size->fX, size->fY); |
35 bm.eraseColor(color0); | 34 bm.eraseColor(color0); |
36 bm.lockPixels(); | 35 bm.lockPixels(); |
37 uint32_t* pixels = (uint32_t*) bm.getPixels(); | 36 uint32_t* pixels = (uint32_t*) bm.getPixels(); |
38 pixels[0] = pixels[2] = color0; | 37 pixels[0] = pixels[2] = color0; |
39 pixels[1] = pixels[3] = color1; | 38 pixels[1] = pixels[3] = color1; |
40 bm.unlockPixels(); | 39 bm.unlockPixels(); |
41 | 40 |
42 return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, | 41 return SkShader::CreateBitmapShader(bm, SkShader::kRepeat_TileMode, |
43 SkShader::kRepeat_TileMode); | 42 SkShader::kRepeat_TileMode); |
44 } | 43 } |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 223 |
225 Rec fRecs[3]; | 224 Rec fRecs[3]; |
226 | 225 |
227 typedef SampleView INHERITED; | 226 typedef SampleView INHERITED; |
228 }; | 227 }; |
229 | 228 |
230 ////////////////////////////////////////////////////////////////////////////// | 229 ////////////////////////////////////////////////////////////////////////////// |
231 | 230 |
232 static SkView* MyFactory() { return new VerticesView; } | 231 static SkView* MyFactory() { return new VerticesView; } |
233 static SkViewRegister reg(MyFactory); | 232 static SkViewRegister reg(MyFactory); |
OLD | NEW |