1 /* 2 * Copyright (c) 2023-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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_IMAGE_FILTER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_IMAGE_FILTER_H 18 19 #include <memory> 20 21 #include "base/geometry/rect.h" 22 #include "testing_color_filter.h" 23 #include "testing_enums.h" 24 #include "testing_image_blur_type.h" 25 #include "testing_rect.h" 26 #include "testing_shader_effect.h" 27 28 namespace OHOS::Ace::Testing { 29 static const TestingRect noCropRect(0.0, 0.0, 0.0, 0.0); 30 enum class FilterType { 31 NO_TYPE, 32 BLUR, 33 COLOR, 34 OFFSET, 35 ARITHMETIC, 36 COMPOSE, 37 }; 38 39 class TestingImageFilter { 40 public: 41 typedef float scalar; 42 TestingImageFilter() = default; 43 ~TestingImageFilter() = default; 44 45 static std::shared_ptr<TestingImageFilter> CreateBlurImageFilter( 46 float sigmaX, float sigmaY, TileMode mode, std::shared_ptr<TestingImageFilter> input, 47 ImageBlurType imageBlurType = ImageBlurType::GAUSS, const TestingRect& filterRect = noCropRect) 48 { 49 return std::make_shared<TestingImageFilter>(); 50 } 51 CreateColorFilterImageFilter(const TestingColorFilter & cf,std::shared_ptr<TestingImageFilter> input)52 static std::shared_ptr<TestingImageFilter> CreateColorFilterImageFilter( 53 const TestingColorFilter& cf, std::shared_ptr<TestingImageFilter> input) 54 { 55 return std::make_shared<TestingImageFilter>(); 56 } 57 CreateArithmeticImageFilter(const std::vector<scalar> & coefficients,bool enforcePMColor,std::shared_ptr<TestingImageFilter> background,std::shared_ptr<TestingImageFilter> foreground)58 static std::shared_ptr<TestingImageFilter> CreateArithmeticImageFilter(const std::vector<scalar>& coefficients, 59 bool enforcePMColor, std::shared_ptr<TestingImageFilter> background, 60 std::shared_ptr<TestingImageFilter> foreground) 61 { 62 return std::make_shared<TestingImageFilter>(); 63 } 64 CreateOffsetImageFilter(scalar dx,scalar dy,std::shared_ptr<TestingImageFilter> input)65 static std::shared_ptr<TestingImageFilter> CreateOffsetImageFilter( 66 scalar dx, scalar dy, std::shared_ptr<TestingImageFilter> input) 67 { 68 return std::make_shared<TestingImageFilter>(); 69 } 70 71 static std::shared_ptr<TestingImageFilter> CreateBlendImageFilter(BlendMode mode, 72 std::shared_ptr<TestingImageFilter> background, std::shared_ptr<TestingImageFilter> foreground = nullptr) 73 { 74 return std::make_shared<TestingImageFilter>(); 75 } 76 77 static std::shared_ptr<TestingImageFilter> CreateShaderImageFilter( 78 std::shared_ptr<TestingShaderEffect> shader, const Rect& rect = {}) 79 { 80 return std::make_shared<TestingImageFilter>(); 81 } 82 }; 83 } // namespace OHOS::Ace::Testing 84 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_IMAGE_FILTER_H 85