mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-12-19 21:17:42 +00:00
!981 Bugfix of rosen path animation
Merge pull request !981 from ZhaoXiaoyu/master
This commit is contained in:
commit
f842f025d0
@ -156,7 +156,7 @@ void RSRenderPathAnimation::OnAnimate(float fraction)
|
||||
Vector2f position;
|
||||
float tangent = 0;
|
||||
animationPath_->GetPosTan(distance * progress, position, tangent);
|
||||
SetPathValue(position, tangent);
|
||||
SetPathValue(position + RSRenderPropertyAnimation::GetOriginValue(), tangent);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -218,20 +218,6 @@ void RSImplicitAnimator::PopImplicitParam()
|
||||
implicitAnimationParams_.pop();
|
||||
}
|
||||
|
||||
void RSImplicitAnimator::ProcessPreCreateAnimation(const RSNode& target, const RSAnimatableProperty& property)
|
||||
{
|
||||
if (target.GetMotionPathOption() != nullptr && RSPathAnimation::IsAnimatablePathProperty(property)) {
|
||||
BeginImplicitPathAnimation(target.GetMotionPathOption());
|
||||
}
|
||||
}
|
||||
|
||||
void RSImplicitAnimator::ProcessPostCreateAnimation(const RSNode& target, const RSAnimatableProperty& property)
|
||||
{
|
||||
if (target.GetMotionPathOption() != nullptr && RSPathAnimation::IsAnimatablePathProperty(property)) {
|
||||
EndImplicitPathAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<RSAnimation> RSImplicitAnimator::CreateImplicitTransition(RSNode& target, bool isTransitionIn)
|
||||
{
|
||||
if (globalImplicitParams_.empty() || implicitAnimations_.empty() || keyframeAnimations_.empty()) {
|
||||
@ -275,8 +261,6 @@ std::shared_ptr<RSAnimation> RSImplicitAnimator::CreateImplicitAnimation(
|
||||
return {};
|
||||
}
|
||||
|
||||
ProcessPreCreateAnimation(target, property);
|
||||
|
||||
std::shared_ptr<RSAnimation> animation;
|
||||
auto params = implicitAnimationParams_.top();
|
||||
switch (params->GetType()) {
|
||||
@ -309,8 +293,6 @@ std::shared_ptr<RSAnimation> RSImplicitAnimator::CreateImplicitAnimation(
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessPostCreateAnimation(target, property);
|
||||
|
||||
if (animation == nullptr) {
|
||||
ROSEN_LOGE("Failed to create animation!");
|
||||
return nullptr;
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
void BeginImplicitKeyFrameAnimation(float fraction, const RSAnimationTimingCurve& timingCurve);
|
||||
void BeginImplicitKeyFrameAnimation(float fraction);
|
||||
void BeginImplicitTransition(const std::shared_ptr<const RSTransitionEffect>& effect);
|
||||
void BeginImplicitPathAnimation(const std::shared_ptr<RSMotionPathOption>& motionPathOption);
|
||||
void EndImplicitPathAnimation();
|
||||
void EndImplicitTransition();
|
||||
void EndImplicitKeyFrameAnimation();
|
||||
bool NeedImplicitAnimaton();
|
||||
@ -49,12 +51,8 @@ public:
|
||||
private:
|
||||
void BeginImplicitCurveAnimation();
|
||||
void EndImplicitCurveAnimation();
|
||||
void BeginImplicitPathAnimation(const std::shared_ptr<RSMotionPathOption>& motionPathOption);
|
||||
void EndImplicitPathAnimation();
|
||||
void PushImplicitParam(const std::shared_ptr<RSImplicitAnimationParam>& implicitParam);
|
||||
void PopImplicitParam();
|
||||
void ProcessPreCreateAnimation(const RSNode& target, const RSAnimatableProperty& property);
|
||||
void ProcessPostCreateAnimation(const RSNode& target, const RSAnimatableProperty& property);
|
||||
void CreateEmptyAnimation();
|
||||
|
||||
template<typename T>
|
||||
|
@ -292,6 +292,24 @@ bool IsValid(const Vector4f& value)
|
||||
stagingProperties_.Set##propertyName(value); \
|
||||
} while (0)
|
||||
|
||||
#define CREATE_PATH_ANIMATION(propertyName, value, property) \
|
||||
do { \
|
||||
auto currentValue = stagingProperties_.Get##propertyName(); \
|
||||
if (implicitAnimator_ && implicitAnimator_->NeedImplicitAnimaton() && IsValid(currentValue)) { \
|
||||
implicitAnimator_->BeginImplicitPathAnimation(motionPathOption_); \
|
||||
implicitAnimator_->CreateImplicitAnimation(*this, property, currentValue, value); \
|
||||
implicitAnimator_->EndImplicitPathAnimation(); \
|
||||
return; \
|
||||
} else if (HasPropertyAnimation(property)) { \
|
||||
FinishAnimationByProperty(property); \
|
||||
SET_NONANIMATABLE_PROPERTY(propertyName, value); \
|
||||
return; \
|
||||
} else { \
|
||||
SET_NONANIMATABLE_PROPERTY(propertyName, value); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// alpha
|
||||
void RSNode::SetAlpha(float alpha)
|
||||
{
|
||||
@ -301,6 +319,13 @@ void RSNode::SetAlpha(float alpha)
|
||||
// Bounds
|
||||
void RSNode::SetBounds(const Vector4f& bounds)
|
||||
{
|
||||
if (motionPathOption_ != nullptr) {
|
||||
auto value = bounds;
|
||||
SetBoundsPosition(value[0], value[1]);
|
||||
SetBoundsSize(value[2], value[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
SET_ANIMATABLE_PROPERTY(Bounds, bounds, RSAnimatableProperty::BOUNDS);
|
||||
}
|
||||
|
||||
@ -331,6 +356,11 @@ void RSNode::SetBoundsHeight(float height)
|
||||
|
||||
void RSNode::SetBoundsPosition(const Vector2f& boundsPosition)
|
||||
{
|
||||
if (motionPathOption_ != nullptr) {
|
||||
CREATE_PATH_ANIMATION(BoundsPosition, boundsPosition, RSAnimatableProperty::BOUNDS_POSITION);
|
||||
return;
|
||||
}
|
||||
|
||||
SET_ANIMATABLE_PROPERTY(BoundsPosition, boundsPosition, RSAnimatableProperty::BOUNDS_POSITION);
|
||||
}
|
||||
|
||||
@ -352,6 +382,13 @@ void RSNode::SetBoundsPositionY(float positionY)
|
||||
// Frame
|
||||
void RSNode::SetFrame(const Vector4f& bounds)
|
||||
{
|
||||
if (motionPathOption_ != nullptr) {
|
||||
auto value = bounds;
|
||||
SetFramePosition(value[0], value[1]);
|
||||
SetFrameSize(value[2], value[3]);
|
||||
return;
|
||||
}
|
||||
|
||||
SET_ANIMATABLE_PROPERTY(Frame, bounds, RSAnimatableProperty::FRAME);
|
||||
}
|
||||
|
||||
@ -382,6 +419,11 @@ void RSNode::SetFrameHeight(float height)
|
||||
|
||||
void RSNode::SetFramePosition(const Vector2f& position)
|
||||
{
|
||||
if (motionPathOption_ != nullptr) {
|
||||
CREATE_PATH_ANIMATION(FramePosition, position, RSAnimatableProperty::FRAME_POSITION);
|
||||
return;
|
||||
}
|
||||
|
||||
SET_ANIMATABLE_PROPERTY(FramePosition, position, RSAnimatableProperty::FRAME_POSITION);
|
||||
}
|
||||
|
||||
@ -466,6 +508,11 @@ void RSNode::SetRotationY(float degree)
|
||||
|
||||
void RSNode::SetTranslate(const Vector2f& translate)
|
||||
{
|
||||
if (motionPathOption_ != nullptr) {
|
||||
CREATE_PATH_ANIMATION(Translate, translate, RSAnimatableProperty::TRANSLATE);
|
||||
return;
|
||||
}
|
||||
|
||||
SET_ANIMATABLE_PROPERTY(Translate, translate, RSAnimatableProperty::TRANSLATE);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user