Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Unified Diff: include/core/SkLights.h

Issue 2287553002: Moved ambient lights out of SkLight's light array (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: added ambient light calculations to Raster renderer of LightingShader Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gm/shadowmaps.cpp ('k') | samplecode/SampleBevel.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkLights.h
diff --git a/include/core/SkLights.h b/include/core/SkLights.h
index d8ec87d53271ed26a15f4d0c9e06ac60405e7759..1371e441d4894a9d1060012e54fab0aa236f117c 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()) {
@@ -123,17 +118,17 @@ 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;
}
};
class Builder {
public:
- Builder() : fLights(new SkLights) { }
+ Builder() : fLights(new SkLights) {}
void add(const Light& light) {
if (fLights) {
@@ -147,6 +142,12 @@ public:
}
}
+ void setAmbientLightColor(const SkColor3f& color) {
+ if (fLights) {
+ fLights->fAmbientLightColor = color;
+ }
+ }
+
sk_sp<SkLights> finish() {
return std::move(fLights);
}
@@ -167,13 +168,20 @@ public:
return fLights[index];
}
+ const SkColor3f& ambientLightColor() const {
+ return fAmbientLightColor;
+ }
+
static sk_sp<SkLights> MakeFromBuffer(SkReadBuffer& buf);
void flatten(SkWriteBuffer& buf) const;
private:
- SkLights() {}
+ SkLights() {
+ fAmbientLightColor.set(0.0f, 0.0f, 0.0f);
+ }
SkTArray<Light> fLights;
+ SkColor3f fAmbientLightColor;
typedef SkRefCnt INHERITED;
};
« no previous file with comments | « gm/shadowmaps.cpp ('k') | samplecode/SampleBevel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698