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

Unified Diff: src/core/SkLightingShader.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/SkCanvas.cpp ('k') | src/core/SkLights.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkLightingShader.cpp
diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp
index e8280b1267439e5405e835adb0e279742d00c12a..6f3c23399df00b21cea511b43aa12a47341181b4 100644
--- a/src/core/SkLightingShader.cpp
+++ b/src/core/SkLightingShader.cpp
@@ -416,30 +416,7 @@ sk_sp<SkFlattenable> SkLightingShaderImpl::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;
- }
- builder.add(SkLights::Light(color, dir));
- }
- }
-
- sk_sp<SkLights> lights(builder.finish());
+ sk_sp<SkLights> lights = SkLights::MakeFromBuffer(buf);
sk_sp<SkNormalSource> normalSource(buf.readFlattenable<SkNormalSource>());
@@ -456,18 +433,7 @@ sk_sp<SkFlattenable> SkLightingShaderImpl::CreateProc(SkReadBuffer& buf) {
void SkLightingShaderImpl::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);
- }
- }
+ fLights->flatten(buf);
buf.writeFlattenable(fNormalSource.get());
buf.writeBool(fDiffuseShader);
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/core/SkLights.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698