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); |