Skip to content

Commit 361b1e2

Browse files
yi-guCommit Bot
authored and
Commit Bot
committed
Reland "Reland Group effects support in cc::AnimationPlayer"
This is a reland of 5978ffa. Original change's description: > Reland Group effects support in cc::AnimationPlayer > > Patch https://chromium-review.googlesource.com/c/chromium/src/+/742162 > got reverted because it caused cc_unittest failure on CFI bot. This > patch fixed the bug. > > Commit message from the original patch: > > The current cc/animations logic assumes a single animation has a single > keyframe effect and can only affect a single layer. To enable animations > with multiple keyframe effects, cc::AnimationPlayer need to support > multiple AnimationTickers each corresponding to one keyframe effect. > > Currently there is a 1:1 relationship between AnimationPlayer and > AnimationTicker. This patch is to extend it to 1:n. Here is a summary of > changes: > - Introduce a sub-class of AnimationPlayer, a.k.a > SingleTickerAnimationPlayer, to handle the existing logic (single > effect). SingleTickerAnimationPlayer owns only one AnimationTicker as > the AnimationPlayer does today. > - Currently a AnimationTicker is created upon creating AnimationPlayer. > In this patch, tickers are created separately and added to the player > afterwards. Tickers that the player owns may belong to different targets > therefore the player needs to coordinate with AnimationHost regarding > this situation. > - Adjust existing unit tests according to the changes above. > > Bug: 767043 > Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel > Change-Id: If21bad1285c35bbc048fef6b619c8272c0760551 > Reviewed-on: https://chromium-review.googlesource.com/890724 > Reviewed-by: Ian Vollick <vollick@chromium.org> > Commit-Queue: Yi Gu <yigu@chromium.org> > Cr-Commit-Position: refs/heads/master@{#532519} Bug: 767043 Change-Id: I5e6e7d796ff03cf76c3e2b0de3c4df5b506bf12d Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel Reviewed-on: https://chromium-review.googlesource.com/893338 Reviewed-by: Ian Vollick <vollick@chromium.org> Commit-Queue: Yi Gu <yigu@chromium.org> Cr-Commit-Position: refs/heads/master@{#532882}
1 parent 68e2ab6 commit 361b1e2

33 files changed

+1915
-927
lines changed

cc/animation/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ cc_component("animation") {
3838
"scroll_offset_animations_impl.h",
3939
"scroll_timeline.cc",
4040
"scroll_timeline.h",
41+
"single_ticker_animation_player.cc",
42+
"single_ticker_animation_player.h",
4143
"timing_function.cc",
4244
"timing_function.h",
4345
"transform_operation.cc",

cc/animation/animation_host.cc

+9-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "cc/animation/animation_events.h"
1616
#include "cc/animation/animation_id_provider.h"
1717
#include "cc/animation/animation_player.h"
18+
#include "cc/animation/animation_ticker.h"
1819
#include "cc/animation/animation_timeline.h"
1920
#include "cc/animation/element_animations.h"
2021
#include "cc/animation/scroll_offset_animation_curve.h"
@@ -123,10 +124,10 @@ void AnimationHost::UnregisterElement(ElementId element_id,
123124
element_animations->ElementUnregistered(element_id, list_type);
124125
}
125126

126-
void AnimationHost::RegisterPlayerForElement(ElementId element_id,
127-
AnimationPlayer* player) {
127+
void AnimationHost::RegisterTickerForElement(ElementId element_id,
128+
AnimationTicker* ticker) {
128129
DCHECK(element_id);
129-
DCHECK(player);
130+
DCHECK(ticker);
130131

131132
scoped_refptr<ElementAnimations> element_animations =
132133
GetElementAnimationsForElementId(element_id);
@@ -142,26 +143,24 @@ void AnimationHost::RegisterPlayerForElement(ElementId element_id,
142143
element_animations->InitAffectedElementTypes();
143144
}
144145

145-
element_animations->AddTicker(player->animation_ticker());
146+
element_animations->AddTicker(ticker);
146147
}
147148

148-
void AnimationHost::UnregisterPlayerForElement(ElementId element_id,
149-
AnimationPlayer* player) {
149+
void AnimationHost::UnregisterTickerForElement(ElementId element_id,
150+
AnimationTicker* ticker) {
150151
DCHECK(element_id);
151-
DCHECK(player);
152+
DCHECK(ticker);
152153

153154
scoped_refptr<ElementAnimations> element_animations =
154155
GetElementAnimationsForElementId(element_id);
155156
DCHECK(element_animations);
156-
element_animations->RemoveTicker(player->animation_ticker());
157+
element_animations->RemoveTicker(ticker);
157158

158159
if (element_animations->IsEmpty()) {
159160
element_animations->ClearAffectedElementTypes();
160161
element_to_animations_map_.erase(element_animations->element_id());
161162
element_animations->SetAnimationHost(nullptr);
162163
}
163-
164-
RemoveFromTicking(player);
165164
}
166165

167166
void AnimationHost::SetMutatorHostClient(MutatorHostClient* client) {

cc/animation/animation_host.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ScrollOffset;
2727
namespace cc {
2828

2929
class AnimationPlayer;
30+
class AnimationTicker;
3031
class AnimationTimeline;
3132
class ElementAnimations;
3233
class LayerTreeHost;
@@ -61,9 +62,9 @@ class CC_ANIMATION_EXPORT AnimationHost : public MutatorHost,
6162
void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline);
6263
AnimationTimeline* GetTimelineById(int timeline_id) const;
6364

64-
void RegisterPlayerForElement(ElementId element_id, AnimationPlayer* player);
65-
void UnregisterPlayerForElement(ElementId element_id,
66-
AnimationPlayer* player);
65+
void RegisterTickerForElement(ElementId element_id, AnimationTicker* ticker);
66+
void UnregisterTickerForElement(ElementId element_id,
67+
AnimationTicker* ticker);
6768

6869
scoped_refptr<ElementAnimations> GetElementAnimationsForElementId(
6970
ElementId element_id) const;

cc/animation/animation_host_perftest.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
#include "base/threading/thread_task_runner_handle.h"
88
#include "cc/animation/animation_id_provider.h"
9-
#include "cc/animation/animation_player.h"
9+
#include "cc/animation/animation_ticker.h"
1010
#include "cc/animation/animation_timeline.h"
11+
#include "cc/animation/single_ticker_animation_player.h"
1112
#include "cc/base/lap_timer.h"
1213
#include "cc/test/fake_impl_task_runner_provider.h"
1314
#include "cc/test/fake_layer_tree_host.h"
@@ -69,13 +70,13 @@ class AnimationHostPerfTest : public testing::Test {
6970
root_layer_->AddChild(layer);
7071
layer->SetElementId(LayerIdToElementIdForTesting(layer->id()));
7172

72-
scoped_refptr<AnimationPlayer> player =
73-
AnimationPlayer::Create(last_player_id_);
73+
scoped_refptr<SingleTickerAnimationPlayer> player =
74+
SingleTickerAnimationPlayer::Create(last_player_id_);
7475
last_player_id_ = AnimationIdProvider::NextPlayerId();
7576

7677
all_players_timeline_->AttachPlayer(player);
7778
player->AttachElement(layer->element_id());
78-
EXPECT_TRUE(player->element_animations());
79+
EXPECT_TRUE(player->element_animations(player->animation_ticker()->id()));
7980
}
8081

8182
// Create impl players.

0 commit comments

Comments
 (0)