Index: include/core/SkLights.h |
diff --git a/include/core/SkLights.h b/include/core/SkLights.h |
index d8ec87d53271ed26a15f4d0c9e06ac60405e7759..a5755f0badf009c8bf1a56d30184daca69797190 100644 |
--- a/include/core/SkLights.h |
+++ b/include/core/SkLights.h |
@@ -22,7 +22,6 @@ public: |
class Light { |
public: |
enum LightType { |
- kAmbient_LightType, // only 'fColor' is used |
kDirectional_LightType, |
kPoint_LightType |
}; |
@@ -43,10 +42,6 @@ public: |
, fShadowMap(std::move(other.fShadowMap)) { |
} |
- static Light MakeAmbient(const SkColor3f& color) { |
- return Light(kAmbient_LightType, color, SkVector3::Make(0.0f, 0.0f, 1.0f)); |
- } |
- |
static Light MakeDirectional(const SkColor3f& color, const SkVector3& dir) { |
Light light(kDirectional_LightType, color, dir); |
if (!light.fDirOrPos.normalize()) { |
@@ -112,7 +107,6 @@ public: |
private: |
LightType fType; |
SkColor3f fColor; // linear (unpremul) color. Range is 0..1 in each channel. |
- |
SkVector3 fDirOrPos; // For directional lights, holds the direction towards the |
// light (+Z is out of the screen). |
// If degenerate, it will be replaced with (0, 0, 1). |
@@ -123,10 +117,10 @@ public: |
sk_sp<SkImage> fShadowMap; |
Light(LightType type, const SkColor3f& color, |
- const SkVector3& dir, SkScalar intensity = 0.0f) { |
+ const SkVector3& dirOrPos, SkScalar intensity = 0.0f) { |
fType = type; |
fColor = color; |
- fDirOrPos = dir; |
+ fDirOrPos = dirOrPos; |
fIntensity = intensity; |
} |
}; |
@@ -147,6 +141,12 @@ public: |
} |
} |
+ void setAmbientLightColor(const SkColor3f& color) { |
+ if (fLights) { |
+ fLights->fAmbientLightColor = color; |
+ } |
+ } |
+ |
sk_sp<SkLights> finish() { |
return std::move(fLights); |
} |
@@ -167,6 +167,10 @@ public: |
return fLights[index]; |
} |
+ const SkColor3f& ambientLightColor() const { |
+ return fAmbientLightColor; |
+ } |
+ |
static sk_sp<SkLights> MakeFromBuffer(SkReadBuffer& buf); |
void flatten(SkWriteBuffer& buf) const; |
@@ -174,6 +178,7 @@ public: |
private: |
SkLights() {} |
SkTArray<Light> fLights; |
+ SkColor3f fAmbientLightColor; |
typedef SkRefCnt INHERITED; |
}; |