1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef RENDER_SERVICE_BASE_RENDER_RENDER_RS_SHADER_FILTER_H 17 #define RENDER_SERVICE_BASE_RENDER_RENDER_RS_SHADER_FILTER_H 18 19 #include "draw/canvas.h" 20 #include "effect/runtime_shader_builder.h" 21 #include "ge_visual_effect.h" 22 #include "ge_visual_effect_container.h" 23 #include "render/rs_filter.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 class RSPaintFilterCanvas; 28 class RSB_EXPORT RSShaderFilter { 29 public: 30 RSShaderFilter() = default; 31 RSShaderFilter(const RSShaderFilter&) = delete; 32 RSShaderFilter operator=(const RSShaderFilter&) = delete; 33 virtual ~RSShaderFilter() = default; 34 35 enum ShaderFilterType { 36 NONE = 0, 37 KAWASE, 38 MESA, 39 GREY, 40 AIBAR, 41 LINEAR_GRADIENT_BLUR, 42 MASK_COLOR, 43 WATER_RIPPLE, 44 MAGNIFIER, 45 LIGHT_BLUR, 46 ALWAYS_SNAPSHOT, 47 DISPLACEMENT_DISTORT, 48 COLOR_GRADIENT, 49 SOUND_WAVE, 50 EDGE_LIGHT, 51 BEZIER_WARP, 52 DISPERSION, 53 CONTENT_LIGHT, 54 }; 55 GetShaderFilterType()56 ShaderFilterType GetShaderFilterType() const 57 { 58 return type_; 59 } 60 PreProcess(std::shared_ptr<Drawing::Image> & image)61 virtual void PreProcess(std::shared_ptr<Drawing::Image>& image) {}; ProcessImage(Drawing::Canvas & canvas,const std::shared_ptr<Drawing::Image> image,const Drawing::Rect & src,const Drawing::Rect & dst)62 virtual std::shared_ptr<Drawing::Image> ProcessImage(Drawing::Canvas& canvas, 63 const std::shared_ptr<Drawing::Image> image, const Drawing::Rect& src, const Drawing::Rect& dst) 64 { 65 return image; 66 } 67 GenerateGEVisualEffect(std::shared_ptr<Drawing::GEVisualEffectContainer> visualEffectContainer)68 virtual void GenerateGEVisualEffect(std::shared_ptr<Drawing::GEVisualEffectContainer> visualEffectContainer) {}; PostProcess(Drawing::Canvas & canvas)69 virtual void PostProcess(Drawing::Canvas& canvas) {}; 70 Hash()71 uint32_t Hash() const 72 { 73 return hash_; 74 } 75 76 protected: 77 ShaderFilterType type_; 78 uint32_t hash_ = 0; 79 }; 80 } // namespace Rosen 81 } // namespace OHOS 82 83 #endif // RENDER_SERVICE_BASE_RENDER_RENDER_RS_SHADER_FILTER_H