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

Side by Side Diff: src/core/SkLightingShader.cpp

Issue 1911963008: DNC - JSON of flattenables, with field names. Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add names to call sites Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBitmapProcState.h" 8 #include "SkBitmapProcState.h"
9 #include "SkColor.h" 9 #include "SkColor.h"
10 #include "SkEmptyShader.h" 10 #include "SkEmptyShader.h"
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 612 }
613 613
614 return sk_make_sp<SkLightingShaderImpl>(diffuse, normal, lights, invNormRota tion, 614 return sk_make_sp<SkLightingShaderImpl>(diffuse, normal, lights, invNormRota tion,
615 &diffLocalM, &normLocalM); 615 &diffLocalM, &normLocalM);
616 } 616 }
617 617
618 void SkLightingShaderImpl::flatten(SkWriteBuffer& buf) const { 618 void SkLightingShaderImpl::flatten(SkWriteBuffer& buf) const {
619 this->INHERITED::flatten(buf); 619 this->INHERITED::flatten(buf);
620 620
621 bool hasNormLocalM = !fNormLocalMatrix.isIdentity(); 621 bool hasNormLocalM = !fNormLocalMatrix.isIdentity();
622 buf.writeBool(hasNormLocalM); 622 buf.writeBool(SK_STRING_AND_VALUE(hasNormLocalM));
623 if (hasNormLocalM) { 623 if (hasNormLocalM) {
624 buf.writeMatrix(fNormLocalMatrix); 624 buf.writeMatrix(SK_STRING_AND_VALUE(fNormLocalMatrix));
625 } 625 }
626 626
627 buf.writeBitmap(fDiffuseMap); 627 buf.writeBitmap(SK_STRING_AND_VALUE(fDiffuseMap));
628 buf.writeBitmap(fNormalMap); 628 buf.writeBitmap(SK_STRING_AND_VALUE(fNormalMap));
629 629
630 buf.writeInt(fLights->numLights()); 630 buf.writeInt("numLights", fLights->numLights());
631 for (int l = 0; l < fLights->numLights(); ++l) { 631 for (int l = 0; l < fLights->numLights(); ++l) {
632 const SkLight& light = fLights->light(l); 632 const SkLight& light = fLights->light(l);
633 633
634 bool isAmbient = SkLight::kAmbient_LightType == light.type(); 634 bool isAmbient = SkLight::kAmbient_LightType == light.type();
635 635
636 buf.writeBool(isAmbient); 636 buf.writeBool(SK_STRING_AND_VALUE(isAmbient));
637 buf.writeScalarArray(&light.color().fX, 3); 637 buf.writeScalarArray("lightColor", &light.color().fX, 3);
638 if (!isAmbient) { 638 if (!isAmbient) {
639 buf.writeScalarArray(&light.dir().fX, 3); 639 buf.writeScalarArray("lightDir", &light.dir().fX, 3);
640 } 640 }
641 } 641 }
642 buf.writePoint(fInvNormRotation); 642 buf.writePoint(SK_STRING_AND_VALUE(fInvNormRotation));
643 } 643 }
644 644
645 bool SkLightingShaderImpl::computeNormTotalInverse(const ContextRec& rec, 645 bool SkLightingShaderImpl::computeNormTotalInverse(const ContextRec& rec,
646 SkMatrix* normTotalInverse) c onst { 646 SkMatrix* normTotalInverse) c onst {
647 SkMatrix total; 647 SkMatrix total;
648 total.setConcat(*rec.fMatrix, fNormLocalMatrix); 648 total.setConcat(*rec.fMatrix, fNormLocalMatrix);
649 649
650 const SkMatrix* m = &total; 650 const SkMatrix* m = &total;
651 if (rec.fLocalMatrix) { 651 if (rec.fLocalMatrix) {
652 total.setConcat(*m, *rec.fLocalMatrix); 652 total.setConcat(*m, *rec.fLocalMatrix);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 normLocalM); 722 normLocalM);
723 } 723 }
724 724
725 /////////////////////////////////////////////////////////////////////////////// 725 ///////////////////////////////////////////////////////////////////////////////
726 726
727 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) 727 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader)
728 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) 728 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl)
729 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 729 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
730 730
731 /////////////////////////////////////////////////////////////////////////////// 731 ///////////////////////////////////////////////////////////////////////////////
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698