1 /*
2  * Copyright (c) 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 PATH_TEST_H
17 #define PATH_TEST_H
18 #include <native_drawing/drawing_canvas.h>
19 #include <native_drawing/drawing_path.h>
20 #include <native_drawing/drawing_rect.h>
21 
22 #include "test_base.h"
23 #include "test_common.h"
24 
25 class PathTransformWithPerspectiveClip : public TestBase {
26 public:
PathTransformWithPerspectiveClip(int type,bool bClip)27     PathTransformWithPerspectiveClip(int type, bool bClip) : TestBase(type), applyPerspectiveClip(bClip)
28     {
29         fileName_ = "PathTransformWithPerspectiveClip";
30     }
~PathTransformWithPerspectiveClip()31     ~PathTransformWithPerspectiveClip() override {};
32 
33 protected:
34     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 358 ms 100次
35     bool applyPerspectiveClip;
36 };
37 
38 class PathSetFillType : public TestBase {
39 public:
PathSetFillType(int type,OH_Drawing_PathFillType fillType)40     PathSetFillType(int type, OH_Drawing_PathFillType fillType) : TestBase(type), fType(fillType)
41     {
42         fileName_ = "PathSetFillType";
43     }
~PathSetFillType()44     ~PathSetFillType() override {};
45 
46 protected:
47     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 712 ms 100次
48     OH_Drawing_PathFillType fType;
49 };
50 
51 class PathGetLength : public TestBase {
52 public:
PathGetLength(int type,bool bForceClosed)53     PathGetLength(int type, bool bForceClosed) : TestBase(type), bClosed(bForceClosed)
54     {
55         fileName_ = "PathGetLength";
56     }
~PathGetLength()57     ~PathGetLength() override {};
58 
59 protected:
60     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 768 ms 100次
61     bool bClosed;
62 };
63 
64 class PathClose : public TestBase {
65 public:
PathClose(int type)66     explicit PathClose(int type) : TestBase(type)
67     {
68         fileName_ = "PathClose";
69     }
~PathClose()70     ~PathClose() override {};
71 
72 protected:
73     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 1544 ms 100次
74 };
75 
76 class PathOffset : public TestBase {
77 public:
PathOffset(int type)78     explicit PathOffset(int type) : TestBase(type)
79     {
80         fileName_ = "PathOffset";
81     }
~PathOffset()82     ~PathOffset() override {};
83 
84 protected:
85     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 454 ms 100次
86 };
87 
88 class PathReset : public TestBase {
89 public:
PathReset(int type)90     explicit PathReset(int type) : TestBase(type)
91     {
92         fileName_ = "PathReset";
93     }
~PathReset()94     ~PathReset() override {};
95 
96 protected:
97     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 2613 ms 100次
98 };
99 
100 class PathCubicTo : public TestBase {
101 public:
PathCubicTo(int type)102     explicit PathCubicTo(int type) : TestBase(type)
103     {
104         fileName_ = "PathCubicTo";
105     }
~PathCubicTo()106     ~PathCubicTo() override {};
107 
108 protected:
109     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 2041 ms 100次
110 };
111 
112 class PathRMoveTo : public TestBase {
113 public:
PathRMoveTo(int type)114     explicit PathRMoveTo(int type) : TestBase(type)
115     {
116         fileName_ = "PathRMoveTo";
117     }
~PathRMoveTo()118     ~PathRMoveTo() override {};
119 
120 protected:
121     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 1299 ms 100次
122 };
123 
124 class PathRLineTo : public TestBase {
125 public:
PathRLineTo(int type)126     explicit PathRLineTo(int type) : TestBase(type)
127     {
128         fileName_ = "PathRLineTo";
129     }
~PathRLineTo()130     ~PathRLineTo() override {};
131 
132 protected:
133     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 767 ms 100次
134 };
135 
136 class PathRQuadTo : public TestBase {
137 public:
PathRQuadTo(int type)138     explicit PathRQuadTo(int type) : TestBase(type)
139     {
140         fileName_ = "PathRQuadTo";
141     }
~PathRQuadTo()142     ~PathRQuadTo() override {};
143 
144 protected:
145     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 1184 ms 100次
146 };
147 
148 class PathRConicTo : public TestBase {
149 public:
PathRConicTo(int type)150     explicit PathRConicTo(int type) : TestBase(type)
151     {
152         fileName_ = "PathRConicTo";
153     }
~PathRConicTo()154     ~PathRConicTo() override {};
155 
156 protected:
157     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 931 ms 100次
158 };
159 
160 class PathRCubicTo : public TestBase {
161 public:
PathRCubicTo(int type)162     explicit PathRCubicTo(int type) : TestBase(type)
163     {
164         fileName_ = "PathRCubicTo";
165     }
~PathRCubicTo()166     ~PathRCubicTo() override {};
167 
168 protected:
169     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 1124 ms 100次
170 };
171 
172 class PathAddRect : public TestBase {
173 public:
PathAddRect(int type)174     explicit PathAddRect(int type) : TestBase(type)
175     {
176         fileName_ = "PathAddRect";
177     }
~PathAddRect()178     ~PathAddRect() override {};
179 
180 protected:
181     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 727 ms 100次
182 };
183 
184 class PathAddRectWithInitialCorner : public TestBase {
185 public:
PathAddRectWithInitialCorner(int type)186     explicit PathAddRectWithInitialCorner(int type) : TestBase(type)
187     {
188         fileName_ = "PathAddRectWithInitialCorner";
189     }
~PathAddRectWithInitialCorner()190     ~PathAddRectWithInitialCorner() override {};
191 
192 protected:
193     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 739 ms 100次
194 };
195 
196 class PathAddRoundRect : public TestBase {
197 public:
PathAddRoundRect(int type)198     explicit PathAddRoundRect(int type) : TestBase(type)
199     {
200         fileName_ = "PathAddRoundRect";
201     }
~PathAddRoundRect()202     ~PathAddRoundRect() override {};
203 
204 protected:
205     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 783 ms 100次
206 };
207 
208 class PathAddPath : public TestBase {
209 public:
PathAddPath(int type)210     explicit PathAddPath(int type) : TestBase(type)
211     {
212         fileName_ = "PathAddPath";
213     }
~PathAddPath()214     ~PathAddPath() override {};
215 
216 protected:
217     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 2348 ms 100次
218 };
219 
220 class PathAddPathWithMode : public TestBase {
221 public:
PathAddPathWithMode(int type,OH_Drawing_PathAddMode mode)222     PathAddPathWithMode(int type, OH_Drawing_PathAddMode mode) : TestBase(type), addMode(mode)
223     {
224         fileName_ = "PathAddPathWithMode";
225     }
~PathAddPathWithMode()226     ~PathAddPathWithMode() override {};
227 
228 protected:
229     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 2133 ms 100次
230     OH_Drawing_PathAddMode addMode;
231 };
232 
233 class PathAddPathWithOffsetAndMode : public TestBase {
234 public:
PathAddPathWithOffsetAndMode(int type,OH_Drawing_PathAddMode mode)235     PathAddPathWithOffsetAndMode(int type, OH_Drawing_PathAddMode mode) : TestBase(type), addMode(mode)
236     {
237         fileName_ = "PathAddPathWithOffsetAndMode";
238     }
~PathAddPathWithOffsetAndMode()239     ~PathAddPathWithOffsetAndMode() override {};
240 
241 protected:
242     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 3547 ms 100次
243     OH_Drawing_PathAddMode addMode;
244 };
245 
246 class PathEffectCreateDashPathEffect : public TestBase {
247 public:
PathEffectCreateDashPathEffect(int type)248     explicit PathEffectCreateDashPathEffect(int type) : TestBase(type) {};
~PathEffectCreateDashPathEffect()249     ~PathEffectCreateDashPathEffect() override {};
250 
251 protected:
252     int rectWidth_ = 0;  // 0 矩形宽度
253     int rectHeight_ = 0; // 0 矩形高度
254     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
255 };
256 
257 class PathCreate : public TestBase {
258 public:
PathCreate(int type)259     explicit PathCreate(int type) : TestBase(type) {};
~PathCreate()260     ~PathCreate() override {};
261 
262 protected:
263     int rectWidth_ = 0;  // 0 矩形宽度
264     int rectHeight_ = 0; // 0 矩形高度
265     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
266 };
267 
268 class PathLineTo : public TestBase {
269 public:
PathLineTo(int type)270     explicit PathLineTo(int type) : TestBase(type) {};
~PathLineTo()271     ~PathLineTo() override {};
272 
273 protected:
274     int rectWidth_ = 0;  // 0 矩形宽度
275     int rectHeight_ = 0; // 0 矩形高度
276     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
277 };
278 
279 class PathArcTo : public TestBase {
280 public:
PathArcTo(int type)281     explicit PathArcTo(int type) : TestBase(type) {};
~PathArcTo()282     ~PathArcTo() override {};
283 
284 protected:
285     int rectWidth_ = 0;  // 0 矩形宽度
286     int rectHeight_ = 0; // 0 矩形高度
287     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
288 };
289 
290 class PathQuadTo : public TestBase {
291 public:
PathQuadTo(int type)292     explicit PathQuadTo(int type) : TestBase(type) {};
~PathQuadTo()293     ~PathQuadTo() override {};
294 
295 protected:
296     int rectWidth_ = 0;  // 0 矩形宽度
297     int rectHeight_ = 0; // 0 矩形高度
298     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
299 };
300 
301 class PathCopy : public TestBase {
302 public:
PathCopy(int type)303     explicit PathCopy(int type) : TestBase(type) {};
~PathCopy()304     ~PathCopy() override {};
305 
306 protected:
307     int rectWidth_ = 0;  // 0 矩形宽度
308     int rectHeight_ = 0; // 0 矩形高度
309     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
310 };
311 
312 class PathConicTo : public TestBase {
313 public:
PathConicTo(int type)314     explicit PathConicTo(int type) : TestBase(type) {};
~PathConicTo()315     ~PathConicTo() override {};
316 
317 protected:
318     int rectWidth_ = 0;  // 0 矩形宽度
319     int rectHeight_ = 0; // 0 矩形高度
320     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
321 };
322 
323 class PathAddPathWithMatrixAndMode : public TestBase {
324 public:
PathAddPathWithMatrixAndMode(int type)325     explicit PathAddPathWithMatrixAndMode(int type) : TestBase(type) {};
~PathAddPathWithMatrixAndMode()326     ~PathAddPathWithMatrixAndMode() override {};
327 
328 protected:
329     int rectWidth_ = 0;  // 0 矩形宽度
330     int rectHeight_ = 0; // 0 矩形高度
331     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
332 };
333 class PathAddOvalWithInitialPoint : public TestBase {
334 public:
PathAddOvalWithInitialPoint(int type)335     explicit PathAddOvalWithInitialPoint(int type) : TestBase(type) {};
~PathAddOvalWithInitialPoint()336     ~PathAddOvalWithInitialPoint() override {};
337 
338 protected:
339     int rectWidth_ = 0;  // 0 矩形宽度
340     int rectHeight_ = 0; // 0 矩形高度
341     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
342 
343 private:
344     TestRend renderer;
345 };
346 
347 class PathAddArc : public TestBase {
348 public:
PathAddArc(int type)349     explicit PathAddArc(int type) : TestBase(type) {};
~PathAddArc()350     ~PathAddArc() override {};
351 
352 protected:
353     int rectWidth_ = 0;  // 0 矩形宽度
354     int rectHeight_ = 0; // 0 矩形高度
355     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
356 
357 private:
358     TestRend renderer;
359 };
360 class PathTransform : public TestBase {
361 public:
PathTransform(int type)362     explicit PathTransform(int type) : TestBase(type) {};
~PathTransform()363     ~PathTransform() override {};
364 
365 protected:
366     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
367 };
368 
369 class PathAddOval : public TestBase {
370 public:
PathAddOval(int type)371     explicit PathAddOval(int type) : TestBase(type) {};
~PathAddOval()372     ~PathAddOval() override {};
373 
374 protected:
375     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
376 };
377 
378 class PathContains : public TestBase {
379 public:
PathContains(int type)380     explicit PathContains(int type) : TestBase(type) {};
~PathContains()381     ~PathContains() override {};
382 
383 protected:
384     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
385 };
386 
387 #endif // PATH_TEST_H