1 /*
2  * Copyright (c) 2023 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 RECORDING_HANDLE_H
17 #define RECORDING_HANDLE_H
18 
19 #include "draw/paint.h"
20 #include "draw/pen.h"
21 #include "effect/filter.h"
22 #include "utils/scalar.h"
23 #include "text/hm_symbol.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 namespace Drawing {
28 struct ImageHandle {
29     size_t offset = 0;
30     size_t size = 0;
31     int32_t width = 0;
32     int32_t height = 0;
33     ColorType colorType = COLORTYPE_UNKNOWN;
34     AlphaType alphaType = ALPHATYPE_UNKNOWN;
35 };
36 
37 struct OpDataHandle {
38     size_t offset = 0;
39     size_t size = 0;
40 };
41 
42 struct FlattenableHandle {
43     size_t offset = 0;
44     size_t size = 0;
45     uint32_t type = 0;
46 };
47 
48 struct CmdListHandle {
49     uint32_t type = 0;
50     size_t offset = 0;
51     size_t size = 0;
52     size_t imageOffset = 0;
53     size_t imageSize = 0;
54     size_t bitmapOffset = 0;
55     size_t bitmapSize = 0;
56 };
57 
58 struct GroupInfoHandle {
59     std::pair<size_t, size_t> vec1 = {0, 0};
60     std::pair<size_t, size_t> vec2 = {0, 0};
61 };
62 
63 struct RenderGroupHandle {
64     std::pair<size_t, size_t> infos = {0, 0};
65     DrawingSColor color;
66 };
67 
68 struct SymbolLayersHandle {
69     uint32_t id = 0;
70     std::pair<size_t, size_t> layers = {0, 0};
71     std::pair<size_t, size_t> groups = {0, 0};
72 };
73 
74 struct LatticeHandle {
75     std::pair<size_t, size_t> fXDivs = {0, 0};
76     std::pair<size_t, size_t> fYDivs = {0, 0};
77     std::pair<size_t, size_t> fRectTypes = {0, 0};
78     int fXCount = 0;
79     int fYCount = 0;
80     std::pair<size_t, size_t> fBounds = {0, 0};
81     std::pair<size_t, size_t> fColors = {0, 0};
82 };
83 
84 struct SymbolOpHandle {
85     SymbolLayersHandle symbolLayerHandle;
86     OpDataHandle pathHandle;
87     uint64_t symbolId = 0;
88 };
89 
90 struct PaintHandle {
91     bool isAntiAlias = false;
92     bool blenderEnabled = false;
93     Paint::PaintStyle style = Paint::PaintStyle::PAINT_NONE;
94     Color color = Color::COLOR_BLACK;
95     BlendMode mode = BlendMode::SRC_OVER;
96     scalar width = 0.0f;
97     scalar miterLimit = 0.0f;
98     Pen::CapStyle capStyle = Pen::CapStyle::FLAT_CAP;
99     Pen::JoinStyle joinStyle = Pen::JoinStyle::MITER_JOIN;
100     Filter::FilterQuality filterQuality = Filter::FilterQuality::NONE;
101     OpDataHandle colorSpaceHandle;
102     FlattenableHandle shaderEffectHandle;
103     FlattenableHandle colorFilterHandle;
104     FlattenableHandle imageFilterHandle;
105     FlattenableHandle maskFilterHandle;
106     FlattenableHandle pathEffectHandle;
107     OpDataHandle blurDrawLooperHandle;
108 };
109 
110 struct BrushHandle {
111     Color color = Color::COLOR_BLACK;
112     BlendMode mode = BlendMode::SRC_OVER;
113     bool isAntiAlias = false;
114     bool blenderEnabled = false;
115     Filter::FilterQuality filterQuality = Filter::FilterQuality::NONE;
116     OpDataHandle colorSpaceHandle;
117     FlattenableHandle shaderEffectHandle;
118     FlattenableHandle colorFilterHandle;
119     FlattenableHandle imageFilterHandle;
120     FlattenableHandle maskFilterHandle;
121 };
122 
123 struct PenHandle {
124     scalar width = 0.0f;
125     scalar miterLimit = 0.0f;
126     Pen::CapStyle capStyle = Pen::CapStyle::FLAT_CAP;
127     Pen::JoinStyle joinStyle = Pen::JoinStyle::MITER_JOIN;
128     FlattenableHandle pathEffectHandle;
129     Color color = Color::COLOR_BLACK;
130 };
131 } // namespace Drawing
132 } // namespace Rosen
133 } // namespace OHOS
134 #endif
135