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

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

Issue 2363733004: UI Compositor Animation: Remove cc::ElementAnimations state storage. (Closed)
Patch Set: Reparent. Created 4 years, 2 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.h ('k') | ui/compositor/layer.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_host.h" 5 #include "cc/animation/animation_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 void AnimationHost::RegisterPlayerForElement(ElementId element_id, 121 void AnimationHost::RegisterPlayerForElement(ElementId element_id,
122 AnimationPlayer* player) { 122 AnimationPlayer* player) {
123 DCHECK(element_id); 123 DCHECK(element_id);
124 DCHECK(player); 124 DCHECK(player);
125 125
126 scoped_refptr<ElementAnimations> element_animations = 126 scoped_refptr<ElementAnimations> element_animations =
127 GetElementAnimationsForElementId(element_id); 127 GetElementAnimationsForElementId(element_id);
128 if (!element_animations) { 128 if (!element_animations) {
129 element_animations = ElementAnimations::Create(); 129 element_animations = ElementAnimations::Create();
130 element_animations->SetElementId(element_id); 130 element_animations->SetElementId(element_id);
131 RegisterElementAnimations(element_animations.get()); 131 element_to_animations_map_[element_animations->element_id()] =
132 element_animations;
132 } 133 }
133 134
134 if (element_animations->animation_host() != this) { 135 if (element_animations->animation_host() != this) {
135 element_animations->SetAnimationHost(this); 136 element_animations->SetAnimationHost(this);
136 element_animations->InitAffectedElementTypes(); 137 element_animations->InitAffectedElementTypes();
137 } 138 }
138 139
139 element_animations->AddPlayer(player); 140 element_animations->AddPlayer(player);
140 } 141 }
141 142
142 void AnimationHost::UnregisterPlayerForElement(ElementId element_id, 143 void AnimationHost::UnregisterPlayerForElement(ElementId element_id,
143 AnimationPlayer* player) { 144 AnimationPlayer* player) {
144 DCHECK(element_id); 145 DCHECK(element_id);
145 DCHECK(player); 146 DCHECK(player);
146 147
147 scoped_refptr<ElementAnimations> element_animations = 148 scoped_refptr<ElementAnimations> element_animations =
148 GetElementAnimationsForElementId(element_id); 149 GetElementAnimationsForElementId(element_id);
149 DCHECK(element_animations); 150 DCHECK(element_animations);
150 element_animations->RemovePlayer(player); 151 element_animations->RemovePlayer(player);
151 152
152 if (element_animations->IsEmpty()) { 153 if (element_animations->IsEmpty()) {
153 element_animations->ClearAffectedElementTypes(); 154 element_animations->ClearAffectedElementTypes();
154 UnregisterElementAnimations(element_animations.get()); 155 element_to_animations_map_.erase(element_animations->element_id());
156 DidDeactivateElementAnimations(element_animations.get());
155 element_animations->SetAnimationHost(nullptr); 157 element_animations->SetAnimationHost(nullptr);
156 } 158 }
157 } 159 }
158 160
159 void AnimationHost::SetMutatorHostClient(MutatorHostClient* client) { 161 void AnimationHost::SetMutatorHostClient(MutatorHostClient* client) {
160 if (mutator_host_client_ == client) 162 if (mutator_host_client_ == client)
161 return; 163 return;
162 164
163 mutator_host_client_ = client; 165 mutator_host_client_ = client;
164 166
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 active_element_to_animations_map_[element_animations->element_id()] = 557 active_element_to_animations_map_[element_animations->element_id()] =
556 element_animations; 558 element_animations;
557 } 559 }
558 560
559 void AnimationHost::DidDeactivateElementAnimations( 561 void AnimationHost::DidDeactivateElementAnimations(
560 ElementAnimations* element_animations) { 562 ElementAnimations* element_animations) {
561 DCHECK(element_animations->element_id()); 563 DCHECK(element_animations->element_id());
562 active_element_to_animations_map_.erase(element_animations->element_id()); 564 active_element_to_animations_map_.erase(element_animations->element_id());
563 } 565 }
564 566
565 void AnimationHost::RegisterElementAnimations(
566 ElementAnimations* element_animations) {
567 DCHECK(element_animations->element_id());
568 element_to_animations_map_[element_animations->element_id()] =
569 element_animations;
570 }
571
572 void AnimationHost::UnregisterElementAnimations(
573 ElementAnimations* element_animations) {
574 DCHECK(element_animations->element_id());
575 element_to_animations_map_.erase(element_animations->element_id());
576 DidDeactivateElementAnimations(element_animations);
577 }
578
579 const AnimationHost::ElementToAnimationsMap& 567 const AnimationHost::ElementToAnimationsMap&
580 AnimationHost::active_element_animations_for_testing() const { 568 AnimationHost::active_element_animations_for_testing() const {
581 return active_element_to_animations_map_; 569 return active_element_to_animations_map_;
582 } 570 }
583 571
584 const AnimationHost::ElementToAnimationsMap& 572 const AnimationHost::ElementToAnimationsMap&
585 AnimationHost::all_element_animations_for_testing() const { 573 AnimationHost::all_element_animations_for_testing() const {
586 return element_to_animations_map_; 574 return element_to_animations_map_;
587 } 575 }
588 576
589 } // namespace cc 577 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_host.h ('k') | ui/compositor/layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698