1 /* 2 * Copyright (c) 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 RENDER_SERVICE_CORE_RS_RCD_RENDER_MANAGER_H 17 #define RENDER_SERVICE_CORE_RS_RCD_RENDER_MANAGER_H 18 19 #include "pipeline/rs_processor.h" 20 #include "rs_rcd_surface_render_node.h" 21 #include "pipeline/round_corner_display/rs_round_corner_config.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 26 struct RcdPrepareInfo { 27 RSBaseRenderNode::SharedPtr bottomNode = nullptr; 28 RSBaseRenderNode::SharedPtr topNode = nullptr; 29 bool hasInvalidScene = false; 30 }; 31 32 struct RcdProcessInfo { 33 std::shared_ptr<RSProcessor> uniProcessor = nullptr; 34 rs_rcd::RoundCornerLayer* topLayer = nullptr; 35 rs_rcd::RoundCornerLayer* bottomLayer = nullptr; 36 bool resourceChanged = false; 37 }; 38 39 struct RcdInfo { 40 RcdPrepareInfo prepareInfo; 41 RcdProcessInfo processInfo; 42 }; 43 44 class RSRcdRenderManager { 45 public: 46 static RSRcdRenderManager& GetInstance(); 47 static void InitInstance(); 48 bool GetRcdRenderEnabled() const; 49 GetContentSurfaceNode()50 RSRcdSurfaceRenderNode::SharedPtr GetContentSurfaceNode() const 51 { 52 return topSurfaceNode_; 53 } GetBackgroundSurfaceNode()54 RSRcdSurfaceRenderNode::SharedPtr GetBackgroundSurfaceNode() const 55 { 56 return bottomSurfaceNode_; 57 } 58 59 void DoPrepareRenderTask(const RcdPrepareInfo& info); 60 void DoProcessRenderTask(const RcdProcessInfo& info); 61 void DoProcessRenderMainThreadTask(const RcdProcessInfo& info); 62 static bool IsRcdProcessInfoValid(const RcdProcessInfo& info); 63 64 RSRcdRenderManager() = default; 65 virtual ~RSRcdRenderManager() = default; 66 67 private: 68 void Reset(); 69 70 bool rcdRenderEnabled_ = false; 71 constexpr static NodeId TOP_RCD_NODE_ID = 1; 72 constexpr static NodeId BACKGROUND_RCD_NODE_ID = 2; 73 74 std::shared_ptr<RSRcdSurfaceRenderNode> topSurfaceNode_ = 75 std::make_shared<RSRcdSurfaceRenderNode>(TOP_RCD_NODE_ID, RCDSurfaceType::TOP); 76 std::shared_ptr<RSRcdSurfaceRenderNode> bottomSurfaceNode_ = 77 std::make_shared<RSRcdSurfaceRenderNode>(BACKGROUND_RCD_NODE_ID, RCDSurfaceType::BOTTOM); 78 bool isBufferCacheClear_ = false; 79 }; 80 } // namespace Rosen 81 } // namespace OHOS 82 #endif // RENDER_SERVICE_CORE_RS_RCD_RENDER_MANAGER_H