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

Unified Diff: include/core/SkLights.h

Issue 2237493002: Added PointLights to SkLights::Light (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: changed a vec3 to a point3 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
Index: include/core/SkLights.h
diff --git a/include/core/SkLights.h b/include/core/SkLights.h
index 52e60c71a07a5fe3cae5f441f58e858617490251..a8f3d052dcc337c555cfc93908c333ab598cac18 100644
--- a/include/core/SkLights.h
+++ b/include/core/SkLights.h
@@ -20,7 +20,8 @@ public:
public:
enum LightType {
kAmbient_LightType, // only 'fColor' is used
- kDirectional_LightType
+ kDirectional_LightType,
+ kPoint_LightType
};
Light(const Light& other)
@@ -37,27 +38,34 @@ public:
, fShadowMap(std::move(other.fShadowMap)) {
}
- Light(const SkColor3f& color)
- : fType(kAmbient_LightType)
- , fColor(color) {
- fDirection.set(0.0f, 0.0f, 1.0f);
+ static Light MakeAmbient(const SkColor3f& color) {
robertphillips 2016/08/10 17:48:39 just "return Light(...);" no need for the temporar
vjiaoblack 2016/08/11 14:27:23 Done.
+ Light light(kAmbient_LightType, color, SkVector3::Make(0.0f, 0.0f, 1.0f));
+ return light;
}
- Light(const SkColor3f& color, const SkVector3& dir)
- : fType(kDirectional_LightType)
- , fColor(color)
- , fDirection(dir) {
- if (!fDirection.normalize()) {
- fDirection.set(0.0f, 0.0f, 1.0f);
+ static Light MakeDirectional(const SkColor3f& color, const SkVector3& dir) {
+ Light light(kDirectional_LightType, color, dir);
+ if (!light.fDirection.normalize()) {
+ light.fDirection.set(0.0f, 0.0f, 1.0f);
}
+ return light;
+ }
+
+ static Light MakePoint(const SkColor3f& color, const SkPoint3& pos) {
robertphillips 2016/08/10 17:48:39 Same here
vjiaoblack 2016/08/11 14:27:23 Done.
+ Light light(kPoint_LightType, color, pos);
+ return light;
}
LightType type() const { return fType; }
const SkColor3f& color() const { return fColor; }
const SkVector3& dir() const {
- SkASSERT(kAmbient_LightType != fType);
+ SkASSERT(kDirectional_LightType == fType);
return fDirection;
}
+ const SkPoint3& pos() const {
+ SkASSERT(kPoint_LightType == fType);
+ return fDirection;
+ }
void setShadowMap(sk_sp<SkImage> shadowMap) {
fShadowMap = std::move(shadowMap);
@@ -85,6 +93,12 @@ public:
SkVector3 fDirection; // direction towards the light (+Z is out of the screen).
// If degenerate, it will be replaced with (0, 0, 1).
sk_sp<SkImage> fShadowMap;
+
+ Light(LightType type, const SkColor3f color, const SkVector3 dir) {
robertphillips 2016/08/10 17:48:39 Don't need "this->" on member variables
vjiaoblack 2016/08/11 14:27:23 Done.
+ this->fType = type;
+ this->fColor = color;
+ this->fDirection = dir;
+ }
};
class Builder {

Powered by Google App Engine
This is Rietveld 408576698