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_CLIENT_CORE_RENDER_RS_SHADER_FILTER_H 17 #define RENDER_SERVICE_CLIENT_CORE_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 MAGNIFIER, 44 WATER_RIPPLE, 45 }; 46 GetShaderFilterType()47 ShaderFilterType GetShaderFilterType() const 48 { 49 return type_; 50 } 51 PreProcess(std::shared_ptr<Drawing::Image> & image)52 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)53 virtual std::shared_ptr<Drawing::Image> ProcessImage(Drawing::Canvas& canvas, 54 const std::shared_ptr<Drawing::Image> image, const Drawing::Rect& src, const Drawing::Rect& dst) 55 { 56 return image; 57 } 58 GenerateGEVisualEffect(std::shared_ptr<Drawing::GEVisualEffectContainer> visualEffectContainer)59 virtual void GenerateGEVisualEffect(std::shared_ptr<Drawing::GEVisualEffectContainer> visualEffectContainer) {}; PostProcess(Drawing::Canvas & canvas)60 virtual void PostProcess(Drawing::Canvas& canvas) {}; 61 Hash()62 uint32_t Hash() const 63 { 64 return hash_; 65 } 66 67 protected: 68 ShaderFilterType type_; 69 uint32_t hash_ = 0; 70 }; 71 } // namespace Rosen 72 } // namespace OHOS 73 74 #endif // RENDER_SERVICE_CLIENT_CORE_RENDER_RS_SHADER_FILTER_H