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

Unified Diff: src/core/SkShadowShader.cpp

Issue 2237493002: Added PointLights to SkLights::Light (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixed serialization bug 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 | « src/core/SkLights.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkShadowShader.cpp
diff --git a/src/core/SkShadowShader.cpp b/src/core/SkShadowShader.cpp
index 5fc992acc14dd790ab86e43e6a761ecc7b7db8bc..804258321a80f9ab0bd20b7ffa995878ab079b17 100644
--- a/src/core/SkShadowShader.cpp
+++ b/src/core/SkShadowShader.cpp
@@ -592,39 +592,7 @@ sk_sp<SkFlattenable> SkShadowShaderImpl::CreateProc(SkReadBuffer& buf) {
bool hasLocalMatrix = buf.readBool();
SkAssertResult(!hasLocalMatrix);
- int numLights = buf.readInt();
-
- SkLights::Builder builder;
-
- for (int l = 0; l < numLights; ++l) {
- bool isAmbient = buf.readBool();
-
- SkColor3f color;
- if (!buf.readScalarArray(&color.fX, 3)) {
- return nullptr;
- }
-
- if (isAmbient) {
- builder.add(SkLights::Light(color));
- } else {
- SkVector3 dir;
- if (!buf.readScalarArray(&dir.fX, 3)) {
- return nullptr;
- }
-
- sk_sp<SkImage> depthMap;
- if (!(depthMap = sk_ref_sp<SkImage>(buf.readImage()))) {
- return nullptr;
- }
-
- SkLights::Light light = SkLights::Light(color, dir);
- light.setShadowMap(depthMap);
-
- builder.add(light);
- }
- }
-
- sk_sp<SkLights> lights(builder.finish());
+ sk_sp<SkLights> lights = SkLights::MakeFromBuffer(buf);
int diffuseWidth = buf.readInt();
int diffuseHeight = buf.readInt();
@@ -641,21 +609,7 @@ sk_sp<SkFlattenable> SkShadowShaderImpl::CreateProc(SkReadBuffer& buf) {
void SkShadowShaderImpl::flatten(SkWriteBuffer& buf) const {
this->INHERITED::flatten(buf);
- buf.writeInt(fLights->numLights());
-
- for (int l = 0; l < fLights->numLights(); ++l) {
- const SkLights::Light& light = fLights->light(l);
-
- bool isAmbient = SkLights::Light::kAmbient_LightType == light.type();
-
- buf.writeBool(isAmbient);
- buf.writeScalarArray(&light.color().fX, 3);
- if (!isAmbient) {
- buf.writeScalarArray(&light.dir().fX, 3);
- }
-
- buf.writeImage(light.getShadowMap());
- }
+ fLights->flatten(buf);
buf.writeInt(fDiffuseWidth);
buf.writeInt(fDiffuseHeight);
« no previous file with comments | « src/core/SkLights.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698