OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2015 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef SkLight_DEFINED | |
9 #define SkLight_DEFINED | |
10 | |
11 #include "SkPoint3.h" | |
12 | |
13 class SK_API SkLight { | |
14 public: | |
15 enum LightType { | |
16 kAmbient_LightType, // only 'fColor' is used | |
17 kDirectional_LightType | |
18 }; | |
19 | |
20 SkLight() : fType(kAmbient_LightType) { | |
21 fColor.set(0.0f, 0.0f, 0.0f); | |
22 fDirection.set(0.0f, 0.0f, 1.0f); | |
23 } | |
24 | |
25 SkLight(const SkColor3f& color) | |
26 : fType(kAmbient_LightType) | |
27 , fColor(color) { | |
28 fDirection.set(0.0f, 0.0f, 1.0f); | |
29 } | |
30 | |
31 SkLight(const SkColor3f& color, const SkVector3& dir) | |
32 : fType(kDirectional_LightType) | |
33 , fColor(color) | |
34 , fDirection(dir) { | |
35 if (!fDirection.normalize()) { | |
36 fDirection.set(0.0f, 0.0f, 1.0f); | |
37 } | |
38 } | |
39 | |
40 LightType type() const { return fType; } | |
41 const SkColor3f& color() const { return fColor; } | |
42 const SkVector3& dir() const { | |
43 SkASSERT(kAmbient_LightType != fType); | |
44 return fDirection; | |
45 } | |
46 | |
47 private: | |
48 LightType fType; | |
49 SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in e
ach channel. | |
50 SkVector3 fDirection; // direction towards the light (+Z is out of t
he screen). | |
51 // If degenerate, it will be replaced with (0,
0, 1). | |
52 }; | |
53 | |
54 | |
55 #endif | |
OLD | NEW |