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(NodeId targetNodeId, std::string name = "ProxyNode");
36     ~RSProxyNode() override;
37 
38     void ResetContextVariableCache() const;
39 
GetName()40     const std::string& GetName() const
41     {
42         return name_;
43     }
44 
45     void AddChild(std::shared_ptr<RSBaseNode> child, int index) override;
46     void RemoveChild(std::shared_ptr<RSBaseNode> child) override;
47     void ClearChildren() override;
48 
SetBounds(const Vector4f & bounds)49     void SetBounds(const Vector4f& bounds) override {}
SetBounds(float positionX,float positionY,float width,float height)50     void SetBounds(float positionX, float positionY, float width, float height) override {}
SetBoundsWidth(float width)51     void SetBoundsWidth(float width) override {}
SetBoundsHeight(float height)52     void SetBoundsHeight(float height) override {}
53 
SetFrame(const Vector4f & frame)54     void SetFrame(const Vector4f& frame) override {}
SetFrame(float positionX,float positionY,float width,float height)55     void SetFrame(float positionX, float positionY, float width, float height) override {}
SetFramePositionX(float positionX)56     void SetFramePositionX(float positionX) override {}
SetFramePositionY(float positionY)57     void SetFramePositionY(float positionY) override {}
58 
59 protected:
60     explicit RSProxyNode(NodeId targetNodeId, std::string name);
61 
62     // when add/remove/update child, construct command using proxy node id, not target node id
GetHierarchyCommandNodeId()63     NodeId GetHierarchyCommandNodeId() const override
64     {
65         return proxyNodeId_;
66     }
67 
68 private:
69     void CreateProxyRenderNode();
70     NodeId proxyNodeId_;
71     std::string name_;
72 };
73 } // namespace Rosen
74 } // namespace OHOS
75 
76 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_PROXY_NODE_H
77