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 #include "pipeline/rs_root_render_node.h"
17
18 #include "platform/drawing/rs_surface.h"
19 #include "transaction/rs_transaction_proxy.h"
20 #include "visitor/rs_node_visitor.h"
21 #if !defined(_WIN32) && !defined(__APPLE__) && !defined(__gnu_linux__)
22 #include <surface.h>
23 #endif
24
25 namespace OHOS {
26 namespace Rosen {
RSRootRenderNode(NodeId id,std::weak_ptr<RSContext> context)27 RSRootRenderNode::RSRootRenderNode(NodeId id, std::weak_ptr<RSContext> context)
28 : RSCanvasRenderNode(id, context), dirtyManager_(std::make_shared<RSDirtyRegionManager>()) {}
29
~RSRootRenderNode()30 RSRootRenderNode::~RSRootRenderNode() {}
31
AttachRSSurfaceNode(NodeId surfaceNodeId)32 void RSRootRenderNode::AttachRSSurfaceNode(NodeId surfaceNodeId)
33 {
34 surfaceNodeId_ = surfaceNodeId;
35 }
36
GetSuggestedBufferWidth() const37 float RSRootRenderNode::GetSuggestedBufferWidth() const
38 {
39 return suggestedBufferWidth_;
40 }
41
GetSuggestedBufferHeight() const42 float RSRootRenderNode::GetSuggestedBufferHeight() const
43 {
44 return suggestedBufferHeight_;
45 }
46
UpdateSuggestedBufferSize(float width,float height)47 void RSRootRenderNode::UpdateSuggestedBufferSize(float width, float height)
48 {
49 suggestedBufferHeight_ = height;
50 suggestedBufferWidth_ = width;
51 }
52
GetSurface()53 std::shared_ptr<RSSurface> RSRootRenderNode::GetSurface()
54 {
55 return rsSurface_;
56 }
57
GetRSSurfaceNodeId()58 NodeId RSRootRenderNode::GetRSSurfaceNodeId()
59 {
60 return surfaceNodeId_;
61 }
62
GetDirtyManager() const63 std::shared_ptr<RSDirtyRegionManager> RSRootRenderNode::GetDirtyManager() const
64 {
65 return dirtyManager_;
66 }
67
Prepare(const std::shared_ptr<RSNodeVisitor> & visitor)68 void RSRootRenderNode::Prepare(const std::shared_ptr<RSNodeVisitor>& visitor)
69 {
70 if (!visitor) {
71 return;
72 }
73 visitor->PrepareRootRenderNode(*this);
74 }
75
Process(const std::shared_ptr<RSNodeVisitor> & visitor)76 void RSRootRenderNode::Process(const std::shared_ptr<RSNodeVisitor>& visitor)
77 {
78 if (!visitor) {
79 return;
80 }
81 RSRenderNode::RenderTraceDebug();
82 visitor->ProcessRootRenderNode(*this);
83 }
84 } // namespace Rosen
85 } // namespace OHOS
86