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 }; 33 34 #ifndef USE_ROSEN_DRAWING 35 class DrawCmdList; 36 #else 37 namespace Drawing { 38 class DrawCmdList; 39 } 40 #endif 41 42 class RSB_EXPORT RSCanvasNodeCommandHelper { 43 public: 44 static void Create(RSContext& context, NodeId id, bool isTextureExportNode = false); 45 #ifndef USE_ROSEN_DRAWING 46 static void UpdateRecording( 47 RSContext& context, NodeId id, std::shared_ptr<DrawCmdList> drawCmds, uint16_t modifierType); 48 #else 49 static void UpdateRecording( 50 RSContext& context, NodeId id, std::shared_ptr<Drawing::DrawCmdList> drawCmds, uint16_t modifierType); 51 #endif 52 static void ClearRecording(RSContext& context, NodeId id); 53 private: 54 #ifndef USE_ROSEN_DRAWING 55 static bool AddCmdToSingleFrameComposer(std::shared_ptr<RSCanvasRenderNode> node, 56 std::shared_ptr<DrawCmdList> drawCmds, RSModifierType type); 57 #else 58 static bool AddCmdToSingleFrameComposer(std::shared_ptr<RSCanvasRenderNode> node, 59 std::shared_ptr<Drawing::DrawCmdList> drawCmds, RSModifierType type); 60 #endif 61 }; 62 63 ADD_COMMAND(RSCanvasNodeCreate, ARG(CANVAS_NODE, CANVAS_NODE_CREATE, RSCanvasNodeCommandHelper::Create, NodeId, bool)) 64 #ifndef USE_ROSEN_DRAWING 65 ADD_COMMAND(RSCanvasNodeUpdateRecording, 66 ARG(CANVAS_NODE, CANVAS_NODE_UPDATE_RECORDING, RSCanvasNodeCommandHelper::UpdateRecording, NodeId, 67 std::shared_ptr<DrawCmdList>, uint16_t)) 68 #else 69 ADD_COMMAND(RSCanvasNodeUpdateRecording, 70 ARG(CANVAS_NODE, CANVAS_NODE_UPDATE_RECORDING, RSCanvasNodeCommandHelper::UpdateRecording, NodeId, 71 std::shared_ptr<Drawing::DrawCmdList>, uint16_t)) 72 #endif 73 ADD_COMMAND(RSCanvasNodeClearRecording, 74 ARG(CANVAS_NODE, CANVAS_NODE_CLEAR_RECORDING, RSCanvasNodeCommandHelper::ClearRecording, NodeId)) 75 76 } // namespace Rosen 77 } // namespace OHOS 78 79 #endif // ROSEN_RENDER_SERVICE_BASE_COMMAND_RS_CANVAS_NODE_COMMAND_H 80