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 void MarkFilterCacheFlags(std::shared_ptr<DrawableV2::RSFilterDrawable>& filterDrawable, 88 RSDirtyRegionManager& dirtyManager, bool needRequestNextVsync) override; 89 90 private: 91 explicit RSEffectRenderNode(NodeId id, const std::weak_ptr<RSContext>& context = {}, 92 bool isTextureExportNode = false); 93 bool FirstFrameHasNoEffectChildren() const; 94 95 bool isVisitedOcclusionFilterCacheEmpty_ = true; 96 bool isRotationChanged_ = false; 97 bool preRotationStatus_ = false; 98 bool preStaticStatus_ = false; 99 100 uint64_t currentAttachedScreenId_ = INVALID_SCREEN_ID; // the current screen this node attached. 101 bool foldStatusChanged_ = false; // fold or expand screen. 102 103 friend class EffectNodeCommandHelper; 104 }; 105 } // namespace Rosen 106 } // namespace OHOS 107 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_EFFECT_RENDER_NODE_H 108