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 "modifier/rs_modifier_type.h" 23 #include "pipeline/rs_canvas_render_node.h" 24 25 namespace OHOS { 26 namespace Rosen { 27 28 enum RSCanvasNodeCommandType : uint16_t { 29 CANVAS_NODE_CREATE, 30 CANVAS_NODE_UPDATE_RECORDING, 31 CANVAS_NODE_CLEAR_RECORDING, 32 CANVAS_NODE_SET_HDR_PRESENT, 33 }; 34 35 namespace Drawing { 36 class DrawCmdList; 37 } 38 39 class RSB_EXPORT RSCanvasNodeCommandHelper { 40 public: 41 static void Create(RSContext& context, NodeId id, bool isTextureExportNode = false); 42 static void UpdateRecording( 43 RSContext& context, NodeId id, std::shared_ptr<Drawing::DrawCmdList> drawCmds, uint16_t modifierType); 44 static void ClearRecording(RSContext& context, NodeId id); 45 static void SetHDRPresent(RSContext& context, NodeId nodeId, bool hdrPresent); 46 private: 47 static bool AddCmdToSingleFrameComposer(std::shared_ptr<RSCanvasRenderNode> node, 48 std::shared_ptr<Drawing::DrawCmdList> drawCmds, RSModifierType type); 49 }; 50 51 ADD_COMMAND(RSCanvasNodeCreate, ARG(CANVAS_NODE, CANVAS_NODE_CREATE, RSCanvasNodeCommandHelper::Create, NodeId, bool)) 52 ADD_COMMAND(RSCanvasNodeUpdateRecording, 53 ARG(CANVAS_NODE, CANVAS_NODE_UPDATE_RECORDING, RSCanvasNodeCommandHelper::UpdateRecording, NodeId, 54 std::shared_ptr<Drawing::DrawCmdList>, uint16_t)) 55 ADD_COMMAND(RSCanvasNodeClearRecording, 56 ARG(CANVAS_NODE, CANVAS_NODE_CLEAR_RECORDING, RSCanvasNodeCommandHelper::ClearRecording, NodeId)) 57 ADD_COMMAND(RSCanvasNodeSetHDRPresent, 58 ARG(CANVAS_NODE, CANVAS_NODE_SET_HDR_PRESENT, RSCanvasNodeCommandHelper::SetHDRPresent, NodeId, bool)) 59 60 } // namespace Rosen 61 } // namespace OHOS 62 63 #endif // ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_CANVAS_NODE_COMMAND_H 64