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

Side by Side Diff: samplecode/SampleLighting.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/SampleLayers.cpp ('k') | samplecode/SampleLines.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 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 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 "DecodeFile.h"
8 #include "SampleCode.h" 9 #include "SampleCode.h"
9 #include "Resources.h" 10 #include "Resources.h"
10 11
11 #include "SkCanvas.h" 12 #include "SkCanvas.h"
12 #include "SkImageDecoder.h"
13 #include "SkLightingShader.h" 13 #include "SkLightingShader.h"
14 #include "SkPoint3.h" 14 #include "SkPoint3.h"
15 15
16 static const SkLightingShader::Lights* create_lights(SkScalar angle, SkScalar bl ue) { 16 static const SkLightingShader::Lights* create_lights(SkScalar angle, SkScalar bl ue) {
17 17
18 const SkVector3 dir = SkVector3::Make(SkScalarSin(angle)*SkScalarSin(SK_Scal arPI*0.25f), 18 const SkVector3 dir = SkVector3::Make(SkScalarSin(angle)*SkScalarSin(SK_Scal arPI*0.25f),
19 SkScalarCos(angle)*SkScalarSin(SK_Scal arPI*0.25f), 19 SkScalarCos(angle)*SkScalarSin(SK_Scal arPI*0.25f),
20 SkScalarCos(SK_ScalarPI*0.25f)); 20 SkScalarCos(SK_ScalarPI*0.25f));
21 21
22 SkLightingShader::Lights::Builder builder; 22 SkLightingShader::Lights::Builder builder;
23 23
24 builder.add(SkLight(SkColor3f::Make(1.0f, 1.0f, blue), dir)); 24 builder.add(SkLight(SkColor3f::Make(1.0f, 1.0f, blue), dir));
25 builder.add(SkLight(SkColor3f::Make(0.1f, 0.1f, 0.1f))); 25 builder.add(SkLight(SkColor3f::Make(0.1f, 0.1f, 0.1f)));
26 26
27 return builder.finish(); 27 return builder.finish();
28 } 28 }
29 29
30 //////////////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////////////
31 31
32 class LightingView : public SampleView { 32 class LightingView : public SampleView {
33 public: 33 public:
34 SkAutoTUnref<SkShader> fShader; 34 SkAutoTUnref<SkShader> fShader;
35 SkBitmap fDiffuseBitmap; 35 SkBitmap fDiffuseBitmap;
36 SkBitmap fNormalBitmap; 36 SkBitmap fNormalBitmap;
37 SkScalar fLightAngle; 37 SkScalar fLightAngle;
38 SkScalar fColorFactor; 38 SkScalar fColorFactor;
39 39
40 LightingView() { 40 LightingView() {
41 SkString diffusePath = GetResourcePath("brickwork-texture.jpg"); 41 SkString diffusePath = GetResourcePath("brickwork-texture.jpg");
42 SkImageDecoder::DecodeFile(diffusePath.c_str(), &fDiffuseBitmap); 42 decode_file(diffusePath.c_str(), &fDiffuseBitmap);
43 SkString normalPath = GetResourcePath("brickwork_normal-map.jpg"); 43 SkString normalPath = GetResourcePath("brickwork_normal-map.jpg");
44 SkImageDecoder::DecodeFile(normalPath.c_str(), &fNormalBitmap); 44 decode_file(normalPath.c_str(), &fNormalBitmap);
45 45
46 fLightAngle = 0.0f; 46 fLightAngle = 0.0f;
47 fColorFactor = 0.0f; 47 fColorFactor = 0.0f;
48 48
49 SkAutoTUnref<const SkLightingShader::Lights> lights(create_lights(fLight Angle, 1.0f)); 49 SkAutoTUnref<const SkLightingShader::Lights> lights(create_lights(fLight Angle, 1.0f));
50 50
51 fShader.reset(SkLightingShader::Create(fDiffuseBitmap, fNormalBitmap, 51 fShader.reset(SkLightingShader::Create(fDiffuseBitmap, fNormalBitmap,
52 lights, SkVector::Make(1.0f, 0.0f ), 52 lights, SkVector::Make(1.0f, 0.0f ),
53 nullptr, nullptr)); 53 nullptr, nullptr));
54 } 54 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 } 97 }
98 98
99 private: 99 private:
100 typedef SampleView INHERITED; 100 typedef SampleView INHERITED;
101 }; 101 };
102 102
103 ////////////////////////////////////////////////////////////////////////////// 103 //////////////////////////////////////////////////////////////////////////////
104 104
105 static SkView* MyFactory() { return new LightingView; } 105 static SkView* MyFactory() { return new LightingView; }
106 static SkViewRegister reg(MyFactory); 106 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleLayers.cpp ('k') | samplecode/SampleLines.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698