1 /*
2  * Copyright (c) 2021-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_UI_RS_NODE_H
16 #define RENDER_SERVICE_CLIENT_CORE_UI_RS_NODE_H
17 
18 #include <optional>
19 #include <unordered_map>
20 
21 #include "animation/rs_animation_timing_curve.h"
22 #include "animation/rs_animation_timing_protocol.h"
23 #include "animation/rs_motion_path_option.h"
24 #include "animation/rs_particle_params.h"
25 #include "animation/rs_symbol_node_config.h"
26 #include "animation/rs_transition_effect.h"
27 #include "command/rs_animation_command.h"
28 #include "common/rs_vector2.h"
29 #include "common/rs_vector4.h"
30 #include "modifier/rs_modifier_extractor.h"
31 #include "modifier/rs_modifier_type.h"
32 #include "modifier/rs_showing_properties_freezer.h"
33 #include "pipeline/rs_recording_canvas.h"
34 #include "property/rs_properties.h"
35 #include "render/rs_mask.h"
36 #include "render/rs_path.h"
37 #include "ui_effect/effect/include/background_color_effect_para.h"
38 #include "ui_effect/effect/include/visual_effect.h"
39 #include "ui_effect/filter/include/filter.h"
40 #include "ui_effect/filter/include/filter_pixel_stretch_para.h"
41 #include "ui_effect/filter/include/filter_blur_para.h"
42 #include "ui_effect/filter/include/filter_water_ripple_para.h"
43 #include "ui_effect/filter/include/filter_fly_out_para.h"
44 #include "ui_effect/filter/include/filter_distort_para.h"
45 
46 #include "recording/recording_canvas.h"
47 
48 namespace OHOS {
49 namespace Rosen {
50 using DrawFunc = std::function<void(std::shared_ptr<Drawing::Canvas>)>;
51 using PropertyCallback = std::function<void()>;
52 using BoundsChangedCallback = std::function<void (const Rosen::Vector4f&)>;
53 using ExportTypeChangedCallback = std::function<void(bool)>;
54 class RSAnimation;
55 class RSCommand;
56 class RSImplicitAnimParam;
57 class RSImplicitAnimator;
58 class RSModifier;
59 class RSObjAbsGeometry;
60 
61 class RSC_EXPORT RSNode : public std::enable_shared_from_this<RSNode> {
62 public:
63     using WeakPtr = std::weak_ptr<RSNode>;
64     using SharedPtr = std::shared_ptr<RSNode>;
65     static inline constexpr RSUINodeType Type = RSUINodeType::RS_NODE;
GetType()66     virtual RSUINodeType GetType() const
67     {
68         return Type;
69     }
70 
71     RSNode(const RSNode&) = delete;
72     RSNode(const RSNode&&) = delete;
73     RSNode& operator=(const RSNode&) = delete;
74     RSNode& operator=(const RSNode&&) = delete;
75     virtual ~RSNode();
76 
77     // this id is ONLY used in hierarchy operation commands, this may differ from id_ when the node is a proxy node.
GetHierarchyCommandNodeId()78     virtual NodeId GetHierarchyCommandNodeId() const
79     {
80         return id_;
81     }
82 
83     virtual void AddChild(SharedPtr child, int index = -1);
84     void MoveChild(SharedPtr child, int index);
85     virtual void RemoveChild(SharedPtr child);
86     void RemoveChildByNodeId(NodeId childId);
87     void RemoveFromTree();
88     virtual void ClearChildren();
GetChildren()89     const std::vector<NodeId>& GetChildren() const
90     {
91         return children_;
92     }
93     // ONLY support index in [0, childrenTotal) or index = -1, otherwise return std::nullopt
94     const std::optional<NodeId> GetChildIdByIndex(int index) const;
95 
96     // Add/RemoveCrossParentChild only used as: the child is under multiple parents(e.g. a window cross multi-screens)
97     void AddCrossParentChild(SharedPtr child, int index);
98     void RemoveCrossParentChild(SharedPtr child, NodeId newParentId);
99 
GetId()100     NodeId GetId() const
101     {
102         return id_;
103     }
104 
GetFollowType()105     virtual FollowType GetFollowType() const
106     {
107         return FollowType::NONE;
108     }
109 
110     bool IsInstanceOf(RSUINodeType type) const;
111     template<typename T>
112     RSC_EXPORT bool IsInstanceOf() const;
113 
114     // type-safe reinterpret_cast
115     template<typename T>
ReinterpretCast(const std::shared_ptr<RSNode> & node)116     static std::shared_ptr<T> ReinterpretCast(const std::shared_ptr<RSNode>& node)
117     {
118         return node ? node->ReinterpretCastTo<T>() : nullptr;
119     }
120     template<typename T>
ReinterpretCastTo()121     std::shared_ptr<T> ReinterpretCastTo()
122     {
123         return (IsInstanceOf<T>()) ? std::static_pointer_cast<T>(shared_from_this()) : nullptr;
124     }
125     template<typename T>
ReinterpretCastTo()126     std::shared_ptr<const T> ReinterpretCastTo() const
127     {
128         return (IsInstanceOf<T>()) ? std::static_pointer_cast<const T>(shared_from_this()) : nullptr;
129     }
130 
131     void DumpTree(int depth, std::string& out) const;
132     virtual void Dump(std::string& out) const;
133 
134     virtual std::string DumpNode(int depth) const;
135     SharedPtr GetParent();
136 
SetId(const NodeId & id)137     void SetId(const NodeId& id)
138     {
139         id_ = id;
140     }
141 
142     bool IsUniRenderEnabled() const;
143     bool IsRenderServiceNode() const;
144     void SetTakeSurfaceForUIFlag();
145 
146     static std::vector<std::shared_ptr<RSAnimation>> Animate(const RSAnimationTimingProtocol& timingProtocol,
147         const RSAnimationTimingCurve& timingCurve, const PropertyCallback& callback,
148         const std::function<void()>& finishCallback = nullptr, const std::function<void()>& repeatCallback = nullptr);
149 
150     static std::vector<std::shared_ptr<RSAnimation>> AnimateWithCurrentOptions(
151         const PropertyCallback& callback, const std::function<void()>& finishCallback, bool timingSensitive = true);
152     static std::vector<std::shared_ptr<RSAnimation>> AnimateWithCurrentCallback(
153         const RSAnimationTimingProtocol& timingProtocol, const RSAnimationTimingCurve& timingCurve,
154         const PropertyCallback& callback);
155 
156     static void RegisterTransitionPair(NodeId inNodeId, NodeId outNodeId);
157     static void UnregisterTransitionPair(NodeId inNodeId, NodeId outNodeId);
158 
159     static void OpenImplicitAnimation(const RSAnimationTimingProtocol& timingProtocol,
160         const RSAnimationTimingCurve& timingCurve, const std::function<void()>& finishCallback = nullptr);
161     static std::vector<std::shared_ptr<RSAnimation>> CloseImplicitAnimation();
162     static bool CloseImplicitCancelAnimation();
163     static bool IsImplicitAnimationOpen();
164 
165     static void ExecuteWithoutAnimation(
166         const PropertyCallback& callback, std::shared_ptr<RSImplicitAnimator> implicitAnimator = nullptr);
167 
168     static void AddKeyFrame(
169         float fraction, const RSAnimationTimingCurve& timingCurve, const PropertyCallback& callback);
170     static void AddKeyFrame(float fraction, const PropertyCallback& callback);
171     static void AddDurationKeyFrame(
172         int duration, const RSAnimationTimingCurve& timingCurve, const PropertyCallback& callback);
173 
174     void NotifyTransition(const std::shared_ptr<const RSTransitionEffect>& effect, bool isTransitionIn);
175 
176     void AddAnimation(const std::shared_ptr<RSAnimation>& animation, bool isStartAnimation = true);
177     void RemoveAllAnimations();
178     void RemoveAnimation(const std::shared_ptr<RSAnimation>& animation);
179     void SetMotionPathOption(const std::shared_ptr<RSMotionPathOption>& motionPathOption);
180     const std::shared_ptr<RSMotionPathOption> GetMotionPathOption() const;
181 
DrawOnNode(RSModifierType type,DrawFunc func)182     virtual void DrawOnNode(RSModifierType type, DrawFunc func) {} // [PLANNING]: support SurfaceNode
183 
184     const RSModifierExtractor& GetStagingProperties() const;
185     const RSShowingPropertiesFreezer& GetShowingProperties() const;
186 
187     template<typename ModifierName, typename PropertyName, typename T>
188     void SetProperty(RSModifierType modifierType, T value);
189 
190     virtual void SetBounds(const Vector4f& bounds);
191     virtual void SetBounds(float positionX, float positionY, float width, float height);
192     virtual void SetBoundsWidth(float width);
193     virtual void SetBoundsHeight(float height);
194 
195     virtual void SetFrame(const Vector4f& frame);
196     virtual void SetFrame(float positionX, float positionY, float width, float height);
197     virtual void SetFramePositionX(float positionX);
198     virtual void SetFramePositionY(float positionY);
199 
200     // The property is valid only for CanvasNode and SurfaceNode in uniRender.
201     virtual void SetFreeze(bool isFreeze);
202     void SetNodeName(const std::string& nodeName);
203 
204     void SetSandBox(std::optional<Vector2f> parentPosition);
205 
206     void SetPositionZ(float positionZ);
207     void SetPositionZApplicableCamera3D(bool isApplicable);
208 
209     void SetPivot(const Vector2f& pivot);
210     void SetPivot(float pivotX, float pivotY);
211     void SetPivotX(float pivotX);
212     void SetPivotY(float pivotY);
213     void SetPivotZ(float pivotZ);
214 
215     void SetCornerRadius(float cornerRadius);
216     void SetCornerRadius(const Vector4f& cornerRadius);
217 
218     void SetRotation(const Quaternion& quaternion);
219     void SetRotation(float degreeX, float degreeY, float degreeZ);
220     void SetRotation(float degree);
221     void SetRotationX(float degree);
222     void SetRotationY(float degree);
223     void SetCameraDistance(float cameraDistance);
224 
225     void SetTranslate(const Vector2f& translate);
226     void SetTranslate(float translateX, float translateY, float translateZ);
227     void SetTranslateX(float translate);
228     void SetTranslateY(float translate);
229     void SetTranslateZ(float translate);
230 
231     void SetScale(float scale);
232     void SetScale(float scaleX, float scaleY);
233     void SetScale(const Vector2f& scale);
234     void SetScaleX(float scaleX);
235     void SetScaleY(float scaleY);
236 
237     void SetSkew(float skew);
238     void SetSkew(float skewX, float skewY);
239     void SetSkew(const Vector2f& skew);
240     void SetSkewX(float skewX);
241     void SetSkewY(float skewY);
242 
243     void SetPersp(float persp);
244     void SetPersp(float perspX, float perspY);
245     void SetPersp(const Vector2f& persp);
246     void SetPerspX(float perspX);
247     void SetPerspY(float perspY);
248 
249     void SetAlpha(float alpha);
250     void SetAlphaOffscreen(bool alphaOffscreen);
251 
252     void SetEnvForegroundColor(uint32_t colorValue);
253     void SetEnvForegroundColorStrategy(ForegroundColorStrategyType colorType);
254     void SetParticleParams(
255         std::vector<ParticleParams>& particleParams, const std::function<void()>& finishCallback = nullptr);
256     void SetEmitterUpdater(const std::vector<std::shared_ptr<EmitterUpdater>>& para);
257     void SetParticleNoiseFields(const std::shared_ptr<ParticleNoiseFields>& para);
258     void SetForegroundColor(uint32_t colorValue);
259     void SetBackgroundColor(uint32_t colorValue);
260     void SetBackgroundShader(const std::shared_ptr<RSShader>& shader);
261 
262     void SetBgImage(const std::shared_ptr<RSImage>& image);
263     void SetBgImageInnerRect(const Vector4f& innerRect);
264     void SetBgImageSize(float width, float height);
265     void SetBgImageWidth(float width);
266     void SetBgImageHeight(float height);
267     void SetBgImagePosition(float positionX, float positionY);
268     void SetBgImagePositionX(float positionX);
269     void SetBgImagePositionY(float positionY);
270 
271     void SetBorderColor(uint32_t colorValue);
272     void SetBorderColor(uint32_t left, uint32_t top, uint32_t right, uint32_t bottom);
273     void SetBorderColor(const Vector4<Color>& color);
274     void SetBorderWidth(float width);
275     void SetBorderWidth(float left, float top, float right, float bottom);
276     void SetBorderWidth(const Vector4f& width);
277     void SetBorderStyle(uint32_t styleValue);
278     void SetBorderStyle(uint32_t left, uint32_t top, uint32_t right, uint32_t bottom);
279     void SetBorderStyle(const Vector4<BorderStyle>& style);
280     void SetBorderDashWidth(const Vector4f& dashWidth);
281     void SetBorderDashGap(const Vector4f& dashGap);
282     void SetOuterBorderColor(const Vector4<Color>& color);
283     void SetOuterBorderWidth(const Vector4f& width);
284     void SetOuterBorderStyle(const Vector4<BorderStyle>& style);
285     void SetOuterBorderRadius(const Vector4f& radius);
286     void SetOutlineColor(const Vector4<Color>& color);
287     void SetOutlineWidth(const Vector4f& width);
288     void SetOutlineStyle(const Vector4<BorderStyle>& style);
289     void SetOutlineDashWidth(const Vector4f& dashWidth);
290     void SetOutlineDashGap(const Vector4f& dashGap);
291     void SetOutlineRadius(const Vector4f& radius);
292 
293     // UIEffect
294     void SetUIBackgroundFilter(const OHOS::Rosen::Filter* backgroundFilter);
295     void SetUICompositingFilter(const OHOS::Rosen::Filter* compositingFilter);
296     void SetUIForegroundFilter(const OHOS::Rosen::Filter* foregroundFilter);
297     void SetVisualEffect(const VisualEffect* visualEffect);
298 
299     void SetForegroundEffectRadius(const float blurRadius);
300     void SetBackgroundFilter(const std::shared_ptr<RSFilter>& backgroundFilter);
301     void SetFilter(const std::shared_ptr<RSFilter>& filter);
302     void SetLinearGradientBlurPara(const std::shared_ptr<RSLinearGradientBlurPara>& para);
303     void SetMotionBlurPara(const float radius, const Vector2f& anchor);
304     void SetMagnifierParams(const std::shared_ptr<RSMagnifierParams>& para);
305     void SetDynamicLightUpRate(const float rate);
306     void SetDynamicLightUpDegree(const float lightUpDegree);
307     void SetDynamicDimDegree(const float dimDegree);
308     void SetBlender(const Blender* blender);
309     void SetFgBrightnessParams(const RSDynamicBrightnessPara& params);
310     void SetFgBrightnessRates(const Vector4f& rates);
311     void SetFgBrightnessSaturation(const float& saturation);
312     void SetFgBrightnessPosCoeff(const Vector4f& coeff);
313     void SetFgBrightnessNegCoeff(const Vector4f& coeff);
314     void SetFgBrightnessFract(const float& fract);
315     void SetBgBrightnessParams(const RSDynamicBrightnessPara& params);
316     void SetBgBrightnessRates(const Vector4f& rates);
317     void SetBgBrightnessSaturation(const float& saturation);
318     void SetBgBrightnessPosCoeff(const Vector4f& coeff);
319     void SetBgBrightnessNegCoeff(const Vector4f& coeff);
320     void SetBgBrightnessFract(const float& fract);
321     void SetGreyCoef(const Vector2f greyCoef);
322     void SetCompositingFilter(const std::shared_ptr<RSFilter>& compositingFilter);
323 
324     void SetShadowColor(uint32_t colorValue);
325     void SetShadowOffset(float offsetX, float offsetY);
326     void SetShadowOffsetX(float offsetX);
327     void SetShadowOffsetY(float offsetY);
328     void SetShadowAlpha(float alpha);
329     void SetShadowElevation(float elevation);
330     void SetShadowRadius(float radius);
331     void SetShadowPath(const std::shared_ptr<RSPath>& shadowPath);
332     void SetShadowMask(bool shadowMask);
333     void SetShadowIsFilled(bool shadowIsFilled);
334     void SetShadowColorStrategy(int shadowColorStrategy);
335 
336     void SetFrameGravity(Gravity gravity);
337 
338     void SetClipRRect(const Vector4f& clipRect, const Vector4f& clipRadius);
339     void SetClipRRect(const std::shared_ptr<RRect>& rrect);
340     void SetClipBounds(const std::shared_ptr<RSPath>& clipToBounds);
341     void SetClipToBounds(bool clipToBounds);
342     void SetClipToFrame(bool clipToFrame);
343     void SetCustomClipToFrame(const Vector4f& clipRect);
344 
345     void SetVisible(bool visible);
346     void SetMask(const std::shared_ptr<RSMask>& mask);
347     void SetSpherizeDegree(float spherizeDegree);
348     void SetLightUpEffectDegree(float LightUpEffectDegree);
349 
350     void SetAttractionEffect(float fraction, const Vector2f& destinationPoint);
351     void SetAttractionEffectFraction(float fraction);
352     void SetAttractionEffectDstPoint(const Vector2f& destinationPoint);
353 
354     void SetPixelStretch(const Vector4f& stretchSize, Drawing::TileMode stretchTileMode = Drawing::TileMode::CLAMP);
355     void SetPixelStretchPercent(const Vector4f& stretchPercent,
356         Drawing::TileMode stretchTileMode = Drawing::TileMode::CLAMP);
357 
358     void SetWaterRippleParams(const RSWaterRipplePara& params, float progress);
359     void SetFlyOutParams(const RSFlyOutPara& params, float degree);
360 
361     void SetDistortionK(const float distortionK);
362 
363     void SetPaintOrder(bool drawContentLast);
364 
SetTransitionEffect(const std::shared_ptr<const RSTransitionEffect> & effect)365     void SetTransitionEffect(const std::shared_ptr<const RSTransitionEffect>& effect)
366     {
367         transitionEffect_ = effect;
368     }
369 
370     void SetUseEffect(bool useEffect);
371     void SetUseEffectType(UseEffectType useEffectType);
372 
373     void SetUseShadowBatching(bool useShadowBatching);
374 
375     void SetColorBlendMode(RSColorBlendMode colorBlendMode);
376 
377     void SetColorBlendApplyType(RSColorBlendApplyType colorBlendApplyType);
378 
379     // driven render was shelved, functions will be deleted soon [start]
MarkDrivenRender(bool flag)380     void MarkDrivenRender(bool flag) {}
MarkDrivenRenderItemIndex(int index)381     void MarkDrivenRenderItemIndex(int index) {}
MarkDrivenRenderFramePaintState(bool flag)382     void MarkDrivenRenderFramePaintState(bool flag) {}
MarkContentChanged(bool isChanged)383     void MarkContentChanged(bool isChanged) {}
384     // driven render was shelved, functions will be deleted soon [end]
385 
386     void AddModifier(const std::shared_ptr<RSModifier> modifier);
387     void RemoveModifier(const std::shared_ptr<RSModifier> modifier);
388 
389     void SetIsCustomTextType(bool isCustomTextType);
390 
391     bool GetIsCustomTextType();
392 
393     void SetIsCustomTypeface(bool isCustomTypeface);
394 
395     bool GetIsCustomTypeface();
396 
397     void SetDrawRegion(std::shared_ptr<RectF> rect);
398 
399     // Mark preferentially draw node and childrens
400     void MarkNodeGroup(bool isNodeGroup, bool isForced = true, bool includeProperty = false);
401 
402     // Mark opinc node
403     void MarkSuggestOpincNode(bool isOpincNode, bool isNeedCalculate = false);
404     // will be abandoned
405     void MarkUifirstNode(bool isUifirstNode);
406     // Mark uifirst leash node
407     void MarkUifirstNode(bool isForceFlag, bool isUifirstEnable);
408 
409     void MarkNodeSingleFrameComposer(bool isNodeSingleFrameComposer);
410 
411     void SetGrayScale(float grayScale);
412 
413     void SetLightIntensity(float lightIntensity);
414 
415     void SetLightColor(uint32_t lightColorValue);
416 
417     void SetLightPosition(const Vector4f& lightPosition);
418 
419     void SetLightPosition(float positionX, float positionY, float positionZ);
420 
421     void SetIlluminatedBorderWidth(float illuminatedBorderWidth);
422 
423     void SetIlluminatedType(uint32_t illuminatedType);
424 
425     void SetBloom(float bloomIntensity);
426 
427     void SetBrightness(float brightness);
428 
429     void SetContrast(float contrast);
430 
431     void SetSaturate(float saturate);
432 
433     void SetSepia(float sepia);
434 
435     void SetInvert(float invert);
436 
437     void SetAiInvert(const Vector4f& aiInvert);
438 
439     void SetSystemBarEffect();
440 
441     void SetHueRotate(float hueRotate);
442 
443     void SetColorBlend(uint32_t colorValue);
444 
445     int32_t CalcExpectedFrameRate(const std::string& scene, float speed);
446 
447     void SetOutOfParent(OutOfParentType outOfParent);
448 
449     void SetFrameNodeInfo(int32_t id, std::string tag);
450 
451     virtual void SetTextureExport(bool isTextureExportNode);
452 
453     void SyncTextureExport(bool isTextureExportNode);
454 
455     int32_t GetFrameNodeId();
456 
457     std::string GetFrameNodeTag();
458 
SetBoundsChangedCallback(BoundsChangedCallback callback)459     virtual void SetBoundsChangedCallback(BoundsChangedCallback callback){};
IsTextureExportNode()460     bool IsTextureExportNode() const
461     {
462         return isTextureExportNode_;
463     }
464     void SetExportTypeChangedCallback(ExportTypeChangedCallback callback);
465 
466     bool IsGeometryDirty() const;
467     bool IsAppearanceDirty() const;
468     void MarkDirty(NodeDirtyType type, bool isDirty);
469 
470     float GetGlobalPositionX() const;
471     float GetGlobalPositionY() const;
472 
473     std::shared_ptr<RSObjAbsGeometry> GetLocalGeometry() const;
474     std::shared_ptr<RSObjAbsGeometry> GetGlobalGeometry() const;
475     void UpdateLocalGeometry();
476     void UpdateGlobalGeometry(const std::shared_ptr<RSObjAbsGeometry>& parentGlobalGeometry);
477 
478     std::mutex childrenNodeLock_; // lock for map operation
479     // key: symbolSpanID, value:nodeid and symbol animation node list
480     std::unordered_map<uint64_t, std::unordered_map<NodeId, SharedPtr>> canvasNodesListMap;
481 
482     // key: status : 1 appear, -1 invalid, value:symbol node animation config
483     std::unordered_map<int,
484         std::unordered_map<NodeId,
485             OHOS::Rosen::AnimationNodeConfig>> replaceNodesSwapMap;
486 
487     void SetInstanceId(int32_t instanceId);
GetInstanceId()488     int32_t GetInstanceId() const
489     {
490         return instanceId_;
491     }
492 
GetNodeName()493     const std::string GetNodeName() const
494     {
495         return nodeName_;
496     }
497 protected:
498     explicit RSNode(bool isRenderServiceNode, bool isTextureExportNode = false);
499     explicit RSNode(bool isRenderServiceNode, NodeId id, bool isTextureExportNode = false);
500 
501     bool isRenderServiceNode_;
502     bool isTextureExportNode_ = false;
503     bool skipDestroyCommandInDestructor_ = false;
504     ExportTypeChangedCallback exportTypeChangedCallback_ = nullptr;
505 
506     // Used for same layer rendering, to determine whether RT or RS generates renderNode when the type of node switches
507     bool hasCreateRenderNodeInRT_ = false;
508     bool hasCreateRenderNodeInRS_ = false;
509 
510     bool drawContentLast_ = false;
511 
512     virtual void OnAddChildren();
513     virtual void OnRemoveChildren();
514 
NeedForcedSendToRemote()515     virtual bool NeedForcedSendToRemote() const
516     {
517         return false;
518     }
519 
520     void DoFlushModifier();
521 
522     std::vector<PropertyId> GetModifierIds() const;
523     bool isCustomTextType_ = false;
524     bool isCustomTypeface_ = false;
525 
GetPropertyMutex()526     std::recursive_mutex& GetPropertyMutex() const
527     {
528         return propertyMutex_;
529     }
530 private:
531     static NodeId GenerateId();
532     static void InitUniRenderEnabled();
533     NodeId id_;
534     NodeId parent_ = 0;
535     int32_t instanceId_ = INSTANCE_ID_UNDEFINED;
536     int32_t frameNodeId_ = -1;
537     std::string frameNodeTag_;
538     std::string nodeName_ = "";
539     std::vector<NodeId> children_;
540     void SetParent(NodeId parent);
541     void RemoveChildById(NodeId childId);
CreateRenderNodeForTextureExportSwitch()542     virtual void CreateRenderNodeForTextureExportSwitch() {};
543 
544     void SetBackgroundBlurRadius(float radius);
545     void SetBackgroundBlurSaturation(float saturation);
546     void SetBackgroundBlurBrightness(float brightness);
547     void SetBackgroundBlurMaskColor(Color maskColor);
548     void SetBackgroundBlurColorMode(int colorMode);
549     void SetBackgroundBlurRadiusX(float blurRadiusX);
550     void SetBackgroundBlurRadiusY(float blurRadiusY);
551 
552     void SetForegroundBlurRadius(float radius);
553     void SetForegroundBlurSaturation(float saturation);
554     void SetForegroundBlurBrightness(float brightness);
555     void SetForegroundBlurMaskColor(Color maskColor);
556     void SetForegroundBlurColorMode(int colorMode);
557     void SetForegroundBlurRadiusX(float blurRadiusX);
558     void SetForegroundBlurRadiusY(float blurRadiusY);
559 
560     bool AnimationCallback(AnimationId animationId, AnimationCallbackEvent event);
561     bool HasPropertyAnimation(const PropertyId& id);
562     std::vector<AnimationId> GetAnimationByPropertyId(const PropertyId& id);
563     void FallbackAnimationsToRoot();
564     void AddAnimationInner(const std::shared_ptr<RSAnimation>& animation);
565     void FinishAnimationByProperty(const PropertyId& id);
566     void RemoveAnimationInner(const std::shared_ptr<RSAnimation>& animation);
567     void CancelAnimationByProperty(const PropertyId& id, const bool needForceSync = false);
568     const std::shared_ptr<RSModifier> GetModifier(const PropertyId& propertyId);
OnBoundsSizeChanged()569     virtual void OnBoundsSizeChanged() const {};
570     void UpdateModifierMotionPathOption();
571     void MarkAllExtendModifierDirty();
572     void ResetExtendModifierDirty();
573     void UpdateImplicitAnimator();
574     void SetParticleDrawRegion(std::vector<ParticleParams>& particleParams);
575 
576     // Planning: refactor RSUIAnimationManager and remove this method
577     void ClearAllModifiers();
578 
579     uint32_t dirtyType_ = static_cast<uint32_t>(NodeDirtyType::NOT_DIRTY);
580 
581     std::shared_ptr<RSObjAbsGeometry> localGeometry_;
582     std::shared_ptr<RSObjAbsGeometry> globalGeometry_;
583 
584     float globalPositionX_ = 0.f;
585     float globalPositionY_ = 0.f;
586 
587     pid_t implicitAnimatorTid_ = 0;
588     bool extendModifierIsDirty_ { false };
589 
590     bool isNodeGroup_ = false;
591 
592     bool isNodeSingleFrameComposer_ = false;
593 
594     bool isSuggestOpincNode_ = false;
595 
596     bool isUifirstNode_ = true;
597     bool isForceFlag_ = false;
598     bool isUifirstEnable_ = false;
599 
600     RSModifierExtractor stagingPropertiesExtractor_;
601     RSShowingPropertiesFreezer showingPropertiesFreezer_;
602     std::map<PropertyId, std::shared_ptr<RSModifier>> modifiers_;
603     std::map<uint16_t, std::shared_ptr<RSModifier>> modifiersTypeMap_;
604     std::map<RSModifierType, std::shared_ptr<RSModifier>> propertyModifiers_;
605     std::shared_ptr<RectF> drawRegion_;
606     OutOfParentType outOfParent_ = OutOfParentType::UNKNOWN;
607 
608     std::unordered_map<AnimationId, std::shared_ptr<RSAnimation>> animations_;
609     std::unordered_map<PropertyId, uint32_t> animatingPropertyNum_;
610     std::shared_ptr<RSMotionPathOption> motionPathOption_;
611     std::shared_ptr<RSImplicitAnimator> implicitAnimator_;
612     std::shared_ptr<const RSTransitionEffect> transitionEffect_;
613 
614     std::recursive_mutex animationMutex_;
615     mutable std::recursive_mutex propertyMutex_;
616 
617     friend class RSUIDirector;
618     friend class RSTransition;
619     friend class RSSpringAnimation;
620     friend class RSShowingPropertiesFreezer;
621     friend class RSPropertyBase;
622     friend class RSPropertyAnimation;
623     friend class RSPathAnimation;
624     friend class RSModifierExtractor;
625     friend class RSModifier;
626     friend class RSKeyframeAnimation;
627     friend class RSInterpolatingSpringAnimation;
628     friend class RSImplicitCancelAnimationParam;
629     friend class RSImplicitAnimator;
630     friend class RSGeometryTransModifier;
631     friend class RSExtendedModifier;
632     friend class RSCurveAnimation;
633     friend class RSAnimation;
634     template<typename T>
635     friend class RSProperty;
636     template<typename T>
637     friend class RSAnimatableProperty;
638     friend class RSInteractiveImplictAnimator;
639 };
640 // backward compatibility
641 using RSBaseNode = RSNode;
642 } // namespace Rosen
643 } // namespace OHOS
644 
645 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_NODE_H
646