1 /*
2 * Copyright (c) 2025 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_RS_HPAE_HIANIMATION_TYPES_H
17 #define RENDER_SERVICE_BASE_RS_HPAE_HIANIMATION_TYPES_H
18
19 #include <cstdint>
20
21 const uint32_t HAE_COLOR_MATRIX_COEF_COUNT = 20;
22 namespace OHOS::Rosen {
23 struct HaeRect {
24 int l;
25 int t;
26 int r;
27 int b;
28
HaeRectHaeRect29 HaeRect(int left, int top, int right, int bottom)
30 {
31 l = left;
32 t = top;
33 r = right;
34 b = bottom;
35 };
36
HaeRectHaeRect37 HaeRect()
38 {
39 l = 0;
40 t = 0;
41 r = 0;
42 b = 0;
43 };
44 };
45
46 struct HaeImage {
47 void *handle;
48 struct HaeRect rect;
49 };
50
51 struct HaePixel {
52 uint16_t a;
53 uint16_t r;
54 uint16_t g;
55 uint16_t b;
56 };
57
58 struct HaeNoiseValue {
59 float noiseRatio;
60 float noiseValue;
61 float noiseUpClip;
62 float noiseDnClip;
63 };
64
65 struct BlurImgParam {
66 uint32_t width;
67 uint32_t height;
68 float sigmaNum;
69 };
70
71 struct HaeBlurBasicAttr {
72 struct HaeImage *srcLayer;
73 struct HaeImage *dstLayer;
74 uint32_t perfLevel;
75 uint32_t timeoutMs = 0;
76 int32_t expectRunTime = -1;
77 float sigmaNum;
78 bool enablePremult;
79 };
80
81 enum BlppAbility : uint32_t {
82 BLPP_CANCEL_PREMULT_EN = 1 << 0,
83 BLPP_NOISE_EN = 1 << 1,
84 BLPP_ALPHA_REPLACE_EN = 1 << 2,
85 BLPP_COLOR_MATRIX_EN = 1 << 3,
86 BLPP_PREMULT_EN = 1 << 4,
87 BLPP_COLOR_MASK_EN = 1 << 5,
88 BLPP_CLMASK_PREMULT_EN = 1 << 6,
89 BLPP_CLMASK_CXL_PREMULT_EN = 1 << 7,
90 };
91
92 struct HaeBlurEffectAttr {
93 uint16_t effectCaps;
94 struct HaeNoiseValue noisePara;
95 uint32_t alphaReplaceVal;
96 float colorMatrixCoef[HAE_COLOR_MATRIX_COEF_COUNT];
97 struct HaePixel colorMaskPara;
98 };
99
100 struct hianimation_algo_device_t {
101 bool (* hianimationInputCheck)(const struct BlurImgParam *imgInfo, const struct HaeNoiseValue *noisePara);
102 int32_t (* hianimationAlgoInit)(uint32_t imgWeight, uint32_t imgHeight, float maxSigma, uint32_t format);
103 int32_t (* hianimationAlgoDeInit)();
104 int32_t (* hianimationBuildTask)(const struct HaeBlurBasicAttr *basicInfo,
105 const struct HaeBlurEffectAttr *effectInfo, uint32_t *outTaskId, void **outTaskPtr);
106 int32_t (* hianimationSyncProcess) (const struct HaeBlurBasicAttr *basicInfo,
107 const struct HaeBlurEffectAttr *effectInfo);
108 int32_t (* hianimationDestroyTask)(uint32_t taskId);
109 };
110
111 } // OHOS::Rosen
112
113 #endif // RENDER_SERVICE_BASE_RS_HPAE_HIANIMATION_TYPES_H