diff --git a/gn/effects_imagefilters.gni b/gn/effects_imagefilters.gni index 5a90ef4052..a72eaca76d 100644 --- a/gn/effects_imagefilters.gni +++ b/gn/effects_imagefilters.gni @@ -21,7 +21,6 @@ skia_effects_imagefilter_sources = [ "$_src/effects/imagefilters/SkImageFilters.cpp", "$_src/effects/imagefilters/SkImageImageFilter.cpp", "$_src/effects/imagefilters/SkLightingImageFilter.cpp", - "$_src/effects/imagefilters/SkLightingImageFilter.h", "$_src/effects/imagefilters/SkMagnifierImageFilter.cpp", "$_src/effects/imagefilters/SkMagnifierImageFilter.h", "$_src/effects/imagefilters/SkMatrixConvolutionImageFilter.cpp", diff --git a/src/core/SkImageFilter_Base.h b/src/core/SkImageFilter_Base.h index a2ce56af35..d024c0da43 100644 --- a/src/core/SkImageFilter_Base.h +++ b/src/core/SkImageFilter_Base.h @@ -492,5 +492,6 @@ void SkRegisterComposeImageFilterFlattenable(); void SkRegisterDisplacementMapImageFilterFlattenable(); void SkRegisterDropShadowImageFilterFlattenable(); void SkRegisterImageImageFilterFlattenable(); +void SkRegisterLightingImageFilterFlattenables(); #endif // SkImageFilter_Base_DEFINED diff --git a/src/effects/imagefilters/SkImageFilters.cpp b/src/effects/imagefilters/SkImageFilters.cpp index 56f4262f3c..b711afc488 100644 --- a/src/effects/imagefilters/SkImageFilters.cpp +++ b/src/effects/imagefilters/SkImageFilters.cpp @@ -9,7 +9,6 @@ #include "include/core/SkPaint.h" -#include "src/effects/imagefilters/SkLightingImageFilter.h" #include "src/effects/imagefilters/SkMagnifierImageFilter.h" #include "src/effects/imagefilters/SkMatrixConvolutionImageFilter.h" #include "src/effects/imagefilters/SkMergeImageFilter.h" @@ -25,7 +24,6 @@ void SkImageFilters::RegisterFlattenables() { SkDilateImageFilter::RegisterFlattenables(); - SkLightingImageFilter::RegisterFlattenables(); SkMagnifierImageFilter::RegisterFlattenables(); SkMatrixConvolutionImageFilter::RegisterFlattenables(); SkMergeImageFilter::RegisterFlattenables(); @@ -121,51 +119,3 @@ sk_sp SkImageFilters::Erode( SkScalar radiusX, SkScalar radiusY, sk_sp input, const CropRect& cropRect) { return SkErodeImageFilter::Make(radiusX, radiusY, std::move(input), cropRect); } - -// Lighting filter effects - -sk_sp SkImageFilters::DistantLitDiffuse( - const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const CropRect& cropRect) { - return SkLightingImageFilter::MakeDistantLitDiffuse(direction, lightColor, surfaceScale, kd, - std::move(input), cropRect); -} - -sk_sp SkImageFilters::PointLitDiffuse( - const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const CropRect& cropRect) { - return SkLightingImageFilter::MakePointLitDiffuse(location, lightColor, surfaceScale, kd, - std::move(input), cropRect); -} - -sk_sp SkImageFilters::SpotLitDiffuse( - const SkPoint3& location, const SkPoint3& target, SkScalar falloffExponent, - SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const CropRect& cropRect) { - return SkLightingImageFilter::MakeSpotLitDiffuse(location, target, falloffExponent, cutoffAngle, - lightColor, surfaceScale, kd, - std::move(input), cropRect); -} - -sk_sp SkImageFilters::DistantLitSpecular( - const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, - SkScalar shininess, sk_sp input, const CropRect& cropRect) { - return SkLightingImageFilter::MakeDistantLitSpecular(direction, lightColor, surfaceScale, - ks, shininess, std::move(input), cropRect); -} - -sk_sp SkImageFilters::PointLitSpecular( - const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, - SkScalar shininess, sk_sp input, const CropRect& cropRect) { - return SkLightingImageFilter::MakePointLitSpecular(location, lightColor, surfaceScale, ks, - shininess, std::move(input), cropRect); -} - -sk_sp SkImageFilters::SpotLitSpecular( - const SkPoint3& location, const SkPoint3& target, SkScalar falloffExponent, - SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, - SkScalar shininess, sk_sp input, const CropRect& cropRect) { - return SkLightingImageFilter::MakeSpotLitSpecular(location, target, falloffExponent, - cutoffAngle, lightColor, surfaceScale, - ks, shininess, std::move(input), cropRect); -} diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp index 1309f1aebf..e768e7fcd5 100644 --- a/src/effects/imagefilters/SkLightingImageFilter.cpp +++ b/src/effects/imagefilters/SkLightingImageFilter.cpp @@ -5,11 +5,10 @@ * found in the LICENSE file. */ -#include "src/effects/imagefilters/SkLightingImageFilter.h" - #include "include/core/SkBitmap.h" #include "include/core/SkPoint3.h" #include "include/core/SkTypes.h" +#include "include/effects/SkImageFilters.h" #include "include/private/SkColorData.h" #include "include/private/SkTPin.h" #include "src/core/SkImageFilter_Base.h" @@ -566,7 +565,7 @@ protected: private: SK_FLATTENABLE_HOOKS(SkDiffuseLightingImageFilter) - friend class SkLightingImageFilter; + friend void ::SkRegisterLightingImageFilterFlattenables(); SkScalar fKD; using INHERITED = SkLightingImageFilterInternal; @@ -601,10 +600,11 @@ protected: private: SK_FLATTENABLE_HOOKS(SkSpecularLightingImageFilter) + friend void ::SkRegisterLightingImageFilterFlattenables(); SkScalar fKS; SkScalar fShininess; - friend class SkLightingImageFilter; + using INHERITED = SkLightingImageFilterInternal; }; @@ -1140,58 +1140,63 @@ void SkImageFilterLight::flattenLight(SkWriteBuffer& buffer) const { } /////////////////////////////////////////////////////////////////////////////// -sk_sp SkLightingImageFilter::MakeDistantLitDiffuse( +sk_sp SkImageFilters::DistantLitDiffuse( const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const SkRect* cropRect) { + sk_sp input, const CropRect& cropRect) { sk_sp light(new SkDistantLight(direction, lightColor)); return SkDiffuseLightingImageFilter::Make(std::move(light), surfaceScale, kd, std::move(input), cropRect); } -sk_sp SkLightingImageFilter::MakePointLitDiffuse( +sk_sp SkImageFilters::PointLitDiffuse( const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const SkRect* cropRect) { + sk_sp input, const CropRect& cropRect) { sk_sp light(new SkPointLight(location, lightColor)); return SkDiffuseLightingImageFilter::Make(std::move(light), surfaceScale, kd, std::move(input), cropRect); } -sk_sp SkLightingImageFilter::MakeSpotLitDiffuse( - const SkPoint3& location, const SkPoint3& target, SkScalar specularExponent, +sk_sp SkImageFilters::SpotLitDiffuse( + const SkPoint3& location, const SkPoint3& target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const SkRect* cropRect) { - sk_sp light( - new SkSpotLight(location, target, specularExponent, cutoffAngle, lightColor)); + sk_sp input, const CropRect& cropRect) { + sk_sp light(new SkSpotLight(location, target, falloffExponent, + cutoffAngle, lightColor)); return SkDiffuseLightingImageFilter::Make(std::move(light), surfaceScale, kd, std::move(input), cropRect); } -sk_sp SkLightingImageFilter::MakeDistantLitSpecular( - const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, - SkScalar shininess, sk_sp input, const SkRect* cropRect) { +sk_sp SkImageFilters::DistantLitSpecular( + const SkPoint3& direction, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, + SkScalar shininess, sk_sp input, const CropRect& cropRect) { sk_sp light(new SkDistantLight(direction, lightColor)); return SkSpecularLightingImageFilter::Make(std::move(light), surfaceScale, ks, shininess, std::move(input), cropRect); } -sk_sp SkLightingImageFilter::MakePointLitSpecular( +sk_sp SkImageFilters::PointLitSpecular( const SkPoint3& location, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, - SkScalar shininess, sk_sp input, const SkRect* cropRect) { + SkScalar shininess, sk_sp input, const CropRect& cropRect) { sk_sp light(new SkPointLight(location, lightColor)); return SkSpecularLightingImageFilter::Make(std::move(light), surfaceScale, ks, shininess, std::move(input), cropRect); } -sk_sp SkLightingImageFilter::MakeSpotLitSpecular( - const SkPoint3& location, const SkPoint3& target, SkScalar specularExponent, +sk_sp SkImageFilters::SpotLitSpecular( + const SkPoint3& location, const SkPoint3& target, SkScalar falloffExponent, SkScalar cutoffAngle, SkColor lightColor, SkScalar surfaceScale, SkScalar ks, - SkScalar shininess, sk_sp input, const SkRect* cropRect) { - sk_sp light( - new SkSpotLight(location, target, specularExponent, cutoffAngle, lightColor)); + SkScalar shininess, sk_sp input, const CropRect& cropRect) { + sk_sp light(new SkSpotLight(location, target, falloffExponent, + cutoffAngle, lightColor)); return SkSpecularLightingImageFilter::Make(std::move(light), surfaceScale, ks, shininess, std::move(input), cropRect); } +void SkRegisterLightingImageFilterFlattenables() { + SK_REGISTER_FLATTENABLE(SkDiffuseLightingImageFilter); + SK_REGISTER_FLATTENABLE(SkSpecularLightingImageFilter); +} + /////////////////////////////////////////////////////////////////////////////// sk_sp SkDiffuseLightingImageFilter::Make(sk_sp light, @@ -2109,8 +2114,3 @@ void GrGLSpotLight::emitLightColor(const GrFragmentProcessor* owner, } #endif - -void SkLightingImageFilter::RegisterFlattenables() { - SK_REGISTER_FLATTENABLE(SkDiffuseLightingImageFilter); - SK_REGISTER_FLATTENABLE(SkSpecularLightingImageFilter); -} diff --git a/src/effects/imagefilters/SkLightingImageFilter.h b/src/effects/imagefilters/SkLightingImageFilter.h deleted file mode 100644 index cdcbd529de..0000000000 --- a/src/effects/imagefilters/SkLightingImageFilter.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2012 The Android Open Source Project - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkLightingImageFilter_DEFINED -#define SkLightingImageFilter_DEFINED - -#include "include/core/SkColor.h" -#include "include/core/SkImageFilter.h" - -struct SkPoint3; - -// DEPRECATED: Use include/effects/SkImageFilters::[Diffuse|Specular]Light[Distant|Point|Spot] -class SK_API SkLightingImageFilter { -public: - static sk_sp MakeDistantLitDiffuse(const SkPoint3& direction, - SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const SkRect* cropRect = nullptr); - static sk_sp MakePointLitDiffuse(const SkPoint3& location, - SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const SkRect* cropRect = nullptr); - static sk_sp MakeSpotLitDiffuse(const SkPoint3& location, - const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle, - SkColor lightColor, SkScalar surfaceScale, SkScalar kd, - sk_sp input, const SkRect* cropRect = nullptr); - static sk_sp MakeDistantLitSpecular(const SkPoint3& direction, - SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, - sk_sp input, const SkRect* cropRect = nullptr); - static sk_sp MakePointLitSpecular(const SkPoint3& location, - SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, - sk_sp input, const SkRect* cropRect = nullptr); - static sk_sp MakeSpotLitSpecular(const SkPoint3& location, - const SkPoint3& target, SkScalar specularExponent, SkScalar cutoffAngle, - SkColor lightColor, SkScalar surfaceScale, SkScalar ks, SkScalar shininess, - sk_sp input, const SkRect* cropRect = nullptr); - - static void RegisterFlattenables(); - -private: - SkLightingImageFilter() = delete; -}; - -#endif diff --git a/src/ports/SkGlobalInitialization_default.cpp b/src/ports/SkGlobalInitialization_default.cpp index 24f0e35c2e..59254ec925 100644 --- a/src/ports/SkGlobalInitialization_default.cpp +++ b/src/ports/SkGlobalInitialization_default.cpp @@ -125,6 +125,7 @@ SkRegisterDisplacementMapImageFilterFlattenable(); SkRegisterDropShadowImageFilterFlattenable(); SkRegisterImageImageFilterFlattenable(); + SkRegisterLightingImageFilterFlattenables(); SK_REGISTER_FLATTENABLE(SkLocalMatrixImageFilter); SK_REGISTER_FLATTENABLE(SkMatrixImageFilter); }