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_PIPELINE_RS_PROXY_RENDER_NODE_H 16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_PROXY_RENDER_NODE_H 17 18 #include "common/rs_macros.h" 19 #include "modifier/rs_modifier_type.h" 20 #include "pipeline/rs_render_node.h" 21 22 namespace OHOS { 23 namespace Rosen { 24 class RSSurfaceRenderNode; 25 class RSB_EXPORT RSProxyRenderNode : public RSRenderNode { 26 public: 27 using WeakPtr = std::weak_ptr<RSProxyRenderNode>; 28 using SharedPtr = std::shared_ptr<RSProxyRenderNode>; 29 static inline constexpr RSRenderNodeType Type = RSRenderNodeType::PROXY_NODE; GetType()30 RSRenderNodeType GetType() const override 31 { 32 return Type; 33 } 34 35 explicit RSProxyRenderNode( 36 NodeId id, std::weak_ptr<RSSurfaceRenderNode> target, NodeId targetId, std::weak_ptr<RSContext> context = {}); 37 ~RSProxyRenderNode() override; 38 39 // void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override; 40 // void ProcessRenderAfterChildren(RSPaintFilterCanvas& canvas) override; 41 42 void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 43 void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override; 44 45 // pass render context (matrix/alpha/clip) from proxy to target 46 void SetContextMatrix(const SkMatrix& transform); 47 void SetContextAlpha(float alpha); 48 void SetContextClipRegion(SkRect clipRegion); 49 50 void ResetContextVariableCache(); 51 52 private: 53 std::weak_ptr<RSSurfaceRenderNode> target_; 54 NodeId targetId_; 55 56 SkMatrix contextMatrix_ = SkMatrix::I(); 57 float contextAlpha_ = 0.0f; 58 SkRect contextClipRect_ = SkRect::MakeEmpty(); 59 }; 60 } // namespace Rosen 61 } // namespace OHOS 62 63 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_PROXY_RENDER_NODE_H 64