OLD | NEW |
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 Loading... |
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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 AnimationRegistrar::AnimationControllerMap copy = | 1064 AnimationRegistrar::AnimationControllerMap copy = |
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 (*iter).second->UpdateState(NULL); | 1070 (*iter).second->UpdateState(NULL); |
1044 } | 1071 } |
1045 } | 1072 } |
1046 | 1073 |
1047 void LayerTreeHost::SetAnimationEventsRecursive( | |
1048 const AnimationEventsVector& events, | |
1049 Layer* layer, | |
1050 base::Time wall_clock_time) { | |
1051 if (!layer) | |
1052 return; | |
1053 | |
1054 for (size_t event_index = 0; event_index < events.size(); ++event_index) { | |
1055 if (layer->id() == events[event_index].layer_id) { | |
1056 switch (events[event_index].type) { | |
1057 case AnimationEvent::Started: | |
1058 layer->NotifyAnimationStarted(events[event_index], | |
1059 wall_clock_time.ToDoubleT()); | |
1060 break; | |
1061 | |
1062 case AnimationEvent::Finished: | |
1063 layer->NotifyAnimationFinished(wall_clock_time.ToDoubleT()); | |
1064 break; | |
1065 | |
1066 case AnimationEvent::PropertyUpdate: | |
1067 layer->NotifyAnimationPropertyUpdate(events[event_index]); | |
1068 break; | |
1069 | |
1070 default: | |
1071 NOTREACHED(); | |
1072 } | |
1073 } | |
1074 } | |
1075 | |
1076 for (size_t child_index = 0; | |
1077 child_index < layer->children().size(); | |
1078 ++child_index) | |
1079 SetAnimationEventsRecursive(events, | |
1080 layer->children()[child_index].get(), | |
1081 wall_clock_time); | |
1082 } | |
1083 | |
1084 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { | 1074 skia::RefPtr<SkPicture> LayerTreeHost::CapturePicture() { |
1085 return proxy_->CapturePicture(); | 1075 return proxy_->CapturePicture(); |
1086 } | 1076 } |
1087 | 1077 |
1088 } // namespace cc | 1078 } // namespace cc |
OLD | NEW |