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

Side by Side Diff: src/effects/SkLightingImageFilter.cpp

Issue 804813002: Cleanup: Mark some overridden methods with 'SK_OVERRIDE'. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The Android Open Source Project 2 * Copyright 2012 The Android Open Source Project
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 "SkLightingImageFilter.h" 8 #include "SkLightingImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 class SkDistantLight : public SkLight { 583 class SkDistantLight : public SkLight {
584 public: 584 public:
585 SkDistantLight(const SkPoint3& direction, SkColor color) 585 SkDistantLight(const SkPoint3& direction, SkColor color)
586 : INHERITED(color), fDirection(direction) { 586 : INHERITED(color), fDirection(direction) {
587 } 587 }
588 588
589 SkPoint3 surfaceToLight(int x, int y, int z, SkScalar surfaceScale) const { 589 SkPoint3 surfaceToLight(int x, int y, int z, SkScalar surfaceScale) const {
590 return fDirection; 590 return fDirection;
591 }; 591 };
592 SkPoint3 lightColor(const SkPoint3&) const { return color(); } 592 SkPoint3 lightColor(const SkPoint3&) const { return color(); }
593 virtual LightType type() const { return kDistant_LightType; } 593 virtual LightType type() const SK_OVERRIDE { return kDistant_LightType; }
594 const SkPoint3& direction() const { return fDirection; } 594 const SkPoint3& direction() const { return fDirection; }
595 virtual GrGLLight* createGLLight() const SK_OVERRIDE { 595 virtual GrGLLight* createGLLight() const SK_OVERRIDE {
596 #if SK_SUPPORT_GPU 596 #if SK_SUPPORT_GPU
597 return SkNEW(GrGLDistantLight); 597 return SkNEW(GrGLDistantLight);
598 #else 598 #else
599 SkDEBUGFAIL("Should not call in GPU-less build"); 599 SkDEBUGFAIL("Should not call in GPU-less build");
600 return NULL; 600 return NULL;
601 #endif 601 #endif
602 } 602 }
603 virtual bool requiresFragmentPosition() const SK_OVERRIDE { return false; } 603 virtual bool requiresFragmentPosition() const SK_OVERRIDE { return false; }
604 604
605 virtual bool isEqual(const SkLight& other) const SK_OVERRIDE { 605 virtual bool isEqual(const SkLight& other) const SK_OVERRIDE {
606 if (other.type() != kDistant_LightType) { 606 if (other.type() != kDistant_LightType) {
607 return false; 607 return false;
608 } 608 }
609 609
610 const SkDistantLight& o = static_cast<const SkDistantLight&>(other); 610 const SkDistantLight& o = static_cast<const SkDistantLight&>(other);
611 return INHERITED::isEqual(other) && 611 return INHERITED::isEqual(other) &&
612 fDirection == o.fDirection; 612 fDirection == o.fDirection;
613 } 613 }
614 614
615 SkDistantLight(SkReadBuffer& buffer) : INHERITED(buffer) { 615 SkDistantLight(SkReadBuffer& buffer) : INHERITED(buffer) {
616 fDirection = readPoint3(buffer); 616 fDirection = readPoint3(buffer);
617 } 617 }
618 618
619 protected: 619 protected:
620 SkDistantLight(const SkPoint3& direction, const SkPoint3& color) 620 SkDistantLight(const SkPoint3& direction, const SkPoint3& color)
621 : INHERITED(color), fDirection(direction) { 621 : INHERITED(color), fDirection(direction) {
622 } 622 }
623 virtual SkLight* transform(const SkMatrix& matrix) const { 623 virtual SkLight* transform(const SkMatrix& matrix) const SK_OVERRIDE {
624 return new SkDistantLight(direction(), color()); 624 return new SkDistantLight(direction(), color());
625 } 625 }
626 virtual void onFlattenLight(SkWriteBuffer& buffer) const SK_OVERRIDE { 626 virtual void onFlattenLight(SkWriteBuffer& buffer) const SK_OVERRIDE {
627 writePoint3(fDirection, buffer); 627 writePoint3(fDirection, buffer);
628 } 628 }
629 629
630 private: 630 private:
631 typedef SkLight INHERITED; 631 typedef SkLight INHERITED;
632 SkPoint3 fDirection; 632 SkPoint3 fDirection;
633 }; 633 };
634 634
635 /////////////////////////////////////////////////////////////////////////////// 635 ///////////////////////////////////////////////////////////////////////////////
636 636
637 class SkPointLight : public SkLight { 637 class SkPointLight : public SkLight {
638 public: 638 public:
639 SkPointLight(const SkPoint3& location, SkColor color) 639 SkPointLight(const SkPoint3& location, SkColor color)
640 : INHERITED(color), fLocation(location) {} 640 : INHERITED(color), fLocation(location) {}
641 641
642 SkPoint3 surfaceToLight(int x, int y, int z, SkScalar surfaceScale) const { 642 SkPoint3 surfaceToLight(int x, int y, int z, SkScalar surfaceScale) const {
643 SkPoint3 direction(fLocation.fX - SkIntToScalar(x), 643 SkPoint3 direction(fLocation.fX - SkIntToScalar(x),
644 fLocation.fY - SkIntToScalar(y), 644 fLocation.fY - SkIntToScalar(y),
645 fLocation.fZ - SkScalarMul(SkIntToScalar(z), surfaceS cale)); 645 fLocation.fZ - SkScalarMul(SkIntToScalar(z), surfaceS cale));
646 direction.normalize(); 646 direction.normalize();
647 return direction; 647 return direction;
648 }; 648 };
649 SkPoint3 lightColor(const SkPoint3&) const { return color(); } 649 SkPoint3 lightColor(const SkPoint3&) const { return color(); }
650 virtual LightType type() const { return kPoint_LightType; } 650 virtual LightType type() const SK_OVERRIDE { return kPoint_LightType; }
651 const SkPoint3& location() const { return fLocation; } 651 const SkPoint3& location() const { return fLocation; }
652 virtual GrGLLight* createGLLight() const SK_OVERRIDE { 652 virtual GrGLLight* createGLLight() const SK_OVERRIDE {
653 #if SK_SUPPORT_GPU 653 #if SK_SUPPORT_GPU
654 return SkNEW(GrGLPointLight); 654 return SkNEW(GrGLPointLight);
655 #else 655 #else
656 SkDEBUGFAIL("Should not call in GPU-less build"); 656 SkDEBUGFAIL("Should not call in GPU-less build");
657 return NULL; 657 return NULL;
658 #endif 658 #endif
659 } 659 }
660 virtual bool requiresFragmentPosition() const SK_OVERRIDE { return true; } 660 virtual bool requiresFragmentPosition() const SK_OVERRIDE { return true; }
661 virtual bool isEqual(const SkLight& other) const SK_OVERRIDE { 661 virtual bool isEqual(const SkLight& other) const SK_OVERRIDE {
662 if (other.type() != kPoint_LightType) { 662 if (other.type() != kPoint_LightType) {
663 return false; 663 return false;
664 } 664 }
665 const SkPointLight& o = static_cast<const SkPointLight&>(other); 665 const SkPointLight& o = static_cast<const SkPointLight&>(other);
666 return INHERITED::isEqual(other) && 666 return INHERITED::isEqual(other) &&
667 fLocation == o.fLocation; 667 fLocation == o.fLocation;
668 } 668 }
669 virtual SkLight* transform(const SkMatrix& matrix) const { 669 virtual SkLight* transform(const SkMatrix& matrix) const SK_OVERRIDE {
670 SkPoint location2 = SkPoint::Make(fLocation.fX, fLocation.fY); 670 SkPoint location2 = SkPoint::Make(fLocation.fX, fLocation.fY);
671 matrix.mapPoints(&location2, 1); 671 matrix.mapPoints(&location2, 1);
672 // Use X scale and Y scale on Z and average the result 672 // Use X scale and Y scale on Z and average the result
673 SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ); 673 SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ);
674 matrix.mapVectors(&locationZ, 1); 674 matrix.mapVectors(&locationZ, 1);
675 SkPoint3 location(location2.fX, location2.fY, SkScalarAve(locationZ.fX, locationZ.fY)); 675 SkPoint3 location(location2.fX, location2.fY, SkScalarAve(locationZ.fX, locationZ.fY));
676 return new SkPointLight(location, color()); 676 return new SkPointLight(location, color());
677 } 677 }
678 678
679 SkPointLight(SkReadBuffer& buffer) : INHERITED(buffer) { 679 SkPointLight(SkReadBuffer& buffer) : INHERITED(buffer) {
(...skipping 23 matching lines...) Expand all
703 fSpecularExponent(SkScalarPin(specularExponent, kSpecularExponentMin, kSp ecularExponentMax)) 703 fSpecularExponent(SkScalarPin(specularExponent, kSpecularExponentMin, kSp ecularExponentMax))
704 { 704 {
705 fS = target - location; 705 fS = target - location;
706 fS.normalize(); 706 fS.normalize();
707 fCosOuterConeAngle = SkScalarCos(SkDegreesToRadians(cutoffAngle)); 707 fCosOuterConeAngle = SkScalarCos(SkDegreesToRadians(cutoffAngle));
708 const SkScalar antiAliasThreshold = 0.016f; 708 const SkScalar antiAliasThreshold = 0.016f;
709 fCosInnerConeAngle = fCosOuterConeAngle + antiAliasThreshold; 709 fCosInnerConeAngle = fCosOuterConeAngle + antiAliasThreshold;
710 fConeScale = SkScalarInvert(antiAliasThreshold); 710 fConeScale = SkScalarInvert(antiAliasThreshold);
711 } 711 }
712 712
713 virtual SkLight* transform(const SkMatrix& matrix) const { 713 virtual SkLight* transform(const SkMatrix& matrix) const SK_OVERRIDE {
714 SkPoint location2 = SkPoint::Make(fLocation.fX, fLocation.fY); 714 SkPoint location2 = SkPoint::Make(fLocation.fX, fLocation.fY);
715 matrix.mapPoints(&location2, 1); 715 matrix.mapPoints(&location2, 1);
716 // Use X scale and Y scale on Z and average the result 716 // Use X scale and Y scale on Z and average the result
717 SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ); 717 SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ);
718 matrix.mapVectors(&locationZ, 1); 718 matrix.mapVectors(&locationZ, 1);
719 SkPoint3 location(location2.fX, location2.fY, SkScalarAve(locationZ.fX, locationZ.fY)); 719 SkPoint3 location(location2.fX, location2.fY, SkScalarAve(locationZ.fX, locationZ.fY));
720 SkPoint target2 = SkPoint::Make(fTarget.fX, fTarget.fY); 720 SkPoint target2 = SkPoint::Make(fTarget.fX, fTarget.fY);
721 matrix.mapPoints(&target2, 1); 721 matrix.mapPoints(&target2, 1);
722 SkPoint targetZ = SkPoint::Make(fTarget.fZ, fTarget.fZ); 722 SkPoint targetZ = SkPoint::Make(fTarget.fZ, fTarget.fZ);
723 matrix.mapVectors(&targetZ, 1); 723 matrix.mapVectors(&targetZ, 1);
(...skipping 24 matching lines...) Expand all
748 } 748 }
749 virtual GrGLLight* createGLLight() const SK_OVERRIDE { 749 virtual GrGLLight* createGLLight() const SK_OVERRIDE {
750 #if SK_SUPPORT_GPU 750 #if SK_SUPPORT_GPU
751 return SkNEW(GrGLSpotLight); 751 return SkNEW(GrGLSpotLight);
752 #else 752 #else
753 SkDEBUGFAIL("Should not call in GPU-less build"); 753 SkDEBUGFAIL("Should not call in GPU-less build");
754 return NULL; 754 return NULL;
755 #endif 755 #endif
756 } 756 }
757 virtual bool requiresFragmentPosition() const SK_OVERRIDE { return true; } 757 virtual bool requiresFragmentPosition() const SK_OVERRIDE { return true; }
758 virtual LightType type() const { return kSpot_LightType; } 758 virtual LightType type() const SK_OVERRIDE { return kSpot_LightType; }
759 const SkPoint3& location() const { return fLocation; } 759 const SkPoint3& location() const { return fLocation; }
760 const SkPoint3& target() const { return fTarget; } 760 const SkPoint3& target() const { return fTarget; }
761 SkScalar specularExponent() const { return fSpecularExponent; } 761 SkScalar specularExponent() const { return fSpecularExponent; }
762 SkScalar cosInnerConeAngle() const { return fCosInnerConeAngle; } 762 SkScalar cosInnerConeAngle() const { return fCosInnerConeAngle; }
763 SkScalar cosOuterConeAngle() const { return fCosOuterConeAngle; } 763 SkScalar cosOuterConeAngle() const { return fCosOuterConeAngle; }
764 SkScalar coneScale() const { return fConeScale; } 764 SkScalar coneScale() const { return fConeScale; }
765 const SkPoint3& s() const { return fS; } 765 const SkPoint3& s() const { return fS; }
766 766
767 SkSpotLight(SkReadBuffer& buffer) : INHERITED(buffer) { 767 SkSpotLight(SkReadBuffer& buffer) : INHERITED(buffer) {
768 fLocation = readPoint3(buffer); 768 fLocation = readPoint3(buffer);
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 1698
1699 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); 1699 fsBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight);
1700 } 1700 }
1701 1701
1702 #endif 1702 #endif
1703 1703
1704 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) 1704 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter)
1705 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) 1705 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter)
1706 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) 1706 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter)
1707 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END 1707 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
OLDNEW
« no previous file with comments | « src/effects/SkColorMatrixFilter.cpp ('k') | src/effects/gradients/SkLinearGradient.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698