Changeset 272178 in webkit
- Timestamp:
- Feb 1, 2021, 2:56:01 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/graphics/ca/PlatformCAAnimation.cpp (modified) (1 diff)
-
WebCore/platform/graphics/ca/PlatformCAAnimation.h (modified) (4 diffs)
-
WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.h (modified) (2 diffs)
-
WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm (modified) (26 diffs)
-
WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (modified) (2 diffs)
-
WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp (modified) (3 diffs)
-
WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h (modified) (2 diffs)
-
WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r272174 r272178 1 2021-02-01 Antoine Quint <graouts@webkit.org> 2 3 Allow support for CAAnimationGroup 4 https://bugs.webkit.org/show_bug.cgi?id=221209 5 6 Reviewed by Dean Jackson, Sam Weinig and Simon Fraser. 7 8 In order to fix bug 219894, we need to use Core Animation's CAAnimationGroup and its 9 setAnimations() method. This patch adds a new "Group" type to PlatformCAAnimation and 10 platform-specific integration for Windows and Cocoa ports. 11 12 * platform/graphics/ca/PlatformCAAnimation.cpp: 13 (WebCore::operator<<): 14 * platform/graphics/ca/PlatformCAAnimation.h: 15 * platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.h: 16 * platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm: 17 (WebCore::PlatformCAAnimationCocoa::PlatformCAAnimationCocoa): 18 (WebCore::PlatformCAAnimationCocoa::keyPath const): 19 (WebCore::PlatformCAAnimationCocoa::setTimingFunction): 20 (WebCore::PlatformCAAnimationCocoa::isAdditive const): 21 (WebCore::PlatformCAAnimationCocoa::setAdditive): 22 (WebCore::PlatformCAAnimationCocoa::valueFunction const): 23 (WebCore::PlatformCAAnimationCocoa::setValueFunction): 24 (WebCore::PlatformCAAnimationCocoa::setFromValue): 25 (WebCore::PlatformCAAnimationCocoa::copyFromValueFrom): 26 (WebCore::PlatformCAAnimationCocoa::setToValue): 27 (WebCore::PlatformCAAnimationCocoa::copyToValueFrom): 28 (WebCore::PlatformCAAnimationCocoa::setValues): 29 (WebCore::PlatformCAAnimationCocoa::copyValuesFrom): 30 (WebCore::PlatformCAAnimationCocoa::setKeyTimes): 31 (WebCore::PlatformCAAnimationCocoa::copyKeyTimesFrom): 32 (WebCore::PlatformCAAnimationCocoa::setTimingFunctions): 33 (WebCore::PlatformCAAnimationCocoa::copyTimingFunctionsFrom): 34 (WebCore::PlatformCAAnimationCocoa::setAnimations): 35 (WebCore::PlatformCAAnimationCocoa::copyAnimationsFrom): 36 * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: 37 (WebCore::PlatformCALayerCocoa::addAnimationForKey): 38 (WebCore::PlatformCALayerCocoa::animationForKey): 39 * platform/graphics/ca/win/PlatformCAAnimationWin.cpp: 40 (PlatformCAAnimationWin::PlatformCAAnimationWin): 41 (PlatformCAAnimationWin::setAnimations): 42 (PlatformCAAnimationWin::copyAnimationsFrom): 43 * platform/graphics/ca/win/PlatformCAAnimationWin.h: 44 1 45 2021-02-01 Saam Barati <sbarati@apple.com> 2 46 -
trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.cpp
r220503 r272178 35 35 switch (type) { 36 36 case PlatformCAAnimation::Basic: ts << "basic"; break; 37 case PlatformCAAnimation::Group: ts << "group"; break; 37 38 case PlatformCAAnimation::Keyframe: ts << "keyframe"; break; 38 39 case PlatformCAAnimation::Spring: ts << "spring"; break; -
trunk/Source/WebCore/platform/graphics/ca/PlatformCAAnimation.h
r262933 r272178 43 43 class PlatformCAAnimation : public RefCounted<PlatformCAAnimation> { 44 44 public: 45 enum AnimationType { Basic, Keyframe, Spring };45 enum AnimationType { Basic, Group, Keyframe, Spring }; 46 46 enum FillModeType { NoFillMode, Forwards, Backwards, Both }; 47 47 enum ValueFunctionType { NoValueFunction, RotateX, RotateY, RotateZ, ScaleX, ScaleY, ScaleZ, Scale, TranslateX, TranslateY, TranslateZ, Translate }; … … 120 120 virtual void copyTimingFunctionsFrom(const PlatformCAAnimation&) = 0; 121 121 122 // Animation group properties. 123 virtual void setAnimations(const Vector<RefPtr<PlatformCAAnimation>>&) = 0; 124 virtual void copyAnimationsFrom(const PlatformCAAnimation&) = 0; 125 122 126 void setActualStartTimeIfNeeded(CFTimeInterval t) 123 127 { … … 127 131 128 132 bool isBasicAnimation() const; 129 133 130 134 protected: 131 135 PlatformCAAnimation(AnimationType type = Basic) … … 157 161 WebCore::PlatformCAAnimation::AnimationType, 158 162 WebCore::PlatformCAAnimation::AnimationType::Basic, 163 WebCore::PlatformCAAnimation::AnimationType::Group, 159 164 WebCore::PlatformCAAnimation::AnimationType::Keyframe, 160 165 WebCore::PlatformCAAnimation::AnimationType::Spring -
trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.h
r260415 r272178 36 36 OBJC_CLASS NSString; 37 37 38 typedef CA PropertyAnimation* PlatformAnimationRef;38 typedef CAAnimation* PlatformAnimationRef; 39 39 40 40 namespace WebCore { … … 124 124 void copyTimingFunctionsFrom(const PlatformCAAnimation&) override; 125 125 126 // Animation group properties. 127 void setAnimations(const Vector<RefPtr<PlatformCAAnimation>>&) final; 128 void copyAnimationsFrom(const PlatformCAAnimation&) final; 129 126 130 private: 127 131 PlatformCAAnimationCocoa(AnimationType, const String& keyPath); 128 132 PlatformCAAnimationCocoa(PlatformAnimationRef); 129 133 130 RetainPtr<CA PropertyAnimation> m_animation;134 RetainPtr<CAAnimation> m_animation; 131 135 }; 132 136 -
trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCAAnimationCocoa.mm
r263941 r272178 168 168 m_animation = [CABasicAnimation animationWithKeyPath:keyPath]; 169 169 break; 170 case Group: 171 m_animation = [CAAnimationGroup animation]; 172 break; 170 173 case Keyframe: 171 174 m_animation = [CAKeyframeAnimation animationWithKeyPath:keyPath]; … … 179 182 PlatformCAAnimationCocoa::PlatformCAAnimationCocoa(PlatformAnimationRef animation) 180 183 { 181 if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CABasicAnimation class]]) { 182 if ([static_cast<CAAnimation*>(animation) isKindOfClass:[CASpringAnimation class]]) 184 auto caAnimation = static_cast<CAAnimation *>(animation); 185 if ([caAnimation isKindOfClass:[CABasicAnimation class]]) { 186 if ([caAnimation isKindOfClass:[CASpringAnimation class]]) 183 187 setType(Spring); 184 188 else 185 189 setType(Basic); 186 } else if ([ static_cast<CAAnimation*>(animation)isKindOfClass:[CAKeyframeAnimation class]])190 } else if ([caAnimation isKindOfClass:[CAKeyframeAnimation class]]) 187 191 setType(Keyframe); 192 else if ([caAnimation isKindOfClass:[CAAnimationGroup class]]) 193 setType(Group); 188 194 else { 189 195 ASSERT_NOT_REACHED(); … … 191 197 } 192 198 193 m_animation = static_cast<CAPropertyAnimation*>(animation);199 m_animation = caAnimation; 194 200 } 195 201 … … 236 242 String PlatformCAAnimationCocoa::keyPath() const 237 243 { 238 return [m_animation keyPath]; 244 if (animationType() == Group) 245 return emptyString(); 246 247 ASSERT([static_cast<CAAnimation *>(m_animation.get()) isKindOfClass:[CAPropertyAnimation class]]); 248 return [static_cast<CAPropertyAnimation *>(m_animation.get()) keyPath]; 239 249 } 240 250 … … 334 344 } 335 345 break; 346 case Group: 347 break; 336 348 } 337 349 } … … 354 366 bool PlatformCAAnimationCocoa::isAdditive() const 355 367 { 356 return [m_animation isAdditive]; 368 if (animationType() == Group) 369 return false; 370 371 ASSERT([static_cast<CAAnimation *>(m_animation.get()) isKindOfClass:[CAPropertyAnimation class]]); 372 return [static_cast<CAPropertyAnimation *>(m_animation.get()) isAdditive]; 357 373 } 358 374 359 375 void PlatformCAAnimationCocoa::setAdditive(bool value) 360 376 { 361 [m_animation setAdditive:value]; 377 if (animationType() == Group) 378 return; 379 380 ASSERT([static_cast<CAAnimation *>(m_animation.get()) isKindOfClass:[CAPropertyAnimation class]]); 381 return [static_cast<CAPropertyAnimation *>(m_animation.get()) setAdditive:value]; 362 382 } 363 383 364 384 PlatformCAAnimation::ValueFunctionType PlatformCAAnimationCocoa::valueFunction() const 365 385 { 366 return fromCAValueFunctionType([[m_animation valueFunction] name]); 386 if (animationType() == Group) 387 return NoValueFunction; 388 389 ASSERT([static_cast<CAAnimation *>(m_animation.get()) isKindOfClass:[CAPropertyAnimation class]]); 390 return fromCAValueFunctionType([[static_cast<CAPropertyAnimation *>(m_animation.get()) valueFunction] name]); 367 391 } 368 392 369 393 void PlatformCAAnimationCocoa::setValueFunction(ValueFunctionType value) 370 394 { 371 [m_animation setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(value)]]; 395 if (animationType() == Group) 396 return; 397 398 ASSERT([static_cast<CAAnimation *>(m_animation.get()) isKindOfClass:[CAPropertyAnimation class]]); 399 return [static_cast<CAPropertyAnimation *>(m_animation.get()) setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(value)]]; 372 400 } 373 401 … … 376 404 if (!isBasicAnimation()) 377 405 return; 378 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:@(value)];406 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:@(value)]; 379 407 } 380 408 … … 383 411 if (!isBasicAnimation()) 384 412 return; 385 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:[NSValue valueWithCATransform3D:value]];413 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:[NSValue valueWithCATransform3D:value]]; 386 414 } 387 415 … … 390 418 if (!isBasicAnimation()) 391 419 return; 392 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:@[ @(value.x()), @(value.y()), @(value.z()) ]];420 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:@[ @(value.x()), @(value.y()), @(value.z()) ]]; 393 421 } 394 422 … … 398 426 return; 399 427 auto [r, g, b, a] = value.toSRGBALossy<uint8_t>(); 400 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:@[@(r), @(g), @(b), @(a)]];428 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:@[@(r), @(g), @(b), @(a)]]; 401 429 } 402 430 … … 404 432 { 405 433 auto value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex); 406 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:value.get()];434 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:value.get()]; 407 435 } 408 436 … … 411 439 if (!isBasicAnimation() || !value.isBasicAnimation()) 412 440 return; 413 auto otherAnimation = static_cast<CABasicAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());414 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:[otherAnimation fromValue]];441 auto otherAnimation = static_cast<CABasicAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get()); 442 [static_cast<CABasicAnimation *>(m_animation.get()) setFromValue:[otherAnimation fromValue]]; 415 443 } 416 444 … … 419 447 if (!isBasicAnimation()) 420 448 return; 421 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:@(value)];449 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:@(value)]; 422 450 } 423 451 … … 426 454 if (!isBasicAnimation()) 427 455 return; 428 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:[NSValue valueWithCATransform3D:value]];456 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:[NSValue valueWithCATransform3D:value]]; 429 457 } 430 458 … … 433 461 if (!isBasicAnimation()) 434 462 return; 435 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:@[ @(value.x()), @(value.y()), @(value.z()) ]];463 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:@[ @(value.x()), @(value.y()), @(value.z()) ]]; 436 464 } 437 465 … … 441 469 return; 442 470 auto [r, g, b, a] = value.toSRGBALossy<uint8_t>(); 443 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:@[@(r), @(g), @(b), @(a)]];471 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:@[@(r), @(g), @(b), @(a)]]; 444 472 } 445 473 … … 447 475 { 448 476 auto value = PlatformCAFilters::filterValueForOperation(operation, internalFilterPropertyIndex); 449 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:value.get()];477 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:value.get()]; 450 478 } 451 479 … … 455 483 return; 456 484 457 auto otherAnimation = static_cast<CABasicAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());458 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:[otherAnimation toValue]];485 auto otherAnimation = static_cast<CABasicAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get()); 486 [static_cast<CABasicAnimation *>(m_animation.get()) setToValue:[otherAnimation toValue]]; 459 487 } 460 488 … … 466 494 return; 467 495 468 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(value, [] (float number) {496 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(value, [] (float number) { 469 497 return @(number); 470 498 }).get()]; … … 476 504 return; 477 505 478 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(value, [] (auto& matrix) {506 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(value, [] (auto& matrix) { 479 507 return [NSValue valueWithCATransform3D:matrix]; 480 508 }).get()]; … … 486 514 return; 487 515 488 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(value, [] (auto& point) {516 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(value, [] (auto& point) { 489 517 return @[@(point.x()), @(point.y()), @(point.z())]; 490 518 }).get()]; … … 496 524 return; 497 525 498 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(value, [] (auto& color) {526 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(value, [] (auto& color) { 499 527 auto [r, g, b, a] = color.template toSRGBALossy<uint8_t>(); 500 528 return @[@(r), @(g), @(b), @(a)]; … … 507 535 return; 508 536 509 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(values, [&] (auto& value) {537 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:createNSArray(values, [&] (auto& value) { 510 538 return PlatformCAFilters::filterValueForOperation(value.get(), internalFilterPropertyIndex); 511 539 }).get()]; … … 517 545 return; 518 546 519 auto otherAnimation = static_cast<CAKeyframeAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());520 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:[otherAnimation values]];547 auto otherAnimation = static_cast<CAKeyframeAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get()); 548 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setValues:[otherAnimation values]]; 521 549 } 522 550 523 551 void PlatformCAAnimationCocoa::setKeyTimes(const Vector<float>& value) 524 552 { 525 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setKeyTimes:createNSArray(value, [] (float time) {553 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setKeyTimes:createNSArray(value, [] (float time) { 526 554 return @(time); 527 555 }).get()]; … … 530 558 void PlatformCAAnimationCocoa::copyKeyTimesFrom(const PlatformCAAnimation& value) 531 559 { 532 auto other = static_cast<CAKeyframeAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get());533 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setKeyTimes:[other keyTimes]];560 auto other = static_cast<CAKeyframeAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get()); 561 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setKeyTimes:[other keyTimes]]; 534 562 } 535 563 536 564 void PlatformCAAnimationCocoa::setTimingFunctions(const Vector<const TimingFunction*>& value, bool reverse) 537 565 { 538 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setTimingFunctions:createNSArray(value, [&] (auto& function) {566 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setTimingFunctions:createNSArray(value, [&] (auto& function) { 539 567 return toCAMediaTimingFunction(function, reverse); 540 568 }).get()]; … … 543 571 void PlatformCAAnimationCocoa::copyTimingFunctionsFrom(const PlatformCAAnimation& value) 544 572 { 545 auto other = static_cast<CAKeyframeAnimation*>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get()); 546 [static_cast<CAKeyframeAnimation*>(m_animation.get()) setTimingFunctions:[other timingFunctions]]; 573 auto other = static_cast<CAKeyframeAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get()); 574 [static_cast<CAKeyframeAnimation *>(m_animation.get()) setTimingFunctions:[other timingFunctions]]; 575 } 576 577 void PlatformCAAnimationCocoa::setAnimations(const Vector<RefPtr<PlatformCAAnimation>>& value) 578 { 579 ASSERT(animationType() == Group); 580 ASSERT([static_cast<CAAnimation *>(m_animation.get()) isKindOfClass:[CAAnimationGroup class]]); 581 582 [static_cast<CAAnimationGroup *>(m_animation.get()) setAnimations:createNSArray(value, [&] (auto& animation) -> CAAnimation * { 583 if (is<PlatformCAAnimationCocoa>(animation.get())) 584 return downcast<PlatformCAAnimationCocoa>(animation.get())->m_animation.get(); 585 return nil; 586 }).get()]; 587 } 588 589 void PlatformCAAnimationCocoa::copyAnimationsFrom(const PlatformCAAnimation& value) 590 { 591 ASSERT(animationType() == Group); 592 ASSERT(value.animationType() == Group); 593 ASSERT([static_cast<CAAnimation *>(m_animation.get()) isKindOfClass:[CAAnimationGroup class]]); 594 ASSERT([static_cast<CAAnimation *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get()) isKindOfClass:[CAAnimationGroup class]]); 595 596 auto other = static_cast<CAAnimationGroup *>(downcast<PlatformCAAnimationCocoa>(value).m_animation.get()); 597 [static_cast<CAAnimationGroup *>(m_animation.get()) setAnimations:[other animations]]; 547 598 } 548 599 -
trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
r271699 r272178 512 512 } 513 513 514 CA PropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>(downcast<PlatformCAAnimationCocoa>(animation).platformAnimation());514 CAAnimation *propertyAnimation = static_cast<CAAnimation *>(downcast<PlatformCAAnimationCocoa>(animation).platformAnimation()); 515 515 if (![propertyAnimation delegate]) 516 516 [propertyAnimation setDelegate:static_cast<id>(m_delegate.get())]; … … 530 530 RefPtr<PlatformCAAnimation> PlatformCALayerCocoa::animationForKey(const String& key) 531 531 { 532 CA PropertyAnimation* propertyAnimation = static_cast<CAPropertyAnimation*>([m_layer animationForKey:key]);532 CAAnimation *propertyAnimation = static_cast<CAAnimation *>([m_layer animationForKey:key]); 533 533 if (!propertyAnimation) 534 534 return nullptr; -
trunk/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.cpp
r263941 r272178 158 158 if (type == Basic) 159 159 m_animation = adoptCF(CACFAnimationCreate(kCACFBasicAnimation)); 160 else 160 else if (type == Keyframe) 161 161 m_animation = adoptCF(CACFAnimationCreate(kCACFKeyframeAnimation)); 162 else if (type == Group) 163 m_animation = adoptCF(CACFAnimationCreate(kCACFAnimationGroup)); 162 164 163 165 CACFAnimationSetKeyPath(m_animation.get(), keyPath.createCFString().get()); … … 170 172 else if (CACFAnimationGetClass(animation) == kCACFKeyframeAnimation) 171 173 setType(Keyframe); 174 else if (CACFAnimationGetClass(animation) == kCACFAnimationGroup) 175 setType(Group); 172 176 else { 173 177 ASSERT_NOT_REACHED(); … … 554 558 } 555 559 560 void PlatformCAAnimationWin::setAnimations(const Vector<RefPtr<PlatformCAAnimation>>& value) 561 { 562 auto array = adoptCF(CFArrayCreateMutable(0, value.size(), &kCFTypeArrayCallBacks)); 563 for (auto& animation : value) { 564 if (is<PlatformCAAnimationWin>(animation.get())) 565 CFArrayAppendValue(array.get(), downcast<PlatformCAAnimationWin>(*animation).m_animation.get()); 566 } 567 568 CACFAnimationSetAnimations(m_animation.get(), array.get()); 569 } 570 571 void PlatformCAAnimationWin::copyAnimationsFrom(const PlatformCAAnimation& value) 572 { 573 CACFAnimationSetAnimations(m_animation.get(), CACFAnimationGetAnimations(downcast<PlatformCAAnimationWin>(value).platformAnimation())); 574 } 575 556 576 #endif // PLATFORM(WIN) -
trunk/Source/WebCore/platform/graphics/ca/win/PlatformCAAnimationWin.h
r260415 r272178 114 114 void copyTimingFunctionsFrom(const PlatformCAAnimation&) override; 115 115 116 // Animation group properties. 117 void setAnimations(const Vector<RefPtr<PlatformCAAnimation>>&) final; 118 void copyAnimationsFrom(const PlatformCAAnimation&) final; 119 116 120 private: 117 121 PlatformCAAnimationWin(AnimationType, const String& keyPath); -
trunk/Source/WebKit/ChangeLog
r272175 r272178 1 2021-02-01 Antoine Quint <graouts@webkit.org> 2 3 Allow support for CAAnimationGroup 4 https://bugs.webkit.org/show_bug.cgi?id=221209 5 6 Reviewed by Dean Jackson, Sam Weinig and Simon Fraser. 7 8 In order to fix bug 219894, we need to use Core Animation's CAAnimationGroup and its 9 setAnimations() method. Add support for the new "Group" PlatformCAAnimation type for 10 the remote animations. 11 12 * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h: 13 * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm: 14 (WebKit::PlatformCAAnimationRemote::Properties::encode const): 15 (WebKit::PlatformCAAnimationRemote::Properties::decode): 16 (WebKit::PlatformCAAnimationRemote::copy const): 17 (WebKit::PlatformCAAnimationRemote::setAnimations): 18 (WebKit::PlatformCAAnimationRemote::copyAnimationsFrom): 19 (WebKit::createAnimation): 20 (WebKit::addAnimationToLayer): 21 (WebKit::operator<<): 22 1 23 2021-02-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 24 -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h
r265098 r272178 120 120 void copyTimingFunctionsFrom(const WebCore::PlatformCAAnimation&) override; 121 121 122 // Animation group properties. 123 void setAnimations(const Vector<RefPtr<PlatformCAAnimation>>&) final; 124 void copyAnimationsFrom(const PlatformCAAnimation&) final; 125 122 126 AnimationType animationType() const { return m_properties.animationType; } 123 127 void setHasExplicitBeginTime(bool hasExplicitBeginTime) { m_properties.hasExplicitBeginTime = hasExplicitBeginTime; } … … 290 294 Vector<float> keyTimes; 291 295 Vector<RefPtr<WebCore::TimingFunction>> timingFunctions; 296 297 Vector<Properties> animations; 292 298 }; 293 299 -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.mm
r265932 r272178 242 242 for (const auto& timingFunction : timingFunctions) 243 243 encodeTimingFunction(encoder, timingFunction.get()); 244 245 encoder << animations; 244 246 } 245 247 … … 320 322 } 321 323 } 324 325 if (!decoder.decode(properties.animations)) 326 return WTF::nullopt; 322 327 323 328 return WTFMove(properties); … … 356 361 animation->copyToValueFrom(*this); 357 362 } 358 363 364 animation->copyAnimationsFrom(*this); 365 359 366 return animation; 360 367 } … … 710 717 m_properties.timingFunctions = other.m_properties.timingFunctions; 711 718 m_properties.reverseTimingFunctions = other.m_properties.reverseTimingFunctions; 719 } 720 721 void PlatformCAAnimationRemote::setAnimations(const Vector<RefPtr<PlatformCAAnimation>>& values) 722 { 723 m_properties.animations = values.map([](auto& value) { 724 return downcast<PlatformCAAnimationRemote>(value.get())->properties(); 725 }); 726 } 727 728 void PlatformCAAnimationRemote::copyAnimationsFrom(const PlatformCAAnimation& value) 729 { 730 const PlatformCAAnimationRemote& other = downcast<PlatformCAAnimationRemote>(value); 731 m_properties.animations = other.m_properties.animations; 712 732 } 713 733 … … 735 755 } 736 756 737 static void addAnimationToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const String& key, const PlatformCAAnimationRemote::Properties& properties)738 { 739 RetainPtr<CA PropertyAnimation> caAnimation;757 static RetainPtr<CAAnimation> createAnimation(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const PlatformCAAnimationRemote::Properties& properties) 758 { 759 RetainPtr<CAAnimation> caAnimation; 740 760 switch (properties.animationType) { 741 761 case PlatformCAAnimation::Basic: { 742 762 auto basicAnimation = [CABasicAnimation animationWithKeyPath:properties.keyPath]; 743 763 744 764 if (properties.keyValues.size() > 1) { 745 765 [basicAnimation setFromValue:animationValueFromKeyframeValue(properties.keyValues[0])]; … … 751 771 752 772 caAnimation = basicAnimation; 773 break; 774 } 775 case PlatformCAAnimation::Group: { 776 auto animationGroup = [CAAnimationGroup animation]; 777 778 if (properties.animations.size()) { 779 [animationGroup setAnimations:createNSArray(properties.animations, [&] (auto& animationProperties) { 780 return createAnimation(layer, layerTreeHost, animationProperties).get(); 781 }).get()]; 782 } 783 784 caAnimation = animationGroup; 753 785 break; 754 786 } … … 776 808 }).get()]; 777 809 } 778 810 779 811 caAnimation = keyframeAnimation; 780 812 break; … … 782 814 case PlatformCAAnimation::Spring: { 783 815 auto springAnimation = [CASpringAnimation animationWithKeyPath:properties.keyPath]; 784 816 785 817 if (properties.keyValues.size() > 1) { 786 818 [springAnimation setFromValue:animationValueFromKeyframeValue(properties.keyValues[0])]; 787 819 [springAnimation setToValue:animationValueFromKeyframeValue(properties.keyValues[1])]; 788 820 } 789 821 790 822 if (properties.timingFunctions.size()) { 791 823 auto& timingFunction = properties.timingFunctions[0]; … … 802 834 } 803 835 } 804 836 805 837 [caAnimation setBeginTime:properties.beginTime]; 806 838 [caAnimation setDuration:properties.duration]; … … 810 842 [caAnimation setAutoreverses:properties.autoReverses]; 811 843 [caAnimation setRemovedOnCompletion:properties.removedOnCompletion]; 812 [caAnimation setAdditive:properties.additive]; 813 844 845 if ([caAnimation isKindOfClass:[CAPropertyAnimation class]]) { 846 [(CAPropertyAnimation *)caAnimation setAdditive:properties.additive]; 847 if (properties.valueFunction != PlatformCAAnimation::NoValueFunction) 848 [(CAPropertyAnimation *)caAnimation setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(properties.valueFunction)]]; 849 } 850 814 851 if (properties.fillMode != PlatformCAAnimation::NoFillMode) 815 852 [caAnimation setFillMode:toCAFillModeType(properties.fillMode)]; 816 853 817 if (properties.valueFunction != PlatformCAAnimation::NoValueFunction)818 [caAnimation setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(properties.valueFunction)]];819 820 854 if (properties.hasExplicitBeginTime) 821 855 [caAnimation setValue:@YES forKey:WKExplicitBeginTimeFlag]; 822 856 823 857 if (layerTreeHost) { 824 858 GraphicsLayer::PlatformLayerID layerID = RemoteLayerTreeNode::layerID(layer); 825 859 826 860 RetainPtr<WKAnimationDelegate>& delegate = layerTreeHost->animationDelegates().add(layerID, nullptr).iterator->value; 827 861 if (!delegate) … … 830 864 [caAnimation setDelegate:delegate.get()]; 831 865 } 832 833 [layer addAnimation:caAnimation.get() forKey:key]; 866 867 return caAnimation; 868 } 869 870 static void addAnimationToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHost, const String& key, const PlatformCAAnimationRemote::Properties& properties) 871 { 872 [layer addAnimation:createAnimation(layer, layerTreeHost, properties).get() forKey:key]; 834 873 } 835 874 … … 944 983 ts.decreaseIndent(); 945 984 985 if (!animation.animations.isEmpty()) { 986 ts << "\n"; 987 ts.increaseIndent(); 988 ts.writeIndent(); 989 ts << "(" << "animations"; 990 ts.increaseIndent(); 991 992 for (auto& childAnimation : animation.animations) { 993 ts << "\n"; 994 ts.writeIndent(); 995 ts << "(animation " << childAnimation; 996 ts << ")"; 997 } 998 999 ts.decreaseIndent(); 1000 ts.decreaseIndent(); 1001 } 1002 946 1003 return ts; 947 1004 }
Note:
See TracChangeset
for help on using the changeset viewer.