• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_BASE_NODE_COMMAND_H
17 #define ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_BASE_NODE_COMMAND_H
18 
19 #include "command/rs_command_templates.h"
20 #include "common/rs_macros.h"
21 
22 namespace OHOS {
23 namespace Rosen {
24 
25 enum RSBaseNodeCommandType : uint16_t {
26     BASE_NODE_DESTROY,
27     BASE_NODE_ADD_CHILD,
28     BASE_NODE_MOVE_CHILD,
29     BASE_NODE_ADD_CROSS_PARENT_CHILD,
30     BASE_NODE_REMOVE_CHILD,
31     BASE_NODE_REMOVE_CROSS_PARENT_CHILD,
32     BASE_NODE_REMOVE_FROM_TREE,
33     BASE_NODE_CLEAR_CHILDREN,
34     BASE_NODE_CLEAR_SURFACE_NODE_CHILDREN,
35 };
36 
37 class RSB_EXPORT BaseNodeCommandHelper {
38 public:
39     static void Destroy(RSContext& context, NodeId nodeId);
40     static void AddChild(RSContext& context, NodeId nodeId, NodeId childNodeId, int32_t index);
41     static void MoveChild(RSContext& context, NodeId nodeId, NodeId childNodeId, int32_t index);
42     static void RemoveChild(RSContext& context, NodeId nodeId, NodeId childNodeId);
43     static void AddCrossParentChild(RSContext& context, NodeId nodeId, NodeId childNodeId, int32_t index);
44     static void RemoveCrossParentChild(RSContext& context, NodeId nodeId, NodeId childNodeId, NodeId newParentId);
45     static void RemoveFromTree(RSContext& context, NodeId nodeId);
46     static void ClearChildren(RSContext& context, NodeId nodeId);
47     static void ClearSurfaceNodeChildren(RSContext& context, NodeId nodeId);
48 };
49 
50 ADD_COMMAND(RSBaseNodeDestroy, ARG(BASE_NODE, BASE_NODE_DESTROY, BaseNodeCommandHelper::Destroy, NodeId))
51 ADD_COMMAND(
52     RSBaseNodeAddChild, ARG(BASE_NODE, BASE_NODE_ADD_CHILD, BaseNodeCommandHelper::AddChild, NodeId, NodeId, int32_t))
53 ADD_COMMAND(RSBaseNodeMoveChild,
54     ARG(BASE_NODE, BASE_NODE_MOVE_CHILD, BaseNodeCommandHelper::MoveChild, NodeId, NodeId, int32_t))
55 ADD_COMMAND(
56     RSBaseNodeRemoveChild, ARG(BASE_NODE, BASE_NODE_REMOVE_CHILD, BaseNodeCommandHelper::RemoveChild, NodeId, NodeId))
57 ADD_COMMAND(
58     RSBaseNodeAddCrossParentChild, ARG(BASE_NODE, BASE_NODE_ADD_CROSS_PARENT_CHILD,
59     BaseNodeCommandHelper::AddCrossParentChild, NodeId, NodeId, int32_t))
60 ADD_COMMAND(
61     RSBaseNodeRemoveCrossParentChild, ARG(BASE_NODE, BASE_NODE_REMOVE_CROSS_PARENT_CHILD,
62     BaseNodeCommandHelper::RemoveCrossParentChild, NodeId, NodeId, NodeId))
63 ADD_COMMAND(
64     RSBaseNodeRemoveFromTree, ARG(BASE_NODE, BASE_NODE_REMOVE_FROM_TREE, BaseNodeCommandHelper::RemoveFromTree, NodeId))
65 ADD_COMMAND(
66     RSBaseNodeClearChild, ARG(BASE_NODE, BASE_NODE_CLEAR_CHILDREN, BaseNodeCommandHelper::ClearChildren, NodeId))
67 ADD_COMMAND(RSBaseNodeClearSurfaceNodeChild,
68     ARG(BASE_NODE, BASE_NODE_CLEAR_SURFACE_NODE_CHILDREN, BaseNodeCommandHelper::ClearSurfaceNodeChildren, NodeId))
69 } // namespace Rosen
70 } // namespace OHOS
71 
72 #endif // ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_BASE_NODE_COMMAND_H
73