Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: cc/animation/animation_player.cc

Issue 2049063002: Revert of Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/animation/animation_host_perftest.cc ('k') | cc/animation/animation_player_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/animation_player.h" 5 #include "cc/animation/animation_player.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/animation/animation_delegate.h" 9 #include "cc/animation/animation_delegate.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
11 #include "cc/animation/animation_timeline.h" 11 #include "cc/animation/animation_timeline.h"
12 #include "cc/animation/element_animations.h" 12 #include "cc/animation/element_animations.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 scoped_refptr<AnimationPlayer> AnimationPlayer::Create(int id) { 16 scoped_refptr<AnimationPlayer> AnimationPlayer::Create(int id) {
17 return make_scoped_refptr(new AnimationPlayer(id)); 17 return make_scoped_refptr(new AnimationPlayer(id));
18 } 18 }
19 19
20 AnimationPlayer::AnimationPlayer(int id) 20 AnimationPlayer::AnimationPlayer(int id)
21 : animation_host_(), 21 : animation_host_(),
22 animation_timeline_(), 22 animation_timeline_(),
23 element_animations_(), 23 element_animations_(),
24 animation_delegate_(), 24 animation_delegate_(),
25 id_(id) { 25 id_(id),
26 element_id_(0) {
26 DCHECK(id_); 27 DCHECK(id_);
27 } 28 }
28 29
29 AnimationPlayer::~AnimationPlayer() { 30 AnimationPlayer::~AnimationPlayer() {
30 DCHECK(!animation_timeline_); 31 DCHECK(!animation_timeline_);
31 DCHECK(!element_animations_); 32 DCHECK(!element_animations_);
32 } 33 }
33 34
34 scoped_refptr<AnimationPlayer> AnimationPlayer::CreateImplInstance() const { 35 scoped_refptr<AnimationPlayer> AnimationPlayer::CreateImplInstance() const {
35 scoped_refptr<AnimationPlayer> player = AnimationPlayer::Create(id()); 36 scoped_refptr<AnimationPlayer> player = AnimationPlayer::Create(id());
(...skipping 14 matching lines...) Expand all
50 UnregisterPlayer(); 51 UnregisterPlayer();
51 52
52 animation_timeline_ = timeline; 53 animation_timeline_ = timeline;
53 54
54 // Register player only if layer AND host attached. 55 // Register player only if layer AND host attached.
55 if (element_id_ && animation_host_) 56 if (element_id_ && animation_host_)
56 RegisterPlayer(); 57 RegisterPlayer();
57 } 58 }
58 59
59 void AnimationPlayer::AttachElement(ElementId element_id) { 60 void AnimationPlayer::AttachElement(ElementId element_id) {
60 DCHECK(!element_id_); 61 DCHECK_EQ(element_id_, 0);
61 DCHECK(element_id); 62 DCHECK(element_id);
62 63
63 element_id_ = element_id; 64 element_id_ = element_id;
64 65
65 // Register player only if layer AND host attached. 66 // Register player only if layer AND host attached.
66 if (animation_host_) 67 if (animation_host_)
67 RegisterPlayer(); 68 RegisterPlayer();
68 } 69 }
69 70
70 void AnimationPlayer::DetachElement() { 71 void AnimationPlayer::DetachElement() {
71 DCHECK(element_id_); 72 DCHECK(element_id_);
72 73
73 if (animation_host_) 74 if (animation_host_)
74 UnregisterPlayer(); 75 UnregisterPlayer();
75 76
76 element_id_ = ElementId(); 77 element_id_ = 0;
77 } 78 }
78 79
79 void AnimationPlayer::RegisterPlayer() { 80 void AnimationPlayer::RegisterPlayer() {
80 DCHECK(element_id_); 81 DCHECK(element_id_);
81 DCHECK(animation_host_); 82 DCHECK(animation_host_);
82 DCHECK(!element_animations_); 83 DCHECK(!element_animations_);
83 84
84 // Create ElementAnimations or re-use existing. 85 // Create ElementAnimations or re-use existing.
85 animation_host_->RegisterPlayerForElement(element_id_, this); 86 animation_host_->RegisterPlayerForElement(element_id_, this);
86 // Get local reference to shared ElementAnimations. 87 // Get local reference to shared ElementAnimations.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 221 }
221 } 222 }
222 223
223 void AnimationPlayer::SetNeedsCommit() { 224 void AnimationPlayer::SetNeedsCommit() {
224 DCHECK(animation_host_); 225 DCHECK(animation_host_);
225 animation_host_->SetNeedsCommit(); 226 animation_host_->SetNeedsCommit();
226 animation_host_->SetNeedsRebuildPropertyTrees(); 227 animation_host_->SetNeedsRebuildPropertyTrees();
227 } 228 }
228 229
229 } // namespace cc 230 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_host_perftest.cc ('k') | cc/animation/animation_player_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698