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

Unified Diff: samplecode/SampleShadowing.cpp

Issue 2287553002: Moved ambient lights out of SkLight's light array (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: made req changes 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: samplecode/SampleShadowing.cpp
diff --git a/samplecode/SampleShadowing.cpp b/samplecode/SampleShadowing.cpp
index 4892f9c27df5c97eb27bd38175a2f59ac5082aac..ada48a0f4b03d948c332d1440a4316dff878d0c6 100644
--- a/samplecode/SampleShadowing.cpp
+++ b/samplecode/SampleShadowing.cpp
@@ -25,7 +25,13 @@ public:
, fLightDepth(300.0f) {
this->setBGColor(0xFFCCCCCC);
robertphillips 2016/08/26 19:16:02 In the prior CL you were calling updateLights. Why
vjiaoblack 2016/08/26 19:25:17 Done.
- this->updateLights(200, 200);
+ SkLights::Builder builder;
+ builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(0.2f, 0.3f, 0.4f),
+ SkVector3::Make(0.2f, 0.05f, 1.0f)));
+ builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(0.4f, 0.3f, 0.2f),
+ SkVector3::Make(0.05f, 0.2f, 1.0f)));
+ builder.setAmbientLightColor(SkColor3f::Make(0.4f, 0.4f, 0.4f));
+ fLights = builder.finish();
fTestRects[0].fColor = 0xFFEE8888;
fTestRects[0].fDepth = 80;
@@ -160,19 +166,21 @@ protected:
}
void updateLights(int x, int y) {
+ float recipX = 1.0f / kWidth;
+ float recipY = 1.0f / kHeight;
+
SkLights::Builder builder;
- builder.add(SkLights::Light::MakePoint(SkColor3f::Make(0.2f, 0.4f, 0.6f),
- SkVector3::Make(x - 50,
- 350 - y,
- fLightDepth),
- 1024));
- builder.add(SkLights::Light::MakePoint(SkColor3f::Make(0.6f, 0.4f, 0.2f),
- SkVector3::Make(x + 50,
- 450 - y,
- fLightDepth),
- 1024));
- builder.add(SkLights::Light::MakeDirectional(SkColor3f::Make(0.2f, 0.2f, 0.2f),
- SkVector3::Make(0.2f, 0.2f, 1.0f)));
+ builder.add(SkLights::Light::MakeDirectional(
+ SkColor3f::Make(0.2f, 0.3f, 0.4f),
+ SkVector3::Make(0.2f + (200.0f - x) * recipX,
+ 0.05f + (200.0f - y) * recipY,
+ 1.0f)));
+ builder.add(SkLights::Light::MakeDirectional(
+ SkColor3f::Make(0.4f, 0.3f, 0.2f),
+ SkVector3::Make(0.05f + (200.0f - x) * recipX,
+ 0.2f + (200.0f - y) * recipY,
+ 1.0f)));
+ builder.setAmbientLightColor(SkColor3f::Make(0.4f, 0.4f, 0.4f));
fLights = builder.finish();
}
@@ -205,7 +213,7 @@ protected:
if (fMoveLight) {
if (dx != 0 || dy != 0) {
robertphillips 2016/08/26 19:16:02 this-> - from prior CL
- this->updateLights(x, y);
+ updateLights(x, y);
fLightsChanged = true;
this->inval(nullptr);
}

Powered by Google App Engine
This is Rietveld 408576698