• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_CJ_DRAWING_UTIL_H
17 #define OHOS_CJ_DRAWING_UTIL_H
18 
19 #include "cj_common_ffi.h"
20 #include "utils/point.h"
21 #include "utils/scalar.h"
22 
23 namespace OHOS {
24 namespace CJDrawing {
25 using Rosen::Drawing::scalar;
26 
27 constexpr size_t ARGC_ZERO = 0;
28 constexpr size_t ARGC_ONE = 1;
29 constexpr size_t ARGC_TWO = 2;
30 constexpr size_t ARGC_THREE = 3;
31 constexpr size_t ARGC_FOUR = 4;
32 constexpr size_t ARGC_FIVE = 5;
33 constexpr size_t ARGC_SIX = 6;
34 constexpr size_t ARGC_SEVEN = 7;
35 constexpr size_t ARGC_EIGHT = 8;
36 
37 struct CPoint {
38     scalar x;
39     scalar y;
40 };
41 
42 struct CRect {
43     scalar left;
44     scalar top;
45     scalar right;
46     scalar bottom;
47 };
48 
49 struct CArrPoint {
50     CPoint* head;
51     int64_t size;
52 };
53 
54 struct CArrFloat {
55     scalar* head;
56     int64_t size;
57 };
58 
59 struct RetDataScalar {
60     int32_t code;
61     scalar data;
62 };
63 
64 struct RetDataArrPoint {
65     int32_t code;
66     CArrPoint data;
67 };
68 
69 enum class CjDrawingErrorCode : int32_t {
70     INTERNAL_ERROR = -1,
71     OK = 0,
72     ERROR_PARAM_VERIFICATION_FAILED = 25900001,
73 };
74 
ParserErr(CjDrawingErrorCode code)75 inline int32_t ParserErr(CjDrawingErrorCode code)
76 {
77     return static_cast<int32_t>(code);
78 }
79 
80 void ConvertToPointsArray(const CArrPoint& arr, Rosen::Drawing::Point* points, int64_t count);
81 void WriteToCjPointsArray(const Rosen::Drawing::Point* points, const CArrPoint& arr, int64_t count);
82 }
83 }
84 #endif
85