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 #include "draw_path_test.h"
16 
17 namespace OHOS {
18 namespace Rosen {
OnTestFunctionCpu(Drawing::Canvas * canvas)19 void DrawPathTest::OnTestFunctionCpu(Drawing::Canvas* canvas)
20 {
21     Drawing::Pen pen;
22     pen.SetColor(0xFFFF0000); // color:red
23     pen.SetWidth(10.0f); // width:10
24     canvas->AttachPen(pen);
25     Drawing::Path path;
26     path.MoveTo(0, 0); // from (0, 0)
27     path.LineTo(300, 300); // to (300, 300)
28     canvas->DrawPath(path);
29     canvas->DetachPen();
30 }
OnTestFunctionGpuUpScreen(Drawing::Canvas * canvas)31 void DrawPathTest::OnTestFunctionGpuUpScreen(Drawing::Canvas* canvas)
32 {
33     Drawing::Path path;
34     path.MoveTo(200, 200); // from (200, 200)
35     path.LineTo(500, 500); // to (500, 500)
36     canvas->DrawPath(path);
37 }
OnTestPerformance(Drawing::Canvas * canvas)38 void DrawPathTest::OnTestPerformance(Drawing::Canvas* canvas)
39 {
40     Drawing::Pen pen;
41     pen.SetColor(0xFFFF0000); // color:red
42     pen.SetWidth(10.0f); // width:10
43     canvas->AttachPen(pen);
44     Drawing::Path path;
45     path.MoveTo(0, 0); // from (0, 0)
46     path.LineTo(300, 300); // to (300, 300)
47     for (int i = 0; i < testCount_; i++) {
48         canvas->DrawPath(path);
49     }
50     canvas->DetachPen();
51 }
52 } // namespace Rosen
53 } // namespace OHOS