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