| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24)
* gHeight; | 55 SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24)
* gHeight; |
| 56 paint.setStrokeWidth(SK_Scalar1 * angle * 2 / 24); | 56 paint.setStrokeWidth(SK_Scalar1 * angle * 2 / 24); |
| 57 canvas->drawLine(W/2, H/2, W/2 + x, H/2 + y, paint); | 57 canvas->drawLine(W/2, H/2, W/2 + x, H/2 + y, paint); |
| 58 } | 58 } |
| 59 | 59 |
| 60 return H; | 60 return H; |
| 61 } | 61 } |
| 62 | 62 |
| 63 static SkShader* make_bg_shader() { | 63 static SkShader* make_bg_shader() { |
| 64 SkBitmap bm; | 64 SkBitmap bm; |
| 65 bm.setConfig(SkBitmap::kARGB_8888_Config, 2, 2); | 65 bm.allocN32Pixels(2, 2); |
| 66 bm.allocPixels(); | |
| 67 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF; | 66 *bm.getAddr32(0, 0) = *bm.getAddr32(1, 1) = 0xFFFFFFFF; |
| 68 *bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCC, 0xCC, 0
xCC); | 67 *bm.getAddr32(1, 0) = *bm.getAddr32(0, 1) = SkPackARGB32(0xFF, 0xCC, 0xCC, 0
xCC); |
| 69 | 68 |
| 70 SkShader* s = SkShader::CreateBitmapShader(bm, | 69 SkShader* s = SkShader::CreateBitmapShader(bm, |
| 71 SkShader::kRepeat_TileMode, | 70 SkShader::kRepeat_TileMode, |
| 72 SkShader::kRepeat_TileMode); | 71 SkShader::kRepeat_TileMode); |
| 73 | 72 |
| 74 SkMatrix m; | 73 SkMatrix m; |
| 75 m.setScale(SkIntToScalar(6), SkIntToScalar(6)); | 74 m.setScale(SkIntToScalar(6), SkIntToScalar(6)); |
| 76 s->setLocalMatrix(m); | 75 s->setLocalMatrix(m); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 127 } |
| 129 | 128 |
| 130 private: | 129 private: |
| 131 typedef SampleView INHERITED; | 130 typedef SampleView INHERITED; |
| 132 }; | 131 }; |
| 133 | 132 |
| 134 /////////////////////////////////////////////////////////////////////////////// | 133 /////////////////////////////////////////////////////////////////////////////// |
| 135 | 134 |
| 136 static SkView* MyFactory() { return new HairModesView; } | 135 static SkView* MyFactory() { return new HairModesView; } |
| 137 static SkViewRegister reg(MyFactory); | 136 static SkViewRegister reg(MyFactory); |
| OLD | NEW |