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 #include "core/interfaces/native/node/path_modifier.h"
16 
17 #include "core/pipeline/base/element_register.h"
18 #include "core/components_ng/base/frame_node.h"
19 #include "core/components_ng/pattern/shape/path_model_ng.h"
20 #include "core/components/common/layout/constants.h"
21 
22 
23 namespace OHOS::Ace::NG {
24 
SetPathCommands(ArkUINodeHandle node,ArkUI_CharPtr commands)25 void SetPathCommands(ArkUINodeHandle node, ArkUI_CharPtr commands)
26 {
27     auto* frameNode = reinterpret_cast<FrameNode*>(node);
28     CHECK_NULL_VOID(frameNode);
29     PathModelNG::SetCommands(frameNode, std::string(commands));
30 }
31 
ResetPathCommands(ArkUINodeHandle node)32 void ResetPathCommands(ArkUINodeHandle node)
33 {
34     std::string outCommands = "";
35     auto* frameNode = reinterpret_cast<FrameNode*>(node);
36     CHECK_NULL_VOID(frameNode);
37     PathModelNG::SetCommands(frameNode, outCommands);
38 }
39 
40 namespace NodeModifier {
GetPathModifier()41 const ArkUIPathModifier* GetPathModifier()
42 {
43     static const ArkUIPathModifier modifier = {SetPathCommands, ResetPathCommands};
44 
45     return &modifier;
46 }
47 
GetCJUIPathModifier()48 const CJUIPathModifier* GetCJUIPathModifier()
49 {
50     static const CJUIPathModifier modifier = {SetPathCommands, ResetPathCommands};
51 
52     return &modifier;
53 }
54 }
55 }