/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef GRAPHICS_EFFECT_GE_VISUAL_EFFECT_IMPL_H #define GRAPHICS_EFFECT_GE_VISUAL_EFFECT_IMPL_H #include #include #include #include "ge_shader.h" #include "ge_shader_filter.h" #include "ge_shader_filter_params.h" #include "ge_visual_effect.h" #include "common/rs_vector3.h" #include "common/rs_vector4.h" #include "effect/color_filter.h" #include "effect/runtime_effect.h" #include "effect/runtime_shader_builder.h" #include "utils/rect.h" namespace OHOS { namespace Rosen { namespace Drawing { class GE_EXPORT GEVisualEffectImpl { public: enum class FilterType { NONE, KAWASE_BLUR, MESA_BLUR, GREY, AIBAR, LINEAR_GRADIENT_BLUR, MAGNIFIER, WATER_RIPPLE, DISPLACEMENT_DISTORT_FILTER, COLOR_GRADIENT, MASK_TRANSITION, // Mask RIPPLE_MASK, DOUBLE_RIPPLE_MASK, PIXEL_MAP_MASK, RADIAL_GRADIENT_MASK, WAVE_GRADIENT_MASK, // Shader DOT_MATRIX, FLOW_LIGHT_SWEEP, COMPLEX_SHADER, SOUND_WAVE, EDGE_LIGHT, BEZIER_WARP, DISPERSION, CONTENT_LIGHT, BORDER_LIGHT, CONTOUR_DIAGONAL_FLOW_LIGHT, WAVY_RIPPLE_LIGHT, AURORA_NOISE, PARTICLE_CIRCULAR_HALO, DIRECTION_LIGHT, VARIABLE_RADIUS_BLUR, COLOR_GRADIENT_EFFECT, LIGHT_CAVE, MAX }; GEVisualEffectImpl(const std::string& name); ~GEVisualEffectImpl(); void SetParam(const std::string& tag, int32_t param); void SetParam(const std::string& tag, int64_t param); void SetParam(const std::string& tag, float param); void SetParam(const std::string& tag, double param); void SetParam(const std::string& tag, const char* const param); void SetParam(const std::string& tag, const std::shared_ptr param); void SetParam(const std::string& tag, const std::shared_ptr param); void SetParam(const std::string& tag, const Drawing::Matrix param); void SetParam(const std::string& tag, const std::pair& param); void SetParam(const std::string& tag, const std::vector>& param); void SetParam(const std::string& tag, const std::vector& param); void SetParam(const std::string& tag, const std::array& param); void SetParam(const std::string& tag, bool param); void SetParam(const std::string& tag, uint32_t param); void SetParam(const std::string& tag, const std::vector& param); void SetParam(const std::string& tag, const std::shared_ptr param); void SetParam(const std::string& tag, const Drawing::Color4f& param); void SetParam(const std::string& tag, const Vector3f& param); void SetParam(const std::string& tag, const Vector4f& param); void SetParam(const std::string& tag, const RectF& param); void SetFilterType(FilterType type) { filterType_ = type; } const FilterType& GetFilterType() const { return filterType_; } void MakeMESAParams() { mesaParams_ = std::make_shared(); } const std::shared_ptr& GetMESAParams() const { return mesaParams_; } void MakeKawaseParams() { kawaseParams_ = std::make_shared(); } const std::shared_ptr& GetKawaseParams() const { return kawaseParams_; } void MakeWaterRippleParams() { waterRippleParams_ = std::make_shared(); } const std::shared_ptr& GetWaterRippleParams() const { return waterRippleParams_; } void MakeAIBarParams() { aiBarParams_ = std::make_shared(); } const std::shared_ptr& GetAIBarParams() const { return aiBarParams_; } void MakeGreyParams() { greyParams_ = std::make_shared(); } const std::shared_ptr& GetGreyParams() const { return greyParams_; } void MakeLinearGradientBlurParams() { linearGradientBlurParams_ = std::make_shared(); } const std::shared_ptr& GetLinearGradientBlurParams() const { return linearGradientBlurParams_; } void MakeMagnifierParams() { magnifierParams_ = std::make_shared(); } const std::shared_ptr& GetMagnifierParams() const { return magnifierParams_; } void MakeColorGradientParams() { colorGradientParams_ = std::make_shared(); } const std::shared_ptr& GetColorGradientParams() const { return colorGradientParams_; } void MakeDisplacementDistortParams() { displacementDistortParams_ = std::make_shared(); } const std::shared_ptr &GetDisplacementDistortParams() const { return displacementDistortParams_; } void MakeSoundWaveParams() { soundWaveParams_ = std::make_shared(); } const std::shared_ptr& GetSoundWaveParams() const { return soundWaveParams_; } void MakeEdgeLightParams() { edgeLightParams_ = std::make_shared(); } const std::shared_ptr& GetEdgeLightParams() const { return edgeLightParams_; } void MakeBezierWarpParams() { bezierWarpParams_ = std::make_shared(); } const std::shared_ptr& GetBezierWarpParams() const { return bezierWarpParams_; } void MakeDispersionParams() { dispersionParams_ = std::make_shared(); } const std::shared_ptr& GetDispersionParams() const { return dispersionParams_; } void MakeDirectionLightParams() { directionLightParams_ = std::make_shared(); } const std::shared_ptr& GetDirectionLightParams() const { return directionLightParams_; } void MakeContentLightParams() { contentLightParams_ = std::make_shared(); } const std::shared_ptr& GetContentLightParams() const { return contentLightParams_; } void MakeContentDiagonalParams() { contentDiagonalParams_ = std::make_shared(); } const std::shared_ptr& GetContenDiagonalParams() const { return contentDiagonalParams_; } void MakeWavyRippleLightParams() { wavyRippleLightParams_ = std::make_shared(); } const std::shared_ptr& GetWavyRippleLightParams() const { return wavyRippleLightParams_; } void MakeAuroraNoiseParams() { auroNoiseParams_ = std::make_shared(); } const std::shared_ptr& GetAuroraNoiseParams() const { return auroNoiseParams_; } void MakeParticleCircularHaloParams() { particleCircularHaloParams_ = std::make_shared(); } const std::shared_ptr& GetParticleCircularHaloParams() const { return particleCircularHaloParams_; } void SetCache(std::shared_ptr cacheData) { cacheAnyPtr_ = cacheData; } std::shared_ptr GetCache() { return cacheAnyPtr_; } void MakeRippleMaskParams() { rippleMaskParams_ = std::make_shared(); } const std::shared_ptr& GetRippleMaskParams() const { return rippleMaskParams_; } void MakeDoubleRippleMaskParams() { doubleRippleMaskParams_ = std::make_shared(); } const std::shared_ptr& GetDoubleRippleMaskParams() const { return doubleRippleMaskParams_; } void MakeRadialGradientMaskParams() { radialGradientMaskParams_ = std::make_shared(); } const std::shared_ptr& GetRadialGradientMaskParams() const { return radialGradientMaskParams_; } void MakePixelMapMaskParams() { pixelMapMaskParams_ = std::make_shared(); } const std::shared_ptr& GetPixelMapMaskParams() const { return pixelMapMaskParams_; } void MakeWaveGradientMaskParams() { waveGradientMaskParams_ = std::make_shared(); } const std::shared_ptr& GetWaveGradientMaskParams() const { return waveGradientMaskParams_; } void MakeMaskTransitionParams() { maskTransitionParams_ = std::make_shared(); } const std::shared_ptr& GetMaskTransitionParams() const { return maskTransitionParams_; } void MakeVariableRadiusBlurParams() { variableRadiusBlurParams_ = std::make_shared(); } const std::shared_ptr& GetVariableRadiusBlurParams() const { return variableRadiusBlurParams_; } void MakeColorGradientEffectParams() { colorGradientEffectParams_ = std::make_shared(); } const std::shared_ptr& GetColorGradientEffectParams() const { return colorGradientEffectParams_; } void MakeLightCaveParams() { lightCaveShaderParams_ = std::make_shared(); } const std::shared_ptr& GetLightCaveParams() const { return lightCaveShaderParams_; } void MakeBorderLightParams() { borderLightParams_ = std::make_shared(); } const std::shared_ptr& GetBorderLightParams() const { return borderLightParams_; } private: static std::map> g_initialMap; std::shared_ptr cacheAnyPtr_ = nullptr; void SetMESABlurParams(const std::string& tag, float param); void SetAIBarParams(const std::string& tag, float param); void SetGreyParams(const std::string& tag, float param); void SetLinearGradientBlurParams(const std::string& tag, float param); void SetMagnifierParamsFloat(const std::string& tag, float param); void SetMagnifierParamsUint32(const std::string& tag, uint32_t param); void SetWaterRippleParams(const std::string& tag, float param); void SetRippleMaskParamsFloat(const std::string& tag, float param); void SetDoubleRippleMaskParamsFloat(const std::string& tag, float param); void SetRadialGradientMaskParamsFloat(const std::string& tag, float param); void SetWaveGradientMaskParamsFloat(const std::string& tag, float param); void SetSoundWaveParams(const std::string& tag, float param); void SetSoundWaveParams(const std::string& tag, const Drawing::Color4f& param); void SetDirectionLightParamsFloat(const std::string& tag, float param); void SetEdgeLightParams(const std::string& tag, float param); void SetDispersionParams(const std::string& tag, float param); void SetDispersionParams(const std::string& tag, const std::pair& param); void SetContentLightParams(const std::string& tag, float param); void SetContentDiagonalFlowParams(const std::string& tag, const Vector4f& param); void SetContentDiagonalFlowParams(const std::string& tag, float param); void SetWavyRippleLightParams(const std::string& tag, float param); void SetWavyRippleLightParams(const std::string& tag, const std::pair& param); void SetAuroraNoiseParams(const std::string& tag, float param); void SetPixelMapMaskParams(const std::string& tag, const RectF& param); void SetPixelMapMaskParams(const std::string& tag, const Vector4f& param); void SetParticleCircularHaloParams(const std::string& tag, float param); void SetParticleCircularHaloParams(const std::string& tag, const std::pair& param); void SetMaskTransitionParamsFloat(const std::string& tag, float param); void SetVariableRadiusBlurParams(const std::string& tag, float param); void SetColorGradientEffectParams(const std::string& tag, float param); void SetColorGradientEffectParams(const std::string& tag, const Vector4f& param); void SetColorGradientEffectParams(const std::string& tag, const std::pair& param); void SetBezierWarpParams(const std::string& tag, const std::pair& param); void SetLightCaveParams(const std::string& tag, const Vector4f& param); void SetLightCaveParams(const std::string& tag, const std::pair& param); void SetLightCaveParams(const std::string& tag, float param); void SetBorderLightParams(const std::string& tag, const Vector3f& param); void SetBorderLightParams(const std::string& tag, const Vector4f& param); void SetBorderLightParams(const std::string& tag, float param); FilterType filterType_ = GEVisualEffectImpl::FilterType::NONE; // ShaderFilter Params std::shared_ptr kawaseParams_ = nullptr; std::shared_ptr mesaParams_ = nullptr; std::shared_ptr aiBarParams_ = nullptr; std::shared_ptr colorGradientParams_ = nullptr; std::shared_ptr greyParams_ = nullptr; std::shared_ptr linearGradientBlurParams_ = nullptr; std::shared_ptr magnifierParams_ = nullptr; std::shared_ptr waterRippleParams_ = nullptr; std::shared_ptr radialGradientMaskParams_ = nullptr; std::shared_ptr pixelMapMaskParams_ = nullptr; std::shared_ptr rippleMaskParams_ = nullptr; std::shared_ptr doubleRippleMaskParams_ = nullptr; std::shared_ptr waveGradientMaskParams_ = nullptr; std::shared_ptr displacementDistortParams_ = nullptr; std::shared_ptr soundWaveParams_ = nullptr; std::shared_ptr edgeLightParams_ = nullptr; std::shared_ptr bezierWarpParams_ = nullptr; std::shared_ptr dispersionParams_ = nullptr; std::shared_ptr contentLightParams_ = nullptr; std::shared_ptr directionLightParams_ = nullptr; std::shared_ptr maskTransitionParams_ = nullptr; std::shared_ptr contentDiagonalParams_ = nullptr; std::shared_ptr wavyRippleLightParams_ = nullptr; std::shared_ptr auroNoiseParams_ = nullptr; std::shared_ptr particleCircularHaloParams_ = nullptr; std::shared_ptr variableRadiusBlurParams_ = nullptr; std::shared_ptr colorGradientEffectParams_ = nullptr; std::shared_ptr lightCaveShaderParams_ = nullptr; std::shared_ptr borderLightParams_ = nullptr; }; } // namespace Drawing } // namespace Rosen } // namespace OHOS #endif // GRAPHICS_EFFECT_GE_VISUAL_EFFECT_IMPL_H