• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
52     static std::shared_ptr<TestingImageFilter> CreateColorFilterImageFilter(
53         const TestingColorFilter& cf, std::shared_ptr<TestingImageFilter> input,
54         const TestingRect& filterRect = noCropRect)
55     {
56         return std::make_shared<TestingImageFilter>();
57     }
58 
59     static std::shared_ptr<TestingImageFilter> CreateArithmeticImageFilter(const std::vector<scalar>& coefficients,
60         bool enforcePMColor, std::shared_ptr<TestingImageFilter> background,
61         std::shared_ptr<TestingImageFilter> foreground, const TestingRect& filterRect = noCropRect)
62     {
63         return std::make_shared<TestingImageFilter>();
64     }
65 
66     static std::shared_ptr<TestingImageFilter> CreateOffsetImageFilter(
67         scalar dx, scalar dy, std::shared_ptr<TestingImageFilter> input, const TestingRect& filterRect = noCropRect)
68     {
69         return std::make_shared<TestingImageFilter>();
70     }
71 
72     static std::shared_ptr<TestingImageFilter> CreateBlendImageFilter(BlendMode mode,
73         std::shared_ptr<TestingImageFilter> background, std::shared_ptr<TestingImageFilter> foreground = nullptr,
74         const TestingRect& filterRect = noCropRect)
75     {
76         return std::make_shared<TestingImageFilter>();
77     }
78 
79     static std::shared_ptr<TestingImageFilter> CreateShaderImageFilter(
80         std::shared_ptr<TestingShaderEffect> shader, const Rect& rect = {})
81     {
82         return std::make_shared<TestingImageFilter>();
83     }
84 };
85 } // namespace OHOS::Ace::Testing
86 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_IMAGE_FILTER_H
87