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 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 explicit RSEffectRenderNode(NodeId id, const std::weak_ptr<RSContext>& context = {}, 35 bool isTextureExportNode = false); 36 ~RSEffectRenderNode() override; 37 38 void ProcessRenderBeforeChildren(RSPaintFilterCanvas& canvas) override; 39 40 void Prepare(const std::shared_ptr<RSNodeVisitor>& visitor) override; 41 void Process(const std::shared_ptr<RSNodeVisitor>& visitor) override; 42 #ifndef USE_ROSEN_DRAWING InitializeEffectRegion()43 std::optional<SkIRect> InitializeEffectRegion() const { return SkIRect::MakeEmpty(); } 44 void SetEffectRegion(const std::optional<SkIRect>& effectRegion); 45 #else InitializeEffectRegion()46 std::optional<Drawing::RectI> InitializeEffectRegion() const { return Drawing::RectI(); } 47 void SetEffectRegion(const std::optional<Drawing::RectI>& effectRegion); 48 #endif 49 // record if there is filter cache for occlusion before this effect node SetVisitedFilterCacheStatus(bool isEmpty)50 void SetVisitedFilterCacheStatus(bool isEmpty) 51 { 52 isVisitedOcclusionFilterCacheEmpty_ = isEmpty; 53 } 54 IsVisitedFilterCacheEmpty()55 bool IsVisitedFilterCacheEmpty() const 56 { 57 return isVisitedOcclusionFilterCacheEmpty_; 58 } 59 60 void SetRotationChanged(bool isRotationChanged); 61 bool GetRotationChanged() const; 62 void SetInvalidateTimesForRotation(int times); 63 64 protected: 65 RectI GetFilterRect() const override; 66 void UpdateFilterCacheManagerWithCacheRegion( 67 RSDirtyRegionManager& dirtyManager, const std::optional<RectI>& clipRect) override; 68 void UpdateFilterCacheWithDirty(RSDirtyRegionManager& dirtyManager, bool isForeground) override; 69 70 private: 71 bool NeedForceCache(); 72 73 bool isVisitedOcclusionFilterCacheEmpty_ = true; 74 bool isRotationChanged_ = false; 75 bool preRotationStatus_ = false; 76 bool preStaticStatus_ = false; 77 int invalidateTimes_ = 0; 78 int cacheUpdateInterval_ = 1; 79 }; 80 } // namespace Rosen 81 } // namespace OHOS 82 #endif // RENDER_SERVICE_CLIENT_CORE_PIPELINE_RS_EFFECT_RENDER_NODE_H 83