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