OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #ifndef SkLight_DEFINED | 8 #ifndef SkLight_DEFINED |
10 #define SkLight_DEFINED | 9 #define SkLight_DEFINED |
11 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
33 : fType(kDirectional_LightType) | 32 : fType(kDirectional_LightType) |
34 , fColor(color) | 33 , fColor(color) |
35 , fDirection(dir) { | 34 , fDirection(dir) { |
36 if (!fDirection.normalize()) { | 35 if (!fDirection.normalize()) { |
37 fDirection.set(0.0f, 0.0f, 1.0f); | 36 fDirection.set(0.0f, 0.0f, 1.0f); |
38 } | 37 } |
39 } | 38 } |
40 | 39 |
41 LightType type() const { return fType; } | 40 LightType type() const { return fType; } |
42 const SkColor3f& color() const { return fColor; } | 41 const SkColor3f& color() const { return fColor; } |
43 const SkVector3& dir() const { | 42 const SkVector3& dir() const { |
44 SkASSERT(kAmbient_LightType != fType); | 43 SkASSERT(kAmbient_LightType != fType); |
45 return fDirection; | 44 return fDirection; |
46 } | 45 } |
47 | 46 |
48 private: | 47 private: |
49 LightType fType; | 48 LightType fType; |
50 SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in e
ach channel. | 49 SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in e
ach channel. |
51 SkVector3 fDirection; // direction towards the light (+Z is out of t
he screen). | 50 SkVector3 fDirection; // direction towards the light (+Z is out of t
he screen). |
52 // If degenerate, it will be replaced with (0,
0, 1). | 51 // If degenerate, it will be replaced with (0,
0, 1). |
53 }; | 52 }; |
54 | 53 |
55 | 54 |
56 #endif | 55 #endif |
OLD | NEW |