OLD | NEW |
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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 class GrGLLight; | 736 class GrGLLight; |
737 | 737 |
738 #endif | 738 #endif |
739 | 739 |
740 }; | 740 }; |
741 | 741 |
742 /////////////////////////////////////////////////////////////////////////////// | 742 /////////////////////////////////////////////////////////////////////////////// |
743 | 743 |
744 class SkImageFilterLight : public SkRefCnt { | 744 class SkImageFilterLight : public SkRefCnt { |
745 public: | 745 public: |
746 | 746 |
747 | 747 |
748 enum LightType { | 748 enum LightType { |
749 kDistant_LightType, | 749 kDistant_LightType, |
750 kPoint_LightType, | 750 kPoint_LightType, |
751 kSpot_LightType, | 751 kSpot_LightType, |
752 }; | 752 }; |
753 virtual LightType type() const = 0; | 753 virtual LightType type() const = 0; |
754 const SkPoint3& color() const { return fColor; } | 754 const SkPoint3& color() const { return fColor; } |
755 virtual GrGLLight* createGLLight() const = 0; | 755 virtual GrGLLight* createGLLight() const = 0; |
756 virtual bool isEqual(const SkImageFilterLight& other) const { | 756 virtual bool isEqual(const SkImageFilterLight& other) const { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 const SkPointLight& o = static_cast<const SkPointLight&>(other); | 873 const SkPointLight& o = static_cast<const SkPointLight&>(other); |
874 return INHERITED::isEqual(other) && | 874 return INHERITED::isEqual(other) && |
875 fLocation == o.fLocation; | 875 fLocation == o.fLocation; |
876 } | 876 } |
877 SkImageFilterLight* transform(const SkMatrix& matrix) const override { | 877 SkImageFilterLight* transform(const SkMatrix& matrix) const override { |
878 SkPoint location2 = SkPoint::Make(fLocation.fX, fLocation.fY); | 878 SkPoint location2 = SkPoint::Make(fLocation.fX, fLocation.fY); |
879 matrix.mapPoints(&location2, 1); | 879 matrix.mapPoints(&location2, 1); |
880 // Use X scale and Y scale on Z and average the result | 880 // Use X scale and Y scale on Z and average the result |
881 SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ); | 881 SkPoint locationZ = SkPoint::Make(fLocation.fZ, fLocation.fZ); |
882 matrix.mapVectors(&locationZ, 1); | 882 matrix.mapVectors(&locationZ, 1); |
883 SkPoint3 location = SkPoint3::Make(location2.fX, | 883 SkPoint3 location = SkPoint3::Make(location2.fX, |
884 location2.fY, | 884 location2.fY, |
885 SkScalarAve(locationZ.fX, locationZ.f
Y)); | 885 SkScalarAve(locationZ.fX, locationZ.f
Y)); |
886 return new SkPointLight(location, color()); | 886 return new SkPointLight(location, color()); |
887 } | 887 } |
888 | 888 |
889 SkPointLight(SkReadBuffer& buffer) : INHERITED(buffer) { | 889 SkPointLight(SkReadBuffer& buffer) : INHERITED(buffer) { |
890 fLocation = readPoint3(buffer); | 890 fLocation = readPoint3(buffer); |
891 } | 891 } |
892 | 892 |
893 protected: | 893 protected: |
894 SkPointLight(const SkPoint3& location, const SkPoint3& color) | 894 SkPointLight(const SkPoint3& location, const SkPoint3& color) |
(...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 | 2118 |
2119 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); | 2119 fragBuilder->codeAppendf("%s(%s)", fLightColorFunc.c_str(), surfaceToLight); |
2120 } | 2120 } |
2121 | 2121 |
2122 #endif | 2122 #endif |
2123 | 2123 |
2124 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) | 2124 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkLightingImageFilter) |
2125 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) | 2125 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkDiffuseLightingImageFilter) |
2126 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) | 2126 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkSpecularLightingImageFilter) |
2127 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END | 2127 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END |
OLD | NEW |