OLD | NEW |
---|---|
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 | 8 |
9 #ifndef SkLights_DEFINED | 9 #ifndef SkLights_DEFINED |
10 #define SkLights_DEFINED | 10 #define SkLights_DEFINED |
11 | 11 |
12 #include "SkPoint3.h" | 12 #include "SkPoint3.h" |
13 #include "SkRefCnt.h" | 13 #include "SkRefCnt.h" |
14 #include "../private/SkTDArray.h" | 14 #include "../private/SkTDArray.h" |
15 #include "SkImage.h" | |
15 | 16 |
16 class SK_API SkLights : public SkRefCnt { | 17 class SK_API SkLights : public SkRefCnt { |
17 public: | 18 public: |
18 class Light { | 19 class Light { |
19 public: | 20 public: |
20 enum LightType { | 21 enum LightType { |
21 kAmbient_LightType, // only 'fColor' is used | 22 kAmbient_LightType, // only 'fColor' is used |
22 kDirectional_LightType | 23 kDirectional_LightType |
23 }; | 24 }; |
24 | 25 |
(...skipping 12 matching lines...) Expand all Loading... | |
37 } | 38 } |
38 } | 39 } |
39 | 40 |
40 LightType type() const { return fType; } | 41 LightType type() const { return fType; } |
41 const SkColor3f& color() const { return fColor; } | 42 const SkColor3f& color() const { return fColor; } |
42 const SkVector3& dir() const { | 43 const SkVector3& dir() const { |
43 SkASSERT(kAmbient_LightType != fType); | 44 SkASSERT(kAmbient_LightType != fType); |
44 return fDirection; | 45 return fDirection; |
45 } | 46 } |
46 | 47 |
48 void setShadowMap(sk_sp<SkImage> shadowMap) { } | |
49 | |
47 private: | 50 private: |
48 LightType fType; | 51 LightType fType; |
49 SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in each channel. | 52 SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in each channel. |
50 SkVector3 fDirection; // direction towards the light (+Z is out of the screen). | 53 SkVector3 fDirection; // direction towards the light (+Z is out of the screen). |
51 // If degenerate, it will be replaced with (0, 0, 1). | 54 // If degenerate, it will be replaced with (0, 0, 1). |
55 | |
52 }; | 56 }; |
53 | 57 |
54 class Builder { | 58 class Builder { |
55 public: | 59 public: |
56 Builder() : fLights(new SkLights) { } | 60 Builder() : fLights(new SkLights) { } |
57 | 61 |
58 void add(const Light& light) { | 62 void add(const Light& light) { |
59 if (fLights) { | 63 if (fLights) { |
60 *fLights->fLights.push() = light; | 64 *fLights->fLights.push() = light; |
61 } | 65 } |
62 } | 66 } |
63 | 67 |
64 sk_sp<SkLights> finish() { | 68 sk_sp<SkLights> finish() { |
65 return fLights; | 69 return fLights; |
66 } | 70 } |
67 | 71 |
68 private: | 72 private: |
69 sk_sp<SkLights> fLights; | 73 sk_sp<SkLights> fLights; |
70 }; | 74 }; |
71 | 75 |
72 int numLights() const { | 76 int numLights() const { |
73 return fLights.count(); | 77 return fLights.count(); |
74 } | 78 } |
75 | 79 |
76 const Light& light(int index) const { | 80 Light& light(int index) { |
jvanverth1
2016/07/15 19:16:30
It might be good to have both a const and a non-co
vjiaoblack
2016/07/18 13:03:23
Done.
| |
77 return fLights[index]; | 81 return fLights[index]; |
78 } | 82 } |
79 | 83 |
80 private: | 84 private: |
81 SkLights() {} | 85 SkLights() {} |
82 | 86 |
83 SkTDArray<Light> fLights; | 87 SkTDArray<Light> fLights; |
84 }; | 88 }; |
85 | 89 |
86 #endif | 90 #endif |
OLD | NEW |