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 
16 #ifndef OHOS_HDI_DISPLAY_V1_2_DISPLAY_CMD_UTILS_H
17 #define OHOS_HDI_DISPLAY_V1_2_DISPLAY_CMD_UTILS_H
18 
19 #include "v1_1/display_command/display_cmd_utils.h"
20 #include "v1_2/display_composer_type.h"
21 
22 #undef LOG_TAG
23 #define LOG_TAG "DISP_CMD"
24 #undef LOG_DOMAIN
25 #define LOG_DOMAIN 0xD002515
26 
27 namespace OHOS {
28 namespace HDI {
29 namespace Display {
30 namespace Composer {
31 namespace V1_2 {
32 
33 class DisplayCmdUtils : public V1_1::DisplayCmdUtils {
34 public:
35     #define SWITCHCASE(x) case (x): {return #x;}
CommandToString(int32_t cmdId)36     static const char *CommandToString(int32_t cmdId)
37     {
38         switch (cmdId) {
39             /* request cmd */
40             SWITCHCASE(REQUEST_CMD_PREPARE_DISPLAY_LAYERS);
41             SWITCHCASE(REQUEST_CMD_SET_DISPLAY_CLIENT_BUFFER);
42             SWITCHCASE(REQUEST_CMD_SET_DISPLAY_CLIENT_DAMAGE);
43             SWITCHCASE(REQUEST_CMD_COMMIT);
44             SWITCHCASE(REQUEST_CMD_SET_LAYER_ALPHA);
45             SWITCHCASE(REQUEST_CMD_SET_LAYER_REGION);
46             SWITCHCASE(REQUEST_CMD_SET_LAYER_CROP);
47             SWITCHCASE(REQUEST_CMD_SET_LAYER_ZORDER);
48             SWITCHCASE(REQUEST_CMD_SET_LAYER_PREMULTI);
49             SWITCHCASE(REQUEST_CMD_SET_LAYER_TRANSFORM_MODE);
50             SWITCHCASE(REQUEST_CMD_SET_LAYER_DIRTY_REGION);
51             SWITCHCASE(REQUEST_CMD_SET_LAYER_VISIBLE_REGION);
52             SWITCHCASE(REQUEST_CMD_SET_LAYER_BUFFER);
53             SWITCHCASE(REQUEST_CMD_SET_LAYER_COMPOSITION_TYPE);
54             SWITCHCASE(REQUEST_CMD_SET_LAYER_BLEND_TYPE);
55             SWITCHCASE(REQUEST_CMD_SET_LAYER_VISIBLE);
56             SWITCHCASE(REQUEST_CMD_SET_LAYER_MASK_INFO);
57             SWITCHCASE(REQUEST_CMD_SET_LAYER_COLOR);
58             SWITCHCASE(REQUEST_CMD_COMMIT_AND_GET_RELEASE_FENCE);
59             SWITCHCASE(REQUEST_CMD_SET_DISPLAY_CONSTRAINT);
60             /* reply cmd */
61             SWITCHCASE(REPLY_CMD_SET_ERROR);
62             SWITCHCASE(REPLY_CMD_PREPARE_DISPLAY_LAYERS);
63             SWITCHCASE(REPLY_CMD_COMMIT);
64             SWITCHCASE(REPLY_CMD_COMMIT_AND_GET_RELEASE_FENCE);
65             /* pack control cmd */
66             SWITCHCASE(CONTROL_CMD_REQUEST_BEGIN);
67             SWITCHCASE(CONTROL_CMD_REPLY_BEGIN);
68             SWITCHCASE(CONTROL_CMD_REQUEST_END);
69             SWITCHCASE(CONTROL_CMD_REPLY_END);
70             default:
71                 return "unknow command id.";
72         }
73     }
74 };
75 using CmdUtils = DisplayCmdUtils;
76 } // namespace V1_2
77 } // namespace Composer
78 } // namespace Display
79 } // namespace HDI
80 } // namespace OHOS
81 #endif // OHOS_HDI_DISPLAY_V1_2_DISPLAY_CMD_UTILS_H