• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_EFFECT_RENDER_NODE_H
16 #define RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_EFFECT_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 #include "screen_manager/screen_types.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 class RSB_EXPORT RSEffectRenderNode : public RSRenderNode {
26 public:
27     using WeakPtr = std::weak_ptr<RSEffectRenderNode>;
28     using SharedPtr = std::shared_ptr<RSEffectRenderNode>;
29     static inline constexpr RSRenderNodeType Type = RSRenderNodeType::EFFECT_NODE;
GetType()30     RSRenderNodeType GetType() const override
31     {
32         return Type;
33     }
34 
OpincGetNodeSupportFlag()35     bool OpincGetNodeSupportFlag() override
36     {
37         return false;
38     }
39 
40     ~RSEffectRenderNode() override;
41 
42     void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override;
43 
44     void QuickPrepare(const std::shared_ptr<RSNodeVisitor>& visitor) override;
45     void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override;
46     void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override;
47     void CheckBlurFilterCacheNeedForceClearOrSave(bool rotationChanged = false,
48         bool rotationStatusChanged = false) override;
InitializeEffectRegion()49     std::optional<Drawing::RectI> InitializeEffectRegion() const { return Drawing::RectI(); }
50     void SetEffectRegion(const std::optional<Drawing::RectI>& effectRegion);
51     // record if there is filter cache for occlusion before this effect node
SetVisitedFilterCacheStatus(bool isEmpty)52     void SetVisitedFilterCacheStatus(bool isEmpty)
53     {
54         isVisitedOcclusionFilterCacheEmpty_ = isEmpty;
55     }
56 
IsVisitedFilterCacheEmpty()57     bool IsVisitedFilterCacheEmpty() const
58     {
59         return isVisitedOcclusionFilterCacheEmpty_;
60     }
61 
62     void SetRotationChanged(bool isRotationChanged);
63     bool GetRotationChanged() const;
64 
65     void SetCurrentAttachedScreenId(uint64_t screenId);
66     uint64_t GetCurrentAttachedScreenId() const;
67     void SetFoldStatusChanged(bool foldStatusChanged);
68 
69     bool CheckFilterCacheNeedForceClear();
70     bool CheckFilterCacheNeedForceSave();
71 
72     // planning: delte when freeze enabled for all nodes.
IsStaticCached()73     bool IsStaticCached() const override
74     {
75         return isStaticCached_;
76     }
77     void InitRenderParams() override;
78     void MarkFilterHasEffectChildren() override;
79     virtual bool EffectNodeShouldPaint() const override;
80     void OnFilterCacheStateChanged() override;
81     bool FirstFrameHasEffectChildren() const override;
82     void MarkClearFilterCacheIfEffectChildrenChanged() override;
83 
84 protected:
85     RectI GetFilterRect() const override;
86     void UpdateFilterCacheWithSelfDirty() override;
87 #ifdef RS_ENABLE_GPU
88     void MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable,
89         RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync) override;
90 #endif
91 
92 private:
93     explicit RSEffectRenderNode(NodeId id, const std::weak_ptr<RSContext>& context = {},
94         bool isTextureExportNode = false);
95     bool FirstFrameHasNoEffectChildren() const;
96 
97     bool isVisitedOcclusionFilterCacheEmpty_ = true;
98     bool isRotationChanged_ = false;
99     bool preRotationStatus_ = false;
100     bool preStaticStatus_ = false;
101 
102     uint64_t currentAttachedScreenId_ = INVALID_SCREEN_ID; // the current screen this node attached.
103     bool foldStatusChanged_ = false; // fold or expand screen.
104 
105     friend class EffectNodeCommandHelper;
106 };
107 } // namespace Rosen
108 } // namespace OHOS
109 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_EFFECT_RENDER_NODE_H
110