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 15 matching lines...) Expand all Loading... |
26 CameraView() { | 26 CameraView() { |
27 fRX = fRY = fRZ = 0; | 27 fRX = fRY = fRZ = 0; |
28 fShaderIndex = 0; | 28 fShaderIndex = 0; |
29 fFrontFace = false; | 29 fFrontFace = false; |
30 | 30 |
31 for (int i = 0;; i++) { | 31 for (int i = 0;; i++) { |
32 SkString str; | 32 SkString str; |
33 str.printf("/skimages/elephant%d.jpeg", i); | 33 str.printf("/skimages/elephant%d.jpeg", i); |
34 SkBitmap bm; | 34 SkBitmap bm; |
35 if (SkImageDecoder::DecodeFile(str.c_str(), &bm)) { | 35 if (SkImageDecoder::DecodeFile(str.c_str(), &bm)) { |
36 SkShader* s = SkShader::CreateBitmapShader(bm, | |
37 SkShader::kClamp_Tile
Mode, | |
38 SkShader::kClamp_Tile
Mode); | |
39 | |
40 SkRect src = { 0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm
.height()) }; | 36 SkRect src = { 0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm
.height()) }; |
41 SkRect dst = { -150, -150, 150, 150 }; | 37 SkRect dst = { -150, -150, 150, 150 }; |
42 SkMatrix matrix; | 38 SkMatrix matrix; |
43 matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit); | 39 matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit); |
44 s->setLocalMatrix(matrix); | 40 |
| 41 SkShader* s = SkShader::CreateBitmapShader(bm, |
| 42 SkShader::kClamp_Tile
Mode, |
| 43 SkShader::kClamp_Tile
Mode, |
| 44 &matrix); |
45 *fShaders.append() = s; | 45 *fShaders.append() = s; |
46 } else { | 46 } else { |
47 break; | 47 break; |
48 } | 48 } |
49 } | 49 } |
50 this->setBGColor(0xFFDDDDDD); | 50 this->setBGColor(0xFFDDDDDD); |
51 } | 51 } |
52 | 52 |
53 virtual ~CameraView() { | 53 virtual ~CameraView() { |
54 fShaders.unrefAll(); | 54 fShaders.unrefAll(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 private: | 97 private: |
98 SkScalar fRX, fRY, fRZ; | 98 SkScalar fRX, fRY, fRZ; |
99 typedef SampleView INHERITED; | 99 typedef SampleView INHERITED; |
100 }; | 100 }; |
101 | 101 |
102 ////////////////////////////////////////////////////////////////////////////// | 102 ////////////////////////////////////////////////////////////////////////////// |
103 | 103 |
104 static SkView* MyFactory() { return new CameraView; } | 104 static SkView* MyFactory() { return new CameraView; } |
105 static SkViewRegister reg(MyFactory); | 105 static SkViewRegister reg(MyFactory); |
OLD | NEW |