1 /* 2 * Copyright (c) 2022 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 HORIZONTAL_BLUR_FILTER_H 17 #define HORIZONTAL_BLUR_FILTER_H 18 19 #include "algo_filter.h" 20 21 namespace OHOS { 22 namespace Rosen { 23 class HorizontalBlurFilter : public AlgoFilter { 24 public: 25 static constexpr int RADIUS = 3; 26 static constexpr float DEFAULT_WEIGHT_ONE = 0.227f; 27 static constexpr float DEFAULT_WEIGHT_TWO = 0.316f; 28 static constexpr float DEFAULT_WEIGHT_THREE = 0.070f; 29 static constexpr float DEFAULT_OFFSET_ONE = 0.0; 30 static constexpr float DEFAULT_OFFSET_TWO = 1.385f; 31 static constexpr float DEFAULT_OFFSET_THREE = 3.231f; 32 33 HorizontalBlurFilter(); ~HorizontalBlurFilter()34 virtual ~HorizontalBlurFilter() {}; 35 void SetValue(const std::string& key, std::shared_ptr<void> value, int size) override; 36 std::string GetFragmentShader() override; 37 std::string GetVertexShader() override; 38 39 private: 40 void LoadFilterParams() override; 41 GLint weightID_ = 0; 42 GLint offsetID_ = 0; 43 float weight_[RADIUS] = {DEFAULT_WEIGHT_ONE, DEFAULT_WEIGHT_TWO, DEFAULT_WEIGHT_THREE}; 44 float offset_[RADIUS] = {DEFAULT_OFFSET_ONE, DEFAULT_OFFSET_TWO, DEFAULT_OFFSET_THREE}; 45 }; 46 } // namespace Rosen 47 } // namespace OHOS 48 #endif // HORIZONTAL_BLUR_FILTER_H 49 50