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

Side by Side Diff: cc/trees/layer_tree_host.cc

Issue 13465014: LayerTreeHost::SetAnimationEvents should use AnimationRegistrar (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/tree_synchronizer_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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 client_->ScheduleComposite(); 547 client_->ScheduleComposite();
548 } 548 }
549 549
550 bool LayerTreeHost::CommitRequested() const { 550 bool LayerTreeHost::CommitRequested() const {
551 return proxy_->CommitRequested(); 551 return proxy_->CommitRequested();
552 } 552 }
553 553
554 void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events, 554 void LayerTreeHost::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events,
555 base::Time wall_clock_time) { 555 base::Time wall_clock_time) {
556 DCHECK(proxy_->IsMainThread()); 556 DCHECK(proxy_->IsMainThread());
557 SetAnimationEventsRecursive(*events, 557 AnimationRegistrar::AnimationControllerMap copy =
558 root_layer_.get(), 558 animation_registrar_->active_animation_controllers();
559 wall_clock_time); 559 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
560 iter != copy.end();
561 ++iter) {
562 for (size_t event_index = 0; event_index < events->size(); ++event_index) {
563 if ((*iter).second->id() == (*events)[event_index].layer_id) {
564 switch ((*events)[event_index].type) {
565 case AnimationEvent::Started:
566 (*iter).second->NotifyAnimationStarted((*events)[event_index],
567 wall_clock_time.ToDoubleT());
568 break;
569
570 case AnimationEvent::Finished:
571 (*iter).second->NotifyAnimationFinished(
572 (*events)[event_index],
573 wall_clock_time.ToDoubleT());
574 break;
575
576 case AnimationEvent::PropertyUpdate:
577 (*iter).second->NotifyAnimationPropertyUpdate(
578 (*events)[event_index]);
579 break;
580
581 default:
582 NOTREACHED();
583 }
584 }
585 }
586 }
560 } 587 }
561 588
562 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { 589 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) {
563 if (root_layer_ == root_layer) 590 if (root_layer_ == root_layer)
564 return; 591 return;
565 592
566 if (root_layer_) 593 if (root_layer_)
567 root_layer_->SetLayerTreeHost(NULL); 594 root_layer_->SetLayerTreeHost(NULL);
568 root_layer_ = root_layer; 595 root_layer_ = root_layer;
569 if (root_layer_) 596 if (root_layer_)
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 animation_registrar_->active_animation_controllers(); 1065 animation_registrar_->active_animation_controllers();
1039 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin(); 1066 for (AnimationRegistrar::AnimationControllerMap::iterator iter = copy.begin();
1040 iter != copy.end(); 1067 iter != copy.end();
1041 ++iter) { 1068 ++iter) {
1042 (*iter).second->Animate(monotonic_time); 1069 (*iter).second->Animate(monotonic_time);
1043 bool start_ready_animations = true; 1070 bool start_ready_animations = true;
1044 (*iter).second->UpdateState(start_ready_animations, NULL); 1071 (*iter).second->UpdateState(start_ready_animations, NULL);
1045 } 1072 }
1046 } 1073 }
1047 1074
1048 void LayerTreeHost::SetAnimationEventsRecursive(
1049 const AnimationEventsVector& events,
1050 Layer* layer,
1051 base::Time wall_clock_time) {
1052 if (!layer)
1053 return;
1054
1055 for (size_t event_index = 0; event_index < events.size(); ++event_index) {
1056 if (layer->id() == events[event_index].layer_id) {
1057 switch (events[event_index].type) {
1058 case AnimationEvent::Started:
1059 layer->NotifyAnimationStarted(events[event_index],
1060 wall_clock_time.ToDoubleT());
1061 break;
1062
1063 case AnimationEvent::Finished:
1064 layer->NotifyAnimationFinished(wall_clock_time.ToDoubleT());
1065 break;
1066
1067 case AnimationEvent::PropertyUpdate:
1068 layer->NotifyAnimationPropertyUpdate(events[event_index]);
1069 break;
1070
1071 default:
1072 NOTREACHED();
1073 }
1074 }
1075 }
1076
1077 for (size_t child_index = 0;
1078 child_index < layer->children().size();
1079 ++child_index)
1080 SetAnimationEventsRecursive(events,
1081 layer->children()[child_index].get(),
1082 wall_clock_time);
1083 }
1084
1085 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { 1075 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() {
1086 return proxy_->CapturePicture(); 1076 return proxy_->CapturePicture();
1087 } 1077 }
1088 1078
1089 } // namespace cc 1079 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host.h ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698