OLD | NEW |
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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 } | 545 } |
546 | 546 |
547 //////////////////////////////////////////////////////////////////////////// | 547 //////////////////////////////////////////////////////////////////////////// |
548 | 548 |
549 #ifndef SK_IGNORE_TO_STRING | 549 #ifndef SK_IGNORE_TO_STRING |
550 void SkLightingShaderImpl::toString(SkString* str) const { | 550 void SkLightingShaderImpl::toString(SkString* str) const { |
551 str->appendf("LightingShader: ()"); | 551 str->appendf("LightingShader: ()"); |
552 } | 552 } |
553 #endif | 553 #endif |
554 | 554 |
555 SkFlattenable* SkLightingShaderImpl::CreateProc(SkReadBuffer& buf) { | 555 sk_sp<SkFlattenable> SkLightingShaderImpl::CreateProc(SkReadBuffer& buf) { |
556 SkMatrix diffLocalM; | 556 SkMatrix diffLocalM; |
557 bool hasDiffLocalM = buf.readBool(); | 557 bool hasDiffLocalM = buf.readBool(); |
558 if (hasDiffLocalM) { | 558 if (hasDiffLocalM) { |
559 buf.readMatrix(&diffLocalM); | 559 buf.readMatrix(&diffLocalM); |
560 } else { | 560 } else { |
561 diffLocalM.reset(); | 561 diffLocalM.reset(); |
562 } | 562 } |
563 | 563 |
564 SkMatrix normLocalM; | 564 SkMatrix normLocalM; |
565 bool hasNormLocalM = buf.readBool(); | 565 bool hasNormLocalM = buf.readBool(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 SkVector3 dir; | 599 SkVector3 dir; |
600 if (!buf.readScalarArray(&dir.fX, 3)) { | 600 if (!buf.readScalarArray(&dir.fX, 3)) { |
601 return nullptr; | 601 return nullptr; |
602 } | 602 } |
603 builder.add(SkLight(color, dir)); | 603 builder.add(SkLight(color, dir)); |
604 } | 604 } |
605 } | 605 } |
606 | 606 |
607 SkAutoTUnref<const SkLightingShader::Lights> lights(builder.finish()); | 607 SkAutoTUnref<const SkLightingShader::Lights> lights(builder.finish()); |
608 | 608 |
609 return new SkLightingShaderImpl(diffuse, normal, lights, SkVector::Make(1.0f
, 0.0f), | 609 return sk_make_sp<SkLightingShaderImpl>(diffuse, normal, lights, SkVector::M
ake(1.0f, 0.0f), |
610 &diffLocalM, &normLocalM); | 610 &diffLocalM, &normLocalM); |
611 } | 611 } |
612 | 612 |
613 void SkLightingShaderImpl::flatten(SkWriteBuffer& buf) const { | 613 void SkLightingShaderImpl::flatten(SkWriteBuffer& buf) const { |
614 this->INHERITED::flatten(buf); | 614 this->INHERITED::flatten(buf); |
615 | 615 |
616 bool hasNormLocalM = !fNormLocalMatrix.isIdentity(); | 616 bool hasNormLocalM = !fNormLocalMatrix.isIdentity(); |
617 buf.writeBool(hasNormLocalM); | 617 buf.writeBool(hasNormLocalM); |
618 if (hasNormLocalM) { | 618 if (hasNormLocalM) { |
619 buf.writeMatrix(fNormLocalMatrix); | 619 buf.writeMatrix(fNormLocalMatrix); |
620 } | 620 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 normLocalM); | 716 normLocalM); |
717 } | 717 } |
718 | 718 |
719 /////////////////////////////////////////////////////////////////////////////// | 719 /////////////////////////////////////////////////////////////////////////////// |
720 | 720 |
721 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) | 721 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingShader) |
722 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) | 722 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkLightingShaderImpl) |
723 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 723 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
724 | 724 |
725 /////////////////////////////////////////////////////////////////////////////// | 725 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |