OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
jvanverth1
2016/07/07 18:43:02
The changes in this file seem unrelated to the des
| |
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 // fShadowMap = shadowMap; | |
50 } | |
51 | |
47 private: | 52 private: |
48 LightType fType; | 53 LightType fType; |
49 SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in each channel. | 54 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). | 55 SkVector3 fDirection; // direction towards the light (+Z is out of the screen). |
51 // If degenerate, it will be replaced with (0, 0, 1). | 56 // If degenerate, it will be replaced with (0, 0, 1). |
57 | |
58 // sk_sp<SkImage> fShadowMap; // TEST_VICTOR this is a happy happy shadow mappy | |
52 }; | 59 }; |
53 | 60 |
54 class Builder { | 61 class Builder { |
55 public: | 62 public: |
56 Builder() : fLights(new SkLights) { } | 63 Builder() : fLights(new SkLights) { } |
57 | 64 |
58 void add(const Light& light) { | 65 void add(const Light& light) { |
59 if (fLights) { | 66 if (fLights) { |
60 *fLights->fLights.push() = light; | 67 *fLights->fLights.push() = light; |
61 } | 68 } |
62 } | 69 } |
63 | 70 |
64 sk_sp<SkLights> finish() { | 71 sk_sp<SkLights> finish() { |
65 return fLights; | 72 return fLights; |
66 } | 73 } |
67 | 74 |
68 private: | 75 private: |
69 sk_sp<SkLights> fLights; | 76 sk_sp<SkLights> fLights; |
70 }; | 77 }; |
71 | 78 |
72 int numLights() const { | 79 int numLights() const { |
73 return fLights.count(); | 80 return fLights.count(); |
74 } | 81 } |
75 | 82 |
76 const Light& light(int index) const { | 83 Light& light(int index) { |
77 return fLights[index]; | 84 return fLights[index]; |
78 } | 85 } |
79 | 86 |
80 private: | 87 private: |
81 SkLights() {} | 88 SkLights() {} |
82 | 89 |
83 SkTDArray<Light> fLights; | 90 SkTDArray<Light> fLights; |
84 }; | 91 }; |
85 | 92 |
86 #endif | 93 #endif |
OLD | NEW |