1 /* 2 * Copyright (c) 2022-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 #ifndef RENDER_SERVICE_CLIENT_CORE_UI_RS_PROXY_NODE_H 16 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_PROXY_NODE_H 17 18 #include <parcel.h> 19 #include <string> 20 21 #include "ui/rs_node.h" 22 23 namespace OHOS { 24 namespace Rosen { 25 class RSC_EXPORT RSProxyNode : public RSNode { 26 public: 27 using WeakPtr = std::weak_ptr<RSProxyNode>; 28 using SharedPtr = std::shared_ptr<RSProxyNode>; 29 static inline constexpr RSUINodeType Type = RSUINodeType::PROXY_NODE; GetType()30 RSUINodeType GetType() const override 31 { 32 return Type; 33 } 34 35 static SharedPtr Create( 36 NodeId targetNodeId, std::string name = "ProxyNode", std::shared_ptr<RSUIContext> rsUIContext = nullptr); 37 ~RSProxyNode() override; 38 39 void ResetContextVariableCache() const; 40 GetName()41 const std::string& GetName() const 42 { 43 return name_; 44 } 45 46 void AddChild(std::shared_ptr<RSBaseNode> child, int index) override; 47 void RemoveChild(std::shared_ptr<RSBaseNode> child) override; 48 void ClearChildren() override; 49 SetBounds(const Vector4f & bounds)50 void SetBounds(const Vector4f& bounds) override {} SetBounds(float positionX,float positionY,float width,float height)51 void SetBounds(float positionX, float positionY, float width, float height) override {} SetBoundsWidth(float width)52 void SetBoundsWidth(float width) override {} SetBoundsHeight(float height)53 void SetBoundsHeight(float height) override {} 54 SetFrame(const Vector4f & frame)55 void SetFrame(const Vector4f& frame) override {} SetFrame(float positionX,float positionY,float width,float height)56 void SetFrame(float positionX, float positionY, float width, float height) override {} SetFramePositionX(float positionX)57 void SetFramePositionX(float positionX) override {} SetFramePositionY(float positionY)58 void SetFramePositionY(float positionY) override {} 59 60 protected: 61 explicit RSProxyNode(NodeId targetNodeId, std::string name, std::shared_ptr<RSUIContext> rsUIContext = nullptr); 62 63 // when add/remove/update child, construct command using proxy node id, not target node id GetHierarchyCommandNodeId()64 NodeId GetHierarchyCommandNodeId() const override 65 { 66 return proxyNodeId_; 67 } 68 69 private: 70 void CreateProxyRenderNode(); 71 void RegisterNodeMap() override; 72 NodeId proxyNodeId_; 73 std::string name_; 74 }; 75 } // namespace Rosen 76 } // namespace OHOS 77 78 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_PROXY_NODE_H 79