Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: samplecode/SampleCamera.cpp

Issue 1812323003: Remove uses of SkImageDecoder from samplecode (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « samplecode/SampleBitmapRect.cpp ('k') | samplecode/SampleConcavePaths.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
OLDNEW
« no previous file with comments | « samplecode/SampleBitmapRect.cpp ('k') | samplecode/SampleConcavePaths.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698