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

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..afc78edee847d6557df562d9048959cbaed6b58b 100644
--- a/samplecode/SampleShadowing.cpp
+++ b/samplecode/SampleShadowing.cpp
@@ -25,7 +25,14 @@ public:
, fLightDepth(300.0f) {
this->setBGColor(0xFFCCCCCC);
robertphillips 2016/08/26 17:31:28 ??
- this->updateLights(200, 200);
+ this->setBGColor(0xFFCCCCCC);
+ 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;
@@ -205,7 +212,23 @@ protected:
if (fMoveLight) {
if (dx != 0 || dy != 0) {
robertphillips 2016/08/26 17:31:28 ??
- this->updateLights(x, y);
+ float recipX = 1.0f / kWidth;
+ float recipY = 1.0f / kHeight;
+
+ SkLights::Builder builder;
+ 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();
+
fLightsChanged = true;
this->inval(nullptr);
}
« no previous file with comments | « samplecode/SampleLitAtlas.cpp ('k') | src/core/SkCanvas.cpp » ('j') | src/core/SkShadowShader.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698