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_DISPLAY_NODE_COMMAND_H
17 #define ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_DISPLAY_NODE_COMMAND_H
18 
19 #include "command/rs_command_templates.h"
20 #include "screen_manager/screen_types.h"
21 #include "common/rs_macros.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 
26 enum RSDisplayNodeCommandType : uint16_t {
27     DISPLAY_NODE_CREATE,
28     DISPLAY_NODE_SET_SCREEN_ID,
29     DISPLAY_NODE_SET_DISPLAY_OFFSET,
30     DISPLAY_NODE_SET_SECURITY_DISPLAY,
31     DISPLAY_NODE_SET_DISPLAY_MODE,
32     DISPLAY_NODE_SET_SCREEN_ROTATION,
33     DISPLAY_NODE_SET_BOOT_ANIMATION,
34     DISPLAY_NODE_SET_ROG_SIZE,
35     DISPLAY_NODE_ADD_TO_TREE,
36     DISPLAY_NODE_REMOVE_FROM_TREE,
37     DISPLAY_NODE_SET_NODE_PID,
38 };
39 
40 class RSB_EXPORT DisplayNodeCommandHelper {
41 public:
42     static void Create(RSContext&, NodeId, const RSDisplayNodeConfig&);
43     static std::shared_ptr<RSDisplayRenderNode> CreateWithConfigInRS(RSContext&, NodeId, const RSDisplayNodeConfig&);
44     static void SetScreenId(RSContext&, NodeId, uint64_t);
45     static void SetDisplayOffset(RSContext&, NodeId, int32_t, int32_t);
46     static void SetSecurityDisplay(RSContext&, NodeId, bool);
47     static void SetDisplayMode(RSContext&, NodeId, const RSDisplayNodeConfig&);
48     static void SetScreenRotation(RSContext&, NodeId, const ScreenRotation&);
49     static void SetBootAnimation(RSContext& context, NodeId nodeId, bool isBootAnimation);
50     static void SetRogSize(RSContext&, NodeId, uint32_t, uint32_t);
51     static void AddDisplayNodeToTree(RSContext&, NodeId);
52     static void RemoveDisplayNodeFromTree(RSContext&, NodeId);
53     static void SetScbNodePid(RSContext&, NodeId, const std::vector<int32_t>& oldScbPids, int32_t currentScbPid);
54 };
55 
56 ADD_COMMAND(RSDisplayNodeCreate,
57     ARG(DISPLAY_NODE, DISPLAY_NODE_CREATE, DisplayNodeCommandHelper::Create, NodeId, RSDisplayNodeConfig))
58 ADD_COMMAND(RSDisplayNodeSetScreenId,
59     ARG(DISPLAY_NODE, DISPLAY_NODE_SET_SCREEN_ID, DisplayNodeCommandHelper::SetScreenId, NodeId, uint64_t))
60 ADD_COMMAND(RSDisplayNodeSetDisplayOffset,
61     ARG(DISPLAY_NODE, DISPLAY_NODE_SET_DISPLAY_OFFSET, DisplayNodeCommandHelper::SetDisplayOffset, NodeId,
62     int32_t, int32_t))
63 ADD_COMMAND(RSDisplayNodeSetSecurityDisplay,
64     ARG(DISPLAY_NODE, DISPLAY_NODE_SET_SECURITY_DISPLAY, DisplayNodeCommandHelper::SetSecurityDisplay, NodeId, bool))
65 ADD_COMMAND(RSDisplayNodeSetDisplayMode,
66     ARG(DISPLAY_NODE, DISPLAY_NODE_SET_DISPLAY_MODE, DisplayNodeCommandHelper::SetDisplayMode, NodeId,
67     RSDisplayNodeConfig))
68 ADD_COMMAND(RSDisplayNodeSetScreenRotation,
69     ARG(DISPLAY_NODE, DISPLAY_NODE_SET_SCREEN_ROTATION, DisplayNodeCommandHelper::SetScreenRotation, NodeId,
70     ScreenRotation))
71 ADD_COMMAND(RSDisplayNodeSetBootAnimation,
72     ARG(DISPLAY_NODE, DISPLAY_NODE_SET_BOOT_ANIMATION, DisplayNodeCommandHelper::SetBootAnimation,
73     NodeId, bool))
74 ADD_COMMAND(RSDisplayNodeSetRogSize,
75     ARG(DISPLAY_NODE, DISPLAY_NODE_SET_ROG_SIZE, DisplayNodeCommandHelper::SetRogSize,
76     NodeId, uint32_t, uint32_t))
77 ADD_COMMAND(RSDisplayNodeAddToTree,
78     ARG(DISPLAY_NODE, DISPLAY_NODE_ADD_TO_TREE, DisplayNodeCommandHelper::AddDisplayNodeToTree, NodeId))
79 ADD_COMMAND(RSDisplayNodeRemoveFromTree,
80     ARG(DISPLAY_NODE, DISPLAY_NODE_REMOVE_FROM_TREE, DisplayNodeCommandHelper::RemoveDisplayNodeFromTree, NodeId))
81 ADD_COMMAND(RSDisplayNodeSetNodePid,
82     ARG(DISPLAY_NODE, DISPLAY_NODE_SET_NODE_PID, DisplayNodeCommandHelper::SetScbNodePid,
83     NodeId, std::vector<int32_t>, int32_t))
84 } // namespace Rosen
85 } // namespace OHOS
86 
87 #endif // ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_DISPLAY_NODE_COMMAND_H
88