| OLD | NEW |
| 1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| 11 | 11 |
| 12 #include "base/atomic_sequence_num.h" | 12 #include "base/atomic_sequence_num.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 18 #include "cc/animation/animation.h" | |
| 19 #include "cc/animation/animation_registrar.h" | |
| 20 #include "cc/animation/keyframed_animation_curve.h" | |
| 21 #include "cc/animation/layer_animation_controller.h" | |
| 22 #include "cc/animation/mutable_properties.h" | 18 #include "cc/animation/mutable_properties.h" |
| 23 #include "cc/base/simple_enclosed_region.h" | 19 #include "cc/base/simple_enclosed_region.h" |
| 24 #include "cc/debug/frame_viewer_instrumentation.h" | 20 #include "cc/debug/frame_viewer_instrumentation.h" |
| 25 #include "cc/input/main_thread_scrolling_reason.h" | 21 #include "cc/input/main_thread_scrolling_reason.h" |
| 26 #include "cc/layers/layer_client.h" | 22 #include "cc/layers/layer_client.h" |
| 27 #include "cc/layers/layer_impl.h" | 23 #include "cc/layers/layer_impl.h" |
| 28 #include "cc/layers/layer_proto_converter.h" | 24 #include "cc/layers/layer_proto_converter.h" |
| 29 #include "cc/layers/layer_settings.h" | 25 #include "cc/layers/layer_settings.h" |
| 30 #include "cc/layers/scrollbar_layer_interface.h" | 26 #include "cc/layers/scrollbar_layer_interface.h" |
| 31 #include "cc/output/copy_output_request.h" | 27 #include "cc/output/copy_output_request.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 91 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
| 96 scroll_parent_(nullptr), | 92 scroll_parent_(nullptr), |
| 97 layer_or_descendant_is_drawn_tracker_(0), | 93 layer_or_descendant_is_drawn_tracker_(0), |
| 98 sorted_for_recursion_tracker_(0), | 94 sorted_for_recursion_tracker_(0), |
| 99 visited_tracker_(0), | 95 visited_tracker_(0), |
| 100 clip_parent_(nullptr), | 96 clip_parent_(nullptr), |
| 101 replica_layer_(nullptr), | 97 replica_layer_(nullptr), |
| 102 client_(nullptr), | 98 client_(nullptr), |
| 103 num_unclipped_descendants_(0), | 99 num_unclipped_descendants_(0), |
| 104 frame_timing_requests_dirty_(false) { | 100 frame_timing_requests_dirty_(false) { |
| 105 if (!settings.use_compositor_animation_timelines) { | |
| 106 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | |
| 107 layer_animation_controller_->AddValueObserver(this); | |
| 108 layer_animation_controller_->set_value_provider(this); | |
| 109 } | |
| 110 } | 101 } |
| 111 | 102 |
| 112 Layer::~Layer() { | 103 Layer::~Layer() { |
| 113 // Our parent should be holding a reference to us so there should be no | 104 // Our parent should be holding a reference to us so there should be no |
| 114 // way for us to be destroyed while we still have a parent. | 105 // way for us to be destroyed while we still have a parent. |
| 115 DCHECK(!parent()); | 106 DCHECK(!parent()); |
| 116 // Similarly we shouldn't have a layer tree host since it also keeps a | 107 // Similarly we shouldn't have a layer tree host since it also keeps a |
| 117 // reference to us. | 108 // reference to us. |
| 118 DCHECK(!layer_tree_host()); | 109 DCHECK(!layer_tree_host()); |
| 119 | 110 |
| 120 if (layer_animation_controller_) { | |
| 121 layer_animation_controller_->RemoveValueObserver(this); | |
| 122 layer_animation_controller_->remove_value_provider(this); | |
| 123 } | |
| 124 | |
| 125 RemoveFromScrollTree(); | 111 RemoveFromScrollTree(); |
| 126 RemoveFromClipTree(); | 112 RemoveFromClipTree(); |
| 127 | 113 |
| 128 // Remove the parent reference from all children and dependents. | 114 // Remove the parent reference from all children and dependents. |
| 129 RemoveAllChildren(); | 115 RemoveAllChildren(); |
| 130 if (mask_layer_.get()) { | 116 if (mask_layer_.get()) { |
| 131 DCHECK_EQ(this, mask_layer_->parent()); | 117 DCHECK_EQ(this, mask_layer_->parent()); |
| 132 mask_layer_->RemoveFromParent(); | 118 mask_layer_->RemoveFromParent(); |
| 133 } | 119 } |
| 134 if (replica_layer_.get()) { | 120 if (replica_layer_.get()) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 159 SetNeedsPushProperties(); | 145 SetNeedsPushProperties(); |
| 160 | 146 |
| 161 for (size_t i = 0; i < children_.size(); ++i) | 147 for (size_t i = 0; i < children_.size(); ++i) |
| 162 children_[i]->SetLayerTreeHost(host); | 148 children_[i]->SetLayerTreeHost(host); |
| 163 | 149 |
| 164 if (mask_layer_.get()) | 150 if (mask_layer_.get()) |
| 165 mask_layer_->SetLayerTreeHost(host); | 151 mask_layer_->SetLayerTreeHost(host); |
| 166 if (replica_layer_.get()) | 152 if (replica_layer_.get()) |
| 167 replica_layer_->SetLayerTreeHost(host); | 153 replica_layer_->SetLayerTreeHost(host); |
| 168 | 154 |
| 169 if (host) | 155 const bool has_any_animation = |
| 170 RegisterForAnimations(host->animation_registrar()); | 156 layer_tree_host_ ? layer_tree_host_->HasAnyAnimation(this) : false; |
| 171 | |
| 172 bool has_any_animation = false; | |
| 173 if (layer_animation_controller_) | |
| 174 has_any_animation = layer_animation_controller_->has_any_animation(); | |
| 175 else if (layer_tree_host_) | |
| 176 has_any_animation = layer_tree_host_->HasAnyAnimation(this); | |
| 177 | 157 |
| 178 if (host && has_any_animation) | 158 if (host && has_any_animation) |
| 179 host->SetNeedsCommit(); | 159 host->SetNeedsCommit(); |
| 180 } | 160 } |
| 181 | 161 |
| 182 void Layer::SetNeedsUpdate() { | 162 void Layer::SetNeedsUpdate() { |
| 183 if (layer_tree_host_ && !ignore_set_needs_commit_) | 163 if (layer_tree_host_ && !ignore_set_needs_commit_) |
| 184 layer_tree_host_->SetNeedsUpdateLayers(); | 164 layer_tree_host_->SetNeedsUpdateLayers(); |
| 185 } | 165 } |
| 186 | 166 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 DCHECK(IsPropertyChangeAllowed()); | 478 DCHECK(IsPropertyChangeAllowed()); |
| 499 if (filters_ == filters) | 479 if (filters_ == filters) |
| 500 return; | 480 return; |
| 501 filters_ = filters; | 481 filters_ = filters; |
| 502 SetSubtreePropertyChanged(); | 482 SetSubtreePropertyChanged(); |
| 503 SetNeedsCommit(); | 483 SetNeedsCommit(); |
| 504 } | 484 } |
| 505 | 485 |
| 506 bool Layer::FilterIsAnimating() const { | 486 bool Layer::FilterIsAnimating() const { |
| 507 DCHECK(layer_tree_host_); | 487 DCHECK(layer_tree_host_); |
| 508 return layer_animation_controller_ | 488 return layer_tree_host_->IsAnimatingFilterProperty(this); |
| 509 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | |
| 510 TargetProperty::FILTER, | |
| 511 LayerAnimationController::ObserverType::ACTIVE) | |
| 512 : layer_tree_host_->IsAnimatingFilterProperty(this); | |
| 513 } | 489 } |
| 514 | 490 |
| 515 bool Layer::HasPotentiallyRunningFilterAnimation() const { | 491 bool Layer::HasPotentiallyRunningFilterAnimation() const { |
| 516 if (layer_animation_controller_) { | |
| 517 return layer_animation_controller_->IsPotentiallyAnimatingProperty( | |
| 518 TargetProperty::FILTER, LayerAnimationController::ObserverType::ACTIVE); | |
| 519 } | |
| 520 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); | 492 return layer_tree_host_->HasPotentiallyRunningFilterAnimation(this); |
| 521 } | 493 } |
| 522 | 494 |
| 523 void Layer::SetBackgroundFilters(const FilterOperations& filters) { | 495 void Layer::SetBackgroundFilters(const FilterOperations& filters) { |
| 524 DCHECK(IsPropertyChangeAllowed()); | 496 DCHECK(IsPropertyChangeAllowed()); |
| 525 if (background_filters_ == filters) | 497 if (background_filters_ == filters) |
| 526 return; | 498 return; |
| 527 background_filters_ = filters; | 499 background_filters_ = filters; |
| 528 SetNeedsCommit(); | 500 SetNeedsCommit(); |
| 529 } | 501 } |
| 530 | 502 |
| 531 void Layer::SetOpacity(float opacity) { | 503 void Layer::SetOpacity(float opacity) { |
| 532 DCHECK(IsPropertyChangeAllowed()); | 504 DCHECK(IsPropertyChangeAllowed()); |
| 533 if (opacity_ == opacity) | 505 if (opacity_ == opacity) |
| 534 return; | 506 return; |
| 535 opacity_ = opacity; | 507 opacity_ = opacity; |
| 536 SetSubtreePropertyChanged(); | 508 SetSubtreePropertyChanged(); |
| 537 SetNeedsCommit(); | 509 SetNeedsCommit(); |
| 538 } | 510 } |
| 539 | 511 |
| 540 float Layer::EffectiveOpacity() const { | 512 float Layer::EffectiveOpacity() const { |
| 541 return hide_layer_and_subtree_ ? 0.f : opacity_; | 513 return hide_layer_and_subtree_ ? 0.f : opacity_; |
| 542 } | 514 } |
| 543 | 515 |
| 544 bool Layer::OpacityIsAnimating() const { | 516 bool Layer::OpacityIsAnimating() const { |
| 545 DCHECK(layer_tree_host_); | 517 DCHECK(layer_tree_host_); |
| 546 return layer_animation_controller_ | 518 return layer_tree_host_->IsAnimatingOpacityProperty(this); |
| 547 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | |
| 548 TargetProperty::OPACITY, | |
| 549 LayerAnimationController::ObserverType::ACTIVE) | |
| 550 : layer_tree_host_->IsAnimatingOpacityProperty(this); | |
| 551 } | 519 } |
| 552 | 520 |
| 553 bool Layer::HasPotentiallyRunningOpacityAnimation() const { | 521 bool Layer::HasPotentiallyRunningOpacityAnimation() const { |
| 554 if (layer_animation_controller_) { | |
| 555 return layer_animation_controller_->IsPotentiallyAnimatingProperty( | |
| 556 TargetProperty::OPACITY, | |
| 557 LayerAnimationController::ObserverType::ACTIVE); | |
| 558 } | |
| 559 return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this); | 522 return layer_tree_host_->HasPotentiallyRunningOpacityAnimation(this); |
| 560 } | 523 } |
| 561 | 524 |
| 562 bool Layer::OpacityCanAnimateOnImplThread() const { | 525 bool Layer::OpacityCanAnimateOnImplThread() const { |
| 563 return false; | 526 return false; |
| 564 } | 527 } |
| 565 | 528 |
| 566 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { | 529 void Layer::SetBlendMode(SkXfermode::Mode blend_mode) { |
| 567 DCHECK(IsPropertyChangeAllowed()); | 530 DCHECK(IsPropertyChangeAllowed()); |
| 568 if (blend_mode_ == blend_mode) | 531 if (blend_mode_ == blend_mode) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 SetNeedsCommitNoRebuild(); | 705 SetNeedsCommitNoRebuild(); |
| 743 return; | 706 return; |
| 744 } | 707 } |
| 745 } | 708 } |
| 746 | 709 |
| 747 SetNeedsCommit(); | 710 SetNeedsCommit(); |
| 748 } | 711 } |
| 749 | 712 |
| 750 bool Layer::AnimationsPreserveAxisAlignment() const { | 713 bool Layer::AnimationsPreserveAxisAlignment() const { |
| 751 DCHECK(layer_tree_host_); | 714 DCHECK(layer_tree_host_); |
| 752 return layer_animation_controller_ | 715 return layer_tree_host_->AnimationsPreserveAxisAlignment(this); |
| 753 ? layer_animation_controller_->AnimationsPreserveAxisAlignment() | |
| 754 : layer_tree_host_->AnimationsPreserveAxisAlignment(this); | |
| 755 } | 716 } |
| 756 | 717 |
| 757 bool Layer::TransformIsAnimating() const { | 718 bool Layer::TransformIsAnimating() const { |
| 758 DCHECK(layer_tree_host_); | 719 DCHECK(layer_tree_host_); |
| 759 return layer_animation_controller_ | 720 return layer_tree_host_->IsAnimatingTransformProperty(this); |
| 760 ? layer_animation_controller_->IsCurrentlyAnimatingProperty( | |
| 761 TargetProperty::TRANSFORM, | |
| 762 LayerAnimationController::ObserverType::ACTIVE) | |
| 763 : layer_tree_host_->IsAnimatingTransformProperty(this); | |
| 764 } | 721 } |
| 765 | 722 |
| 766 bool Layer::HasPotentiallyRunningTransformAnimation() const { | 723 bool Layer::HasPotentiallyRunningTransformAnimation() const { |
| 767 if (layer_animation_controller_) { | |
| 768 return layer_animation_controller_->IsPotentiallyAnimatingProperty( | |
| 769 TargetProperty::TRANSFORM, | |
| 770 LayerAnimationController::ObserverType::ACTIVE); | |
| 771 } | |
| 772 return layer_tree_host_->HasPotentiallyRunningTransformAnimation(this); | 724 return layer_tree_host_->HasPotentiallyRunningTransformAnimation(this); |
| 773 } | 725 } |
| 774 | 726 |
| 775 bool Layer::HasOnlyTranslationTransforms() const { | 727 bool Layer::HasOnlyTranslationTransforms() const { |
| 776 if (layer_animation_controller_) { | |
| 777 return layer_animation_controller_->HasOnlyTranslationTransforms( | |
| 778 LayerAnimationController::ObserverType::ACTIVE); | |
| 779 } | |
| 780 return layer_tree_host_->HasOnlyTranslationTransforms(this); | 728 return layer_tree_host_->HasOnlyTranslationTransforms(this); |
| 781 } | 729 } |
| 782 | 730 |
| 783 bool Layer::MaximumTargetScale(float* max_scale) const { | 731 bool Layer::MaximumTargetScale(float* max_scale) const { |
| 784 if (layer_animation_controller_) { | |
| 785 return layer_animation_controller_->MaximumTargetScale( | |
| 786 LayerAnimationController::ObserverType::ACTIVE, max_scale); | |
| 787 } | |
| 788 return layer_tree_host_->MaximumTargetScale(this, max_scale); | 732 return layer_tree_host_->MaximumTargetScale(this, max_scale); |
| 789 } | 733 } |
| 790 | 734 |
| 791 bool Layer::AnimationStartScale(float* start_scale) const { | 735 bool Layer::AnimationStartScale(float* start_scale) const { |
| 792 if (layer_animation_controller_) { | |
| 793 return layer_animation_controller_->AnimationStartScale( | |
| 794 LayerAnimationController::ObserverType::ACTIVE, start_scale); | |
| 795 } | |
| 796 return layer_tree_host_->AnimationStartScale(this, start_scale); | 736 return layer_tree_host_->AnimationStartScale(this, start_scale); |
| 797 } | 737 } |
| 798 | 738 |
| 799 bool Layer::HasAnyAnimationTargetingProperty( | 739 bool Layer::HasAnyAnimationTargetingProperty( |
| 800 TargetProperty::Type property) const { | 740 TargetProperty::Type property) const { |
| 801 if (layer_animation_controller_) | |
| 802 return !!layer_animation_controller_->GetAnimation(property); | |
| 803 | |
| 804 return layer_tree_host_->HasAnyAnimationTargetingProperty(this, property); | 741 return layer_tree_host_->HasAnyAnimationTargetingProperty(this, property); |
| 805 } | 742 } |
| 806 | 743 |
| 807 bool Layer::ScrollOffsetAnimationWasInterrupted() const { | 744 bool Layer::ScrollOffsetAnimationWasInterrupted() const { |
| 808 DCHECK(layer_tree_host_); | 745 DCHECK(layer_tree_host_); |
| 809 return layer_animation_controller_ | 746 return layer_tree_host_->ScrollOffsetAnimationWasInterrupted(this); |
| 810 ? layer_animation_controller_ | |
| 811 ->scroll_offset_animation_was_interrupted() | |
| 812 : layer_tree_host_->ScrollOffsetAnimationWasInterrupted(this); | |
| 813 } | 747 } |
| 814 | 748 |
| 815 void Layer::SetScrollParent(Layer* parent) { | 749 void Layer::SetScrollParent(Layer* parent) { |
| 816 DCHECK(IsPropertyChangeAllowed()); | 750 DCHECK(IsPropertyChangeAllowed()); |
| 817 if (scroll_parent_ == parent) | 751 if (scroll_parent_ == parent) |
| 818 return; | 752 return; |
| 819 | 753 |
| 820 if (scroll_parent_) | 754 if (scroll_parent_) |
| 821 scroll_parent_->RemoveScrollChild(this); | 755 scroll_parent_->RemoveScrollChild(this); |
| 822 | 756 |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 layer->PassCopyRequests(&main_thread_copy_requests); | 1310 layer->PassCopyRequests(&main_thread_copy_requests); |
| 1377 } | 1311 } |
| 1378 | 1312 |
| 1379 // If the main thread commits multiple times before the impl thread actually | 1313 // If the main thread commits multiple times before the impl thread actually |
| 1380 // draws, then damage tracking will become incorrect if we simply clobber the | 1314 // draws, then damage tracking will become incorrect if we simply clobber the |
| 1381 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 1315 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
| 1382 // union) any update changes that have occurred on the main thread. | 1316 // union) any update changes that have occurred on the main thread. |
| 1383 update_rect_.Union(layer->update_rect()); | 1317 update_rect_.Union(layer->update_rect()); |
| 1384 layer->SetUpdateRect(update_rect_); | 1318 layer->SetUpdateRect(update_rect_); |
| 1385 | 1319 |
| 1386 if (layer->layer_animation_controller() && layer_animation_controller_) | |
| 1387 layer_animation_controller_->PushAnimationUpdatesTo( | |
| 1388 layer->layer_animation_controller()); | |
| 1389 | |
| 1390 if (frame_timing_requests_dirty_) { | 1320 if (frame_timing_requests_dirty_) { |
| 1391 layer->SetFrameTimingRequests(frame_timing_requests_); | 1321 layer->SetFrameTimingRequests(frame_timing_requests_); |
| 1392 frame_timing_requests_dirty_ = false; | 1322 frame_timing_requests_dirty_ = false; |
| 1393 } | 1323 } |
| 1394 | 1324 |
| 1395 // Reset any state that should be cleared for the next update. | 1325 // Reset any state that should be cleared for the next update. |
| 1396 subtree_property_changed_ = false; | 1326 subtree_property_changed_ = false; |
| 1397 update_rect_ = gfx::Rect(); | 1327 update_rect_ = gfx::Rect(); |
| 1398 | 1328 |
| 1399 needs_push_properties_ = false; | 1329 needs_push_properties_ = false; |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1838 } | 1768 } |
| 1839 } | 1769 } |
| 1840 } | 1770 } |
| 1841 | 1771 |
| 1842 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { | 1772 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { |
| 1843 // Do nothing. Scroll deltas will be sent from the compositor thread back | 1773 // Do nothing. Scroll deltas will be sent from the compositor thread back |
| 1844 // to the main thread in the same manner as during non-animated | 1774 // to the main thread in the same manner as during non-animated |
| 1845 // compositor-driven scrolling. | 1775 // compositor-driven scrolling. |
| 1846 } | 1776 } |
| 1847 | 1777 |
| 1848 void Layer::OnAnimationWaitingForDeletion() { | |
| 1849 // Animations are only deleted during PushProperties. | |
| 1850 SetNeedsPushProperties(); | |
| 1851 } | |
| 1852 | |
| 1853 void Layer::OnTransformIsPotentiallyAnimatingChanged(bool is_animating) { | 1778 void Layer::OnTransformIsPotentiallyAnimatingChanged(bool is_animating) { |
| 1854 if (!layer_tree_host_) | 1779 if (!layer_tree_host_) |
| 1855 return; | 1780 return; |
| 1856 TransformTree& transform_tree = | 1781 TransformTree& transform_tree = |
| 1857 layer_tree_host_->property_trees()->transform_tree; | 1782 layer_tree_host_->property_trees()->transform_tree; |
| 1858 TransformNode* node = transform_tree.Node(transform_tree_index()); | 1783 TransformNode* node = transform_tree.Node(transform_tree_index()); |
| 1859 if (!node) | 1784 if (!node) |
| 1860 return; | 1785 return; |
| 1861 | 1786 |
| 1862 if (node->owner_id == id()) { | 1787 if (node->owner_id == id()) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1881 node->data.has_only_translation_animations = true; | 1806 node->data.has_only_translation_animations = true; |
| 1882 } | 1807 } |
| 1883 transform_tree.set_needs_update(true); | 1808 transform_tree.set_needs_update(true); |
| 1884 } | 1809 } |
| 1885 } | 1810 } |
| 1886 | 1811 |
| 1887 bool Layer::IsActive() const { | 1812 bool Layer::IsActive() const { |
| 1888 return true; | 1813 return true; |
| 1889 } | 1814 } |
| 1890 | 1815 |
| 1891 bool Layer::AddAnimation(scoped_ptr <Animation> animation) { | |
| 1892 DCHECK(layer_animation_controller_); | |
| 1893 if (!layer_animation_controller_->animation_registrar()) | |
| 1894 return false; | |
| 1895 | |
| 1896 if (animation->target_property() == TargetProperty::SCROLL_OFFSET && | |
| 1897 !layer_animation_controller_->animation_registrar() | |
| 1898 ->supports_scroll_animations()) | |
| 1899 return false; | |
| 1900 | |
| 1901 UMA_HISTOGRAM_BOOLEAN("Renderer.AnimationAddedToOrphanLayer", | |
| 1902 !layer_tree_host_); | |
| 1903 layer_animation_controller_->AddAnimation(std::move(animation)); | |
| 1904 SetNeedsCommit(); | |
| 1905 return true; | |
| 1906 } | |
| 1907 | |
| 1908 void Layer::PauseAnimation(int animation_id, double time_offset) { | |
| 1909 DCHECK(layer_animation_controller_); | |
| 1910 layer_animation_controller_->PauseAnimation( | |
| 1911 animation_id, base::TimeDelta::FromSecondsD(time_offset)); | |
| 1912 SetNeedsCommit(); | |
| 1913 } | |
| 1914 | |
| 1915 void Layer::RemoveAnimation(int animation_id) { | |
| 1916 DCHECK(layer_animation_controller_); | |
| 1917 layer_animation_controller_->RemoveAnimation(animation_id); | |
| 1918 SetNeedsCommit(); | |
| 1919 } | |
| 1920 | |
| 1921 void Layer::AbortAnimation(int animation_id) { | |
| 1922 DCHECK(layer_animation_controller_); | |
| 1923 layer_animation_controller_->AbortAnimation(animation_id); | |
| 1924 SetNeedsCommit(); | |
| 1925 } | |
| 1926 | |
| 1927 void Layer::SetLayerAnimationControllerForTest( | |
| 1928 scoped_refptr<LayerAnimationController> controller) { | |
| 1929 DCHECK(layer_animation_controller_); | |
| 1930 layer_animation_controller_->RemoveValueObserver(this); | |
| 1931 layer_animation_controller_ = controller; | |
| 1932 layer_animation_controller_->AddValueObserver(this); | |
| 1933 SetNeedsCommit(); | |
| 1934 } | |
| 1935 | |
| 1936 bool Layer::HasActiveAnimation() const { | 1816 bool Layer::HasActiveAnimation() const { |
| 1937 DCHECK(layer_tree_host_); | 1817 DCHECK(layer_tree_host_); |
| 1938 return layer_animation_controller_ | 1818 return layer_tree_host_->HasActiveAnimation(this); |
| 1939 ? layer_animation_controller_->HasActiveAnimation() | |
| 1940 : layer_tree_host_->HasActiveAnimation(this); | |
| 1941 } | |
| 1942 | |
| 1943 void Layer::RegisterForAnimations(AnimationRegistrar* registrar) { | |
| 1944 if (layer_animation_controller_) | |
| 1945 layer_animation_controller_->SetAnimationRegistrar(registrar); | |
| 1946 } | |
| 1947 | |
| 1948 void Layer::AddLayerAnimationEventObserver( | |
| 1949 LayerAnimationEventObserver* animation_observer) { | |
| 1950 DCHECK(layer_animation_controller_); | |
| 1951 layer_animation_controller_->AddEventObserver(animation_observer); | |
| 1952 } | |
| 1953 | |
| 1954 void Layer::RemoveLayerAnimationEventObserver( | |
| 1955 LayerAnimationEventObserver* animation_observer) { | |
| 1956 DCHECK(layer_animation_controller_); | |
| 1957 layer_animation_controller_->RemoveEventObserver(animation_observer); | |
| 1958 } | 1819 } |
| 1959 | 1820 |
| 1960 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { | 1821 ScrollbarLayerInterface* Layer::ToScrollbarLayer() { |
| 1961 return nullptr; | 1822 return nullptr; |
| 1962 } | 1823 } |
| 1963 | 1824 |
| 1964 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { | 1825 RenderingStatsInstrumentation* Layer::rendering_stats_instrumentation() const { |
| 1965 return layer_tree_host_->rendering_stats_instrumentation(); | 1826 return layer_tree_host_->rendering_stats_instrumentation(); |
| 1966 } | 1827 } |
| 1967 | 1828 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2088 this, layer_tree_host_->property_trees()->transform_tree); | 1949 this, layer_tree_host_->property_trees()->transform_tree); |
| 2089 } | 1950 } |
| 2090 | 1951 |
| 2091 gfx::Transform Layer::screen_space_transform() const { | 1952 gfx::Transform Layer::screen_space_transform() const { |
| 2092 DCHECK_NE(transform_tree_index_, -1); | 1953 DCHECK_NE(transform_tree_index_, -1); |
| 2093 return draw_property_utils::ScreenSpaceTransform( | 1954 return draw_property_utils::ScreenSpaceTransform( |
| 2094 this, layer_tree_host_->property_trees()->transform_tree); | 1955 this, layer_tree_host_->property_trees()->transform_tree); |
| 2095 } | 1956 } |
| 2096 | 1957 |
| 2097 } // namespace cc | 1958 } // namespace cc |
| OLD | NEW |