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 "DecodeFile.h" |
8 #include "SampleCode.h" | 9 #include "SampleCode.h" |
9 #include "SkAnimTimer.h" | 10 #include "SkAnimTimer.h" |
10 #include "SkView.h" | 11 #include "SkView.h" |
11 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
12 #include "SkCamera.h" | 13 #include "SkCamera.h" |
13 #include "SkEmbossMaskFilter.h" | 14 #include "SkEmbossMaskFilter.h" |
14 #include "SkGradientShader.h" | 15 #include "SkGradientShader.h" |
15 #include "SkPath.h" | 16 #include "SkPath.h" |
16 #include "SkRegion.h" | 17 #include "SkRegion.h" |
17 #include "SkShader.h" | 18 #include "SkShader.h" |
18 #include "SkUtils.h" | 19 #include "SkUtils.h" |
19 #include "SkRandom.h" | 20 #include "SkRandom.h" |
20 #include "SkImageDecoder.h" | |
21 | 21 |
22 class CameraView : public SampleView { | 22 class CameraView : public SampleView { |
23 SkTDArray<SkShader*> fShaders; | 23 SkTDArray<SkShader*> fShaders; |
24 int fShaderIndex; | 24 int fShaderIndex; |
25 bool fFrontFace; | 25 bool fFrontFace; |
26 public: | 26 public: |
27 CameraView() { | 27 CameraView() { |
28 fRX = fRY = fRZ = 0; | 28 fRX = fRY = fRZ = 0; |
29 fShaderIndex = 0; | 29 fShaderIndex = 0; |
30 fFrontFace = false; | 30 fFrontFace = false; |
31 | 31 |
32 for (int i = 0;; i++) { | 32 for (int i = 0;; i++) { |
33 SkString str; | 33 SkString str; |
34 str.printf("/skimages/elephant%d.jpeg", i); | 34 str.printf("/skimages/elephant%d.jpeg", i); |
35 SkBitmap bm; | 35 SkBitmap bm; |
36 if (SkImageDecoder::DecodeFile(str.c_str(), &bm)) { | 36 if (decode_file(str.c_str(), &bm)) { |
37 SkRect src = { 0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm
.height()) }; | 37 SkRect src = { 0, 0, SkIntToScalar(bm.width()), SkIntToScalar(bm
.height()) }; |
38 SkRect dst = { -150, -150, 150, 150 }; | 38 SkRect dst = { -150, -150, 150, 150 }; |
39 SkMatrix matrix; | 39 SkMatrix matrix; |
40 matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit); | 40 matrix.setRectToRect(src, dst, SkMatrix::kFill_ScaleToFit); |
41 | 41 |
42 SkShader* s = SkShader::MakeBitmapShader(bm, | 42 SkShader* s = SkShader::MakeBitmapShader(bm, |
43 SkShader::kClamp_Tile
Mode, | 43 SkShader::kClamp_Tile
Mode, |
44 SkShader::kClamp_Tile
Mode, | 44 SkShader::kClamp_Tile
Mode, |
45 &matrix).release(); | 45 &matrix).release(); |
46 *fShaders.append() = s; | 46 *fShaders.append() = s; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 private: | 101 private: |
102 SkScalar fRX, fRY, fRZ; | 102 SkScalar fRX, fRY, fRZ; |
103 typedef SampleView INHERITED; | 103 typedef SampleView INHERITED; |
104 }; | 104 }; |
105 | 105 |
106 ////////////////////////////////////////////////////////////////////////////// | 106 ////////////////////////////////////////////////////////////////////////////// |
107 | 107 |
108 static SkView* MyFactory() { return new CameraView; } | 108 static SkView* MyFactory() { return new CameraView; } |
109 static SkViewRegister reg(MyFactory); | 109 static SkViewRegister reg(MyFactory); |
OLD | NEW |