OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "DecodeFile.h" |
9 #include "SampleCode.h" | 9 #include "SampleCode.h" |
10 #include "Resources.h" | 10 #include "Resources.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkLightingShader.h" | 12 #include "SkLightingShader.h" |
13 #include "SkNormalSource.h" | 13 #include "SkNormalSource.h" |
14 #include "SkPoint3.h" | 14 #include "SkPoint3.h" |
15 | 15 |
16 static sk_sp<SkLights> create_lights(SkScalar angle, SkScalar blue) { | 16 static sk_sp<SkLights> create_lights(SkScalar angle, SkScalar blue) { |
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 SkLights::Builder builder; | 22 SkLights::Builder builder; |
23 | 23 |
24 builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(1.0f, 1.0f, blu
e), dir)); | 24 builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(1.0f, 1.0f, blu
e), dir)); |
25 builder.add(SkLights::Light::MakeAmbient(SkColor3f::Make(0.1f, 0.1f, 0.1f)))
; | 25 builder.setAmbientLightColor(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 SkBitmap fDiffuseBitmap; | 34 SkBitmap fDiffuseBitmap; |
35 SkBitmap fNormalBitmap; | 35 SkBitmap fNormalBitmap; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 typedef SampleView INHERITED; | 92 typedef SampleView INHERITED; |
93 }; | 93 }; |
94 | 94 |
95 ////////////////////////////////////////////////////////////////////////////// | 95 ////////////////////////////////////////////////////////////////////////////// |
96 | 96 |
97 static SkView* MyFactory() { return new LightingView; } | 97 static SkView* MyFactory() { return new LightingView; } |
98 static SkViewRegister reg(MyFactory); | 98 static SkViewRegister reg(MyFactory); |
OLD | NEW |