Skip to content

Commit 3904dc2

Browse files
yi-guCommit Bot
authored and
Commit Bot
committed
Rename cc animation classes to be consistent with blink classes and spec
Currently the names of Animation related classes on cc side is very confusing. e.g. cc::Animation is quite different from blink::Animation. blink::Animation is corresponding to cc::AnimationPlayer which owns multiple cc::AnimationTicker which owns multiple cc::Animation. To be consistent with blink, it’s better to rename the relevant classes. In addition, the cc::AnimationTicker behaves as the cc counterpart of blink::KeyframeEffect therefore it should be renamed as well. Corresponding changes are also made to the clients of cc::Animation (vr, ui, blink) in this patch. Summary: This patch: Animation -> KeyframeModel AnimationTicker -> KeyframeEffect Follow up patch: AnimationPlayer -> Animation Bug: 807667 Cq-Include-Trybots: master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I24c240b514da38541e4dd8a5550a9092ebd11430 Reviewed-on: https://chromium-review.googlesource.com/906830 Commit-Queue: Yi Gu <yigu@chromium.org> Reviewed-by: Ian Vollick <vollick@chromium.org> Reviewed-by: Majid Valipour <majidvp@chromium.org> Reviewed-by: Robert Flack <flackr@chromium.org> Reviewed-by: Stephen McGruer <smcgruer@chromium.org> Cr-Commit-Position: refs/heads/master@{#537082}
1 parent 302248e commit 3904dc2

File tree

105 files changed

+4654
-4291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+4654
-4291
lines changed

cc/animation/BUILD.gn

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import("//cc/cc.gni")
77
cc_component("animation") {
88
output_name = "cc_animation"
99
sources = [
10-
"animation.cc",
11-
"animation.h",
1210
"animation_curve.cc",
1311
"animation_curve.h",
1412
"animation_delegate.h",
@@ -22,12 +20,14 @@ cc_component("animation") {
2220
"animation_player.cc",
2321
"animation_player.h",
2422
"animation_target.h",
25-
"animation_ticker.cc",
26-
"animation_ticker.h",
2723
"animation_timeline.cc",
2824
"animation_timeline.h",
2925
"element_animations.cc",
3026
"element_animations.h",
27+
"keyframe_effect.cc",
28+
"keyframe_effect.h",
29+
"keyframe_model.cc",
30+
"keyframe_model.h",
3131
"keyframed_animation_curve.cc",
3232
"keyframed_animation_curve.h",
3333
"scroll_offset_animation_curve.cc",
@@ -38,8 +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",
41+
"single_keyframe_effect_animation_player.cc",
42+
"single_keyframe_effect_animation_player.h",
4343
"timing_function.cc",
4444
"timing_function.h",
4545
"transform_operation.cc",

cc/animation/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ of Chromium interact with cc/animation, most prominently Blink and ui/.
1919
## How cc/animation works
2020

2121
The root concept in cc/animation is an
22-
[animation](https://codesearch.chromium.org/chromium/src/cc/animation/animation.h).
22+
[keyframe model](https://codesearch.chromium.org/chromium/src/cc/animation/keyframe_model.h).
2323
Animations contain the state necessary to 'play' (interpolate values from) an
2424
[animation curve](https://codesearch.chromium.org/chromium/src/cc/animation/animation_curve.h),
2525
which is a function that returns a value given an input time. Aside from the
@@ -29,10 +29,10 @@ An animation does not know or care what property is being animated, and holds
2929
only an opaque identifier for the property to allow clients to map output values
3030
to the correct properties.
3131

32-
Targeting only a single property means that cc animations are distinct from the
32+
Targeting only a single property means that cc KeyframeModels are distinct from the
3333
Blink concept of an animation, which wraps the animation of multiple properties.
3434
To coordinate the playback of multiple cc/animations (e.g. those that are
35-
animating multiple properties on the same target), animations have the concept
35+
animating multiple properties on the same target), KeyframeModels have the concept
3636
of a group identifier. Animations that have the same group identifier and the
3737
same target are started together, and animation-finished notifications are only
3838
sent when all animations in the group have finished.
@@ -42,7 +42,7 @@ Animations are grouped together based on their
4242
(the entity whose property is being animated) and each such group is owned by an
4343
[animation player](https://codesearch.chromium.org/chromium/src/cc/animation/animation_player.h).
4444
Note that there may be multiple animation players with the same target (each
45-
with a set of animations for that target); the
45+
with a set of KeyframeModels for that target); the
4646
[ElementAnimations](https://codesearch.chromium.org/chromium/src/cc/animation/element_animations.h)
4747
class wraps the multiple animation players and has a 1:1 relationship with
4848
target entities.

cc/animation/animation_delegate.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66
#define CC_ANIMATION_ANIMATION_DELEGATE_H_
77

88
#include "base/time/time.h"
9-
#include "cc/animation/animation.h"
109
#include "cc/animation/animation_curve.h"
10+
#include "cc/animation/keyframe_model.h"
1111

1212
namespace cc {
1313

1414
class CC_ANIMATION_EXPORT AnimationDelegate {
1515
public:
16+
// TODO(yigu): The Notify* methods will be called multiple times per
17+
// animation (once for effect/property pairing).
18+
// Ideally, we would only notify start once (e.g., wait on all effects to
19+
// start before notifying delegate) this way effect becomes an internal
20+
// details of the player. Perhaps we can do that at some point maybe as part
21+
// of https://bugs.chromium.org/p/chromium/issues/detail?id=810003
1622
virtual void NotifyAnimationStarted(base::TimeTicks monotonic_time,
1723
int target_property,
1824
int group) = 0;

cc/animation/animation_events.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include <memory>
99
#include <vector>
1010

11-
#include "cc/animation/animation.h"
1211
#include "cc/animation/animation_curve.h"
1312
#include "cc/animation/animation_export.h"
13+
#include "cc/animation/keyframe_model.h"
1414
#include "cc/paint/filter_operations.h"
1515
#include "cc/trees/element_id.h"
1616
#include "cc/trees/mutator_host.h"

cc/animation/animation_host.cc

+22-18
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
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"
1918
#include "cc/animation/animation_timeline.h"
2019
#include "cc/animation/element_animations.h"
20+
#include "cc/animation/keyframe_effect.h"
2121
#include "cc/animation/scroll_offset_animation_curve.h"
2222
#include "cc/animation/scroll_offset_animations.h"
2323
#include "cc/animation/scroll_offset_animations_impl.h"
@@ -124,10 +124,11 @@ void AnimationHost::UnregisterElement(ElementId element_id,
124124
element_animations->ElementUnregistered(element_id, list_type);
125125
}
126126

127-
void AnimationHost::RegisterTickerForElement(ElementId element_id,
128-
AnimationTicker* ticker) {
127+
void AnimationHost::RegisterKeyframeEffectForElement(
128+
ElementId element_id,
129+
KeyframeEffect* keyframe_effect) {
129130
DCHECK(element_id);
130-
DCHECK(ticker);
131+
DCHECK(keyframe_effect);
131132

132133
scoped_refptr<ElementAnimations> element_animations =
133134
GetElementAnimationsForElementId(element_id);
@@ -143,18 +144,19 @@ void AnimationHost::RegisterTickerForElement(ElementId element_id,
143144
element_animations->InitAffectedElementTypes();
144145
}
145146

146-
element_animations->AddTicker(ticker);
147+
element_animations->AddKeyframeEffect(keyframe_effect);
147148
}
148149

149-
void AnimationHost::UnregisterTickerForElement(ElementId element_id,
150-
AnimationTicker* ticker) {
150+
void AnimationHost::UnregisterKeyframeEffectForElement(
151+
ElementId element_id,
152+
KeyframeEffect* keyframe_effect) {
151153
DCHECK(element_id);
152-
DCHECK(ticker);
154+
DCHECK(keyframe_effect);
153155

154156
scoped_refptr<ElementAnimations> element_animations =
155157
GetElementAnimationsForElementId(element_id);
156158
DCHECK(element_animations);
157-
element_animations->RemoveTicker(ticker);
159+
element_animations->RemoveKeyframeEffect(keyframe_effect);
158160

159161
if (element_animations->IsEmpty()) {
160162
element_animations->ClearAffectedElementTypes();
@@ -287,7 +289,7 @@ bool AnimationHost::ActivateAnimations() {
287289
TRACE_EVENT0("cc", "AnimationHost::ActivateAnimations");
288290
PlayersList ticking_players_copy = ticking_players_;
289291
for (auto& it : ticking_players_copy)
290-
it->ActivateAnimations();
292+
it->ActivateKeyframeEffects();
291293

292294
return true;
293295
}
@@ -522,14 +524,16 @@ bool AnimationHost::AnimationStartScale(ElementId element_id,
522524
: true;
523525
}
524526

525-
bool AnimationHost::HasAnyAnimation(ElementId element_id) const {
527+
bool AnimationHost::IsElementAnimating(ElementId element_id) const {
526528
auto element_animations = GetElementAnimationsForElementId(element_id);
527-
return element_animations ? element_animations->HasAnyAnimation() : false;
529+
return element_animations ? element_animations->HasAnyKeyframeModel() : false;
528530
}
529531

530-
bool AnimationHost::HasTickingAnimationForTesting(ElementId element_id) const {
532+
bool AnimationHost::HasTickingKeyframeModelForTesting(
533+
ElementId element_id) const {
531534
auto element_animations = GetElementAnimationsForElementId(element_id);
532-
return element_animations ? element_animations->HasTickingAnimation() : false;
535+
return element_animations ? element_animations->HasTickingKeyframeEffect()
536+
: false;
533537
}
534538

535539
void AnimationHost::ImplOnlyScrollAnimationCreate(
@@ -626,7 +630,7 @@ void AnimationHost::SetMutationUpdate(
626630
size_t AnimationHost::CompositedAnimationsCount() const {
627631
size_t composited_animations_count = 0;
628632
for (const auto& it : ticking_players_)
629-
composited_animations_count += it->TickingAnimationsCount();
633+
composited_animations_count += it->TickingKeyframeModelsCount();
630634
return composited_animations_count;
631635
}
632636

@@ -635,11 +639,11 @@ void AnimationHost::SetAnimationCounts(
635639
size_t main_thread_compositable_animations_count) {
636640
// The |total_animations_count| is the total number of blink::Animations.
637641
// A blink::Animation holds a CompositorAnimationPlayerHolder, which holds
638-
// a CompositorAnimationPlayer, which holds a cc::AnimationPlayer. In other
642+
// a CompositorAnimationPlayer, which holds a AnimationPlayer. In other
639643
// words, if a blink::Animation can be accelerated on compositor, it would
640-
// have a 1:1 mapping to a cc::AnimationPlayer.
644+
// have a 1:1 mapping to a AnimationPlayer.
641645
// So to check how many main thread animations there are, we subtract the
642-
// number of cc::AnimationPlayer from |total_animations_count|.
646+
// number of AnimationPlayer from |total_animations_count|.
643647
size_t ticking_players_count = ticking_players_.size();
644648
if (main_thread_animations_count_ !=
645649
total_animations_count - ticking_players_count) {

cc/animation/animation_host.h

+8-7
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "base/memory/ptr_util.h"
1414
#include "base/memory/ref_counted.h"
1515
#include "base/time/time.h"
16-
#include "cc/animation/animation.h"
1716
#include "cc/animation/animation_export.h"
17+
#include "cc/animation/keyframe_model.h"
1818
#include "cc/trees/mutator_host.h"
1919
#include "cc/trees/mutator_host_client.h"
2020
#include "ui/gfx/geometry/box_f.h"
@@ -27,10 +27,10 @@ class ScrollOffset;
2727
namespace cc {
2828

2929
class AnimationPlayer;
30-
class AnimationTicker;
3130
class AnimationTimeline;
3231
class ElementAnimations;
3332
class LayerTreeHost;
33+
class KeyframeEffect;
3434
class ScrollOffsetAnimations;
3535
class ScrollOffsetAnimationsImpl;
3636

@@ -62,9 +62,10 @@ class CC_ANIMATION_EXPORT AnimationHost : public MutatorHost,
6262
void RemoveAnimationTimeline(scoped_refptr<AnimationTimeline> timeline);
6363
AnimationTimeline* GetTimelineById(int timeline_id) const;
6464

65-
void RegisterTickerForElement(ElementId element_id, AnimationTicker* ticker);
66-
void UnregisterTickerForElement(ElementId element_id,
67-
AnimationTicker* ticker);
65+
void RegisterKeyframeEffectForElement(ElementId element_id,
66+
KeyframeEffect* keyframe_effect);
67+
void UnregisterKeyframeEffectForElement(ElementId element_id,
68+
KeyframeEffect* keyframe_effect);
6869

6970
scoped_refptr<ElementAnimations> GetElementAnimationsForElementId(
7071
ElementId element_id) const;
@@ -145,8 +146,8 @@ class CC_ANIMATION_EXPORT AnimationHost : public MutatorHost,
145146
ElementListType list_type,
146147
float* start_scale) const override;
147148

148-
bool HasAnyAnimation(ElementId element_id) const override;
149-
bool HasTickingAnimationForTesting(ElementId element_id) const override;
149+
bool IsElementAnimating(ElementId element_id) const override;
150+
bool HasTickingKeyframeModelForTesting(ElementId element_id) const override;
150151

151152
void ImplOnlyScrollAnimationCreate(
152153
ElementId element_id,

cc/animation/animation_host_perftest.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +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_ticker.h"
109
#include "cc/animation/animation_timeline.h"
11-
#include "cc/animation/single_ticker_animation_player.h"
10+
#include "cc/animation/keyframe_effect.h"
11+
#include "cc/animation/single_keyframe_effect_animation_player.h"
1212
#include "cc/base/lap_timer.h"
1313
#include "cc/test/fake_impl_task_runner_provider.h"
1414
#include "cc/test/fake_layer_tree_host.h"
@@ -70,13 +70,13 @@ class AnimationHostPerfTest : public testing::Test {
7070
root_layer_->AddChild(layer);
7171
layer->SetElementId(LayerIdToElementIdForTesting(layer->id()));
7272

73-
scoped_refptr<SingleTickerAnimationPlayer> player =
74-
SingleTickerAnimationPlayer::Create(last_player_id_);
73+
scoped_refptr<SingleKeyframeEffectAnimationPlayer> player =
74+
SingleKeyframeEffectAnimationPlayer::Create(last_player_id_);
7575
last_player_id_ = AnimationIdProvider::NextPlayerId();
7676

7777
all_players_timeline_->AttachPlayer(player);
7878
player->AttachElement(layer->element_id());
79-
EXPECT_TRUE(player->element_animations(player->animation_ticker()->id()));
79+
EXPECT_TRUE(player->element_animations(player->keyframe_effect()->id()));
8080
}
8181

8282
// Create impl players.

cc/animation/animation_id_provider.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
namespace cc {
99

10-
base::AtomicSequenceNumber g_next_animation_id;
10+
base::AtomicSequenceNumber g_next_keyframe_model_id;
1111
base::AtomicSequenceNumber g_next_group_id;
1212
base::AtomicSequenceNumber g_next_timeline_id;
1313
base::AtomicSequenceNumber g_next_player_id;
1414

15-
int AnimationIdProvider::NextAnimationId() {
15+
int AnimationIdProvider::NextKeyframeModelId() {
1616
// Animation IDs start from 1.
17-
return g_next_animation_id.GetNext() + 1;
17+
return g_next_keyframe_model_id.GetNext() + 1;
1818
}
1919

2020
int AnimationIdProvider::NextGroupId() {

cc/animation/animation_id_provider.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace cc {
1313
class CC_ANIMATION_EXPORT AnimationIdProvider {
1414
public:
1515
// These functions each return monotonically increasing values.
16-
static int NextAnimationId();
16+
static int NextKeyframeModelId();
1717
static int NextGroupId();
1818
static int NextTimelineId();
1919
static int NextPlayerId();

0 commit comments

Comments
 (0)