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_CANVAS_NODE_COMMAND_H 17 #define ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_CANVAS_NODE_COMMAND_H 18 19 20 #include "command/rs_command_templates.h" 21 #include "common/rs_macros.h" 22 #include "pipeline/rs_canvas_render_node.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 27 //Each command HAVE TO have UNIQUE ID in ALL HISTORY 28 //If a command is not used and you want to delete it, 29 //just COMMENT it - and never use this value anymore 30 enum RSCanvasNodeCommandType : uint16_t { 31 CANVAS_NODE_CREATE = 0, 32 CANVAS_NODE_UPDATE_RECORDING = 1, 33 CANVAS_NODE_CLEAR_RECORDING = 2, 34 CANVAS_NODE_SET_HDR_PRESENT = 3, 35 CANVAS_NODE_SET_LINKED_ROOTNODE = 4, 36 CANVAS_NODE_SET_COLOR_GAMUT = 5, 37 }; 38 39 namespace Drawing { 40 class DrawCmdList; 41 } 42 43 class RSB_EXPORT RSCanvasNodeCommandHelper { 44 public: 45 static void Create(RSContext& context, NodeId id, bool isTextureExportNode = false); 46 static void UpdateRecording( 47 RSContext& context, NodeId id, std::shared_ptr<Drawing::DrawCmdList> drawCmds, uint16_t modifierType); 48 static void ClearRecording(RSContext& context, NodeId id); 49 static void SetHDRPresent(RSContext& context, NodeId nodeId, bool hdrPresent); 50 static void SetColorGamut(RSContext& context, NodeId nodeId, uint32_t colorGamut); 51 52 // [Attention] Only used in PC window resize scene now 53 static void SetLinkedRootNodeId(RSContext& context, NodeId nodeId, NodeId rootNodeId); 54 55 private: 56 static bool AddCmdToSingleFrameComposer(std::shared_ptr<RSCanvasRenderNode> node, 57 std::shared_ptr<Drawing::DrawCmdList> drawCmds, uint16_t modifierType); 58 }; 59 60 ADD_COMMAND(RSCanvasNodeCreate, 61 ARG(PERMISSION_APP, CANVAS_NODE, CANVAS_NODE_CREATE, 62 RSCanvasNodeCommandHelper::Create, NodeId, bool)) 63 ADD_COMMAND(RSCanvasNodeUpdateRecording, 64 ARG(PERMISSION_APP, CANVAS_NODE, CANVAS_NODE_UPDATE_RECORDING, 65 RSCanvasNodeCommandHelper::UpdateRecording, NodeId, std::shared_ptr<Drawing::DrawCmdList>, uint16_t)) 66 ADD_COMMAND(RSCanvasNodeClearRecording, 67 ARG(PERMISSION_APP, CANVAS_NODE, CANVAS_NODE_CLEAR_RECORDING, 68 RSCanvasNodeCommandHelper::ClearRecording, NodeId)) 69 ADD_COMMAND(RSCanvasNodeSetHDRPresent, 70 ARG(PERMISSION_APP, CANVAS_NODE, CANVAS_NODE_SET_HDR_PRESENT, 71 RSCanvasNodeCommandHelper::SetHDRPresent, NodeId, bool)) 72 ADD_COMMAND(RSCanvasNodeSetColorGamut, 73 ARG(PERMISSION_APP, CANVAS_NODE, CANVAS_NODE_SET_COLOR_GAMUT, 74 RSCanvasNodeCommandHelper::SetColorGamut, NodeId, uint32_t)) 75 76 // [Attention] Only used in PC window resize scene now 77 ADD_COMMAND(RSCanvasNodeSetLinkedRootNodeId, 78 ARG(PERMISSION_APP, CANVAS_NODE, CANVAS_NODE_SET_LINKED_ROOTNODE, 79 RSCanvasNodeCommandHelper::SetLinkedRootNodeId, NodeId, NodeId)) 80 81 } // namespace Rosen 82 } // namespace OHOS 83 84 #endif // ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_CANVAS_NODE_COMMAND_H 85