• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SetUIFirstSwitch(RSUIFirstSwitch uiFirstSwitch);
410 
411     void MarkNodeSingleFrameComposer(bool isNodeSingleFrameComposer);
412 
413     void SetGrayScale(float grayScale);
414 
415     void SetLightIntensity(float lightIntensity);
416 
417     void SetLightColor(uint32_t lightColorValue);
418 
419     void SetLightPosition(const Vector4f& lightPosition);
420 
421     void SetLightPosition(float positionX, float positionY, float positionZ);
422 
423     void SetIlluminatedBorderWidth(float illuminatedBorderWidth);
424 
425     void SetIlluminatedType(uint32_t illuminatedType);
426 
427     void SetBloom(float bloomIntensity);
428 
429     void SetBrightness(float brightness);
430 
431     void SetContrast(float contrast);
432 
433     void SetSaturate(float saturate);
434 
435     void SetSepia(float sepia);
436 
437     void SetInvert(float invert);
438 
439     void SetAiInvert(const Vector4f& aiInvert);
440 
441     void SetSystemBarEffect();
442 
443     void SetHueRotate(float hueRotate);
444 
445     void SetColorBlend(uint32_t colorValue);
446 
447     int32_t CalcExpectedFrameRate(const std::string& scene, float speed);
448 
449     void SetOutOfParent(OutOfParentType outOfParent);
450 
451     void SetFrameNodeInfo(int32_t id, std::string tag);
452 
453     virtual void SetTextureExport(bool isTextureExportNode);
454 
455     void SyncTextureExport(bool isTextureExportNode);
456 
457     int32_t GetFrameNodeId();
458 
459     std::string GetFrameNodeTag();
460 
SetBoundsChangedCallback(BoundsChangedCallback callback)461     virtual void SetBoundsChangedCallback(BoundsChangedCallback callback){};
IsTextureExportNode()462     bool IsTextureExportNode() const
463     {
464         return isTextureExportNode_;
465     }
466     void SetExportTypeChangedCallback(ExportTypeChangedCallback callback);
467 
468     bool IsGeometryDirty() const;
469     bool IsAppearanceDirty() const;
470     void MarkDirty(NodeDirtyType type, bool isDirty);
471 
472     float GetGlobalPositionX() const;
473     float GetGlobalPositionY() const;
474 
475     std::shared_ptr<RSObjAbsGeometry> GetLocalGeometry() const;
476     std::shared_ptr<RSObjAbsGeometry> GetGlobalGeometry() const;
477     void UpdateLocalGeometry();
478     void UpdateGlobalGeometry(const std::shared_ptr<RSObjAbsGeometry>& parentGlobalGeometry);
479 
480     std::mutex childrenNodeLock_; // lock for map operation
481     // key: symbolSpanID, value:nodeid and symbol animation node list
482     std::unordered_map<uint64_t, std::unordered_map<NodeId, SharedPtr>> canvasNodesListMap;
483 
484     // key: status : 1 appear, -1 invalid, value:symbol node animation config
485     std::unordered_map<int,
486         std::unordered_map<NodeId,
487             OHOS::Rosen::AnimationNodeConfig>> replaceNodesSwapMap;
488 
489     void SetInstanceId(int32_t instanceId);
GetInstanceId()490     int32_t GetInstanceId() const
491     {
492         return instanceId_;
493     }
494 
GetNodeName()495     const std::string GetNodeName() const
496     {
497         return nodeName_;
498     }
499 protected:
500     explicit RSNode(bool isRenderServiceNode, bool isTextureExportNode = false);
501     explicit RSNode(bool isRenderServiceNode, NodeId id, bool isTextureExportNode = false);
502 
503     bool isRenderServiceNode_;
504     bool isTextureExportNode_ = false;
505     bool skipDestroyCommandInDestructor_ = false;
506     ExportTypeChangedCallback exportTypeChangedCallback_ = nullptr;
507 
508     // Used for same layer rendering, to determine whether RT or RS generates renderNode when the type of node switches
509     bool hasCreateRenderNodeInRT_ = false;
510     bool hasCreateRenderNodeInRS_ = false;
511 
512     bool drawContentLast_ = false;
513 
514     virtual void OnAddChildren();
515     virtual void OnRemoveChildren();
516 
NeedForcedSendToRemote()517     virtual bool NeedForcedSendToRemote() const
518     {
519         return false;
520     }
521 
522     void DoFlushModifier();
523 
524     std::vector<PropertyId> GetModifierIds() const;
525     bool isCustomTextType_ = false;
526     bool isCustomTypeface_ = false;
527 
GetPropertyMutex()528     std::recursive_mutex& GetPropertyMutex() const
529     {
530         return propertyMutex_;
531     }
532 private:
533     static NodeId GenerateId();
534     static void InitUniRenderEnabled();
535     NodeId id_;
536     NodeId parent_ = 0;
537     int32_t instanceId_ = INSTANCE_ID_UNDEFINED;
538     int32_t frameNodeId_ = -1;
539     std::string frameNodeTag_;
540     std::string nodeName_ = "";
541     std::vector<NodeId> children_;
542     void SetParent(NodeId parent);
543     void RemoveChildById(NodeId childId);
CreateRenderNodeForTextureExportSwitch()544     virtual void CreateRenderNodeForTextureExportSwitch() {};
545 
546     void SetBackgroundBlurRadius(float radius);
547     void SetBackgroundBlurSaturation(float saturation);
548     void SetBackgroundBlurBrightness(float brightness);
549     void SetBackgroundBlurMaskColor(Color maskColor);
550     void SetBackgroundBlurColorMode(int colorMode);
551     void SetBackgroundBlurRadiusX(float blurRadiusX);
552     void SetBackgroundBlurRadiusY(float blurRadiusY);
553 
554     void SetForegroundBlurRadius(float radius);
555     void SetForegroundBlurSaturation(float saturation);
556     void SetForegroundBlurBrightness(float brightness);
557     void SetForegroundBlurMaskColor(Color maskColor);
558     void SetForegroundBlurColorMode(int colorMode);
559     void SetForegroundBlurRadiusX(float blurRadiusX);
560     void SetForegroundBlurRadiusY(float blurRadiusY);
561 
562     bool AnimationCallback(AnimationId animationId, AnimationCallbackEvent event);
563     bool HasPropertyAnimation(const PropertyId& id);
564     std::vector<AnimationId> GetAnimationByPropertyId(const PropertyId& id);
565     void FallbackAnimationsToRoot();
566     void AddAnimationInner(const std::shared_ptr<RSAnimation>& animation);
567     void FinishAnimationByProperty(const PropertyId& id);
568     void RemoveAnimationInner(const std::shared_ptr<RSAnimation>& animation);
569     void CancelAnimationByProperty(const PropertyId& id, const bool needForceSync = false);
570     const std::shared_ptr<RSModifier> GetModifier(const PropertyId& propertyId);
OnBoundsSizeChanged()571     virtual void OnBoundsSizeChanged() const {};
572     void UpdateModifierMotionPathOption();
573     void MarkAllExtendModifierDirty();
574     void ResetExtendModifierDirty();
575     void UpdateImplicitAnimator();
576     void SetParticleDrawRegion(std::vector<ParticleParams>& particleParams);
577 
578     // Planning: refactor RSUIAnimationManager and remove this method
579     void ClearAllModifiers();
580 
581     uint32_t dirtyType_ = static_cast<uint32_t>(NodeDirtyType::NOT_DIRTY);
582 
583     std::shared_ptr<RSObjAbsGeometry> localGeometry_;
584     std::shared_ptr<RSObjAbsGeometry> globalGeometry_;
585 
586     float globalPositionX_ = 0.f;
587     float globalPositionY_ = 0.f;
588 
589     pid_t implicitAnimatorTid_ = 0;
590     bool extendModifierIsDirty_ { false };
591 
592     bool isNodeGroup_ = false;
593 
594     bool isNodeSingleFrameComposer_ = false;
595 
596     bool isSuggestOpincNode_ = false;
597 
598     bool isUifirstNode_ = true;
599     bool isForceFlag_ = false;
600     bool isUifirstEnable_ = false;
601     RSUIFirstSwitch uiFirstSwitch_ = RSUIFirstSwitch::NONE;
602 
603     RSModifierExtractor stagingPropertiesExtractor_;
604     RSShowingPropertiesFreezer showingPropertiesFreezer_;
605     std::map<PropertyId, std::shared_ptr<RSModifier>> modifiers_;
606     std::map<uint16_t, std::shared_ptr<RSModifier>> modifiersTypeMap_;
607     std::map<RSModifierType, std::shared_ptr<RSModifier>> propertyModifiers_;
608     std::shared_ptr<RectF> drawRegion_;
609     OutOfParentType outOfParent_ = OutOfParentType::UNKNOWN;
610 
611     std::unordered_map<AnimationId, std::shared_ptr<RSAnimation>> animations_;
612     std::unordered_map<PropertyId, uint32_t> animatingPropertyNum_;
613     std::shared_ptr<RSMotionPathOption> motionPathOption_;
614     std::shared_ptr<RSImplicitAnimator> implicitAnimator_;
615     std::shared_ptr<const RSTransitionEffect> transitionEffect_;
616 
617     std::recursive_mutex animationMutex_;
618     mutable std::recursive_mutex propertyMutex_;
619 
620     friend class RSUIDirector;
621     friend class RSTransition;
622     friend class RSSpringAnimation;
623     friend class RSShowingPropertiesFreezer;
624     friend class RSPropertyBase;
625     friend class RSPropertyAnimation;
626     friend class RSPathAnimation;
627     friend class RSModifierExtractor;
628     friend class RSModifier;
629     friend class RSKeyframeAnimation;
630     friend class RSInterpolatingSpringAnimation;
631     friend class RSImplicitCancelAnimationParam;
632     friend class RSImplicitAnimator;
633     friend class RSGeometryTransModifier;
634     friend class RSExtendedModifier;
635     friend class RSCurveAnimation;
636     friend class RSAnimation;
637     template<typename T>
638     friend class RSProperty;
639     template<typename T>
640     friend class RSAnimatableProperty;
641     friend class RSInteractiveImplictAnimator;
642 };
643 // backward compatibility
644 using RSBaseNode = RSNode;
645 } // namespace Rosen
646 } // namespace OHOS
647 
648 #endif // RENDER_SERVICE_CLIENT_CORE_UI_RS_NODE_H
649