| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.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 #include <limits> | 11 #include <limits> |
| 12 #include <map> | 12 #include <map> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <unordered_map> | 14 #include <unordered_map> |
| 15 #include <utility> | 15 #include <utility> |
| 16 | 16 |
| 17 #include "base/auto_reset.h" | 17 #include "base/auto_reset.h" |
| 18 #include "base/containers/small_map.h" | 18 #include "base/containers/small_map.h" |
| 19 #include "base/json/json_writer.h" | 19 #include "base/json/json_writer.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/numerics/safe_conversions.h" | 21 #include "base/numerics/safe_conversions.h" |
| 22 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "base/trace_event/trace_event_argument.h" | 24 #include "base/trace_event/trace_event_argument.h" |
| 25 #include "cc/animation/animation_events.h" | 25 #include "cc/animation/animation_events.h" |
| 26 #include "cc/animation/animation_host.h" | 26 #include "cc/animation/animation_host.h" |
| 27 #include "cc/animation/animation_id_provider.h" | |
| 28 #include "cc/animation/scroll_offset_animation_curve.h" | |
| 29 #include "cc/animation/timing_function.h" | 27 #include "cc/animation/timing_function.h" |
| 30 #include "cc/base/histograms.h" | 28 #include "cc/base/histograms.h" |
| 31 #include "cc/base/math_util.h" | 29 #include "cc/base/math_util.h" |
| 32 #include "cc/debug/benchmark_instrumentation.h" | 30 #include "cc/debug/benchmark_instrumentation.h" |
| 33 #include "cc/debug/debug_rect_history.h" | 31 #include "cc/debug/debug_rect_history.h" |
| 34 #include "cc/debug/devtools_instrumentation.h" | 32 #include "cc/debug/devtools_instrumentation.h" |
| 35 #include "cc/debug/frame_rate_counter.h" | 33 #include "cc/debug/frame_rate_counter.h" |
| 36 #include "cc/debug/frame_viewer_instrumentation.h" | 34 #include "cc/debug/frame_viewer_instrumentation.h" |
| 37 #include "cc/debug/rendering_stats_instrumentation.h" | 35 #include "cc/debug/rendering_stats_instrumentation.h" |
| 38 #include "cc/debug/traced_value.h" | 36 #include "cc/debug/traced_value.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 settings.use_partial_raster)), | 215 settings.use_partial_raster)), |
| 218 pinch_gesture_active_(false), | 216 pinch_gesture_active_(false), |
| 219 pinch_gesture_end_should_clear_scrolling_layer_(false), | 217 pinch_gesture_end_should_clear_scrolling_layer_(false), |
| 220 fps_counter_( | 218 fps_counter_( |
| 221 FrameRateCounter::Create(task_runner_provider_->HasImplThread())), | 219 FrameRateCounter::Create(task_runner_provider_->HasImplThread())), |
| 222 memory_history_(MemoryHistory::Create()), | 220 memory_history_(MemoryHistory::Create()), |
| 223 debug_rect_history_(DebugRectHistory::Create()), | 221 debug_rect_history_(DebugRectHistory::Create()), |
| 224 texture_mailbox_deleter_(new TextureMailboxDeleter(GetTaskRunner())), | 222 texture_mailbox_deleter_(new TextureMailboxDeleter(GetTaskRunner())), |
| 225 max_memory_needed_bytes_(0), | 223 max_memory_needed_bytes_(0), |
| 226 resourceless_software_draw_(false), | 224 resourceless_software_draw_(false), |
| 227 animation_registrar_(), | 225 animation_host_(), |
| 228 rendering_stats_instrumentation_(rendering_stats_instrumentation), | 226 rendering_stats_instrumentation_(rendering_stats_instrumentation), |
| 229 micro_benchmark_controller_(this), | 227 micro_benchmark_controller_(this), |
| 230 shared_bitmap_manager_(shared_bitmap_manager), | 228 shared_bitmap_manager_(shared_bitmap_manager), |
| 231 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), | 229 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 232 task_graph_runner_(task_graph_runner), | 230 task_graph_runner_(task_graph_runner), |
| 233 id_(id), | 231 id_(id), |
| 234 requires_high_res_to_draw_(false), | 232 requires_high_res_to_draw_(false), |
| 235 is_likely_to_require_a_draw_(false), | 233 is_likely_to_require_a_draw_(false), |
| 236 frame_timing_tracker_(FrameTimingTracker::Create(this)) { | 234 frame_timing_tracker_(FrameTimingTracker::Create(this)) { |
| 237 if (settings.use_compositor_animation_timelines) { | 235 if (settings.accelerated_animation_enabled) { |
| 238 if (settings.accelerated_animation_enabled) { | 236 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); |
| 239 animation_host_ = AnimationHost::Create(ThreadInstance::IMPL); | 237 animation_host_->SetMutatorHostClient(this); |
| 240 animation_host_->SetMutatorHostClient(this); | 238 animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); |
| 241 animation_host_->SetSupportsScrollAnimations(SupportsImplScrolling()); | |
| 242 } | |
| 243 } else { | |
| 244 animation_registrar_ = AnimationRegistrar::Create(); | |
| 245 animation_registrar_->set_supports_scroll_animations( | |
| 246 SupportsImplScrolling()); | |
| 247 } | 239 } |
| 248 | 240 |
| 249 DCHECK(task_runner_provider_->IsImplThread()); | 241 DCHECK(task_runner_provider_->IsImplThread()); |
| 250 DidVisibilityChange(this, visible_); | 242 DidVisibilityChange(this, visible_); |
| 251 | 243 |
| 252 SetDebugState(settings.initial_debug_state); | 244 SetDebugState(settings.initial_debug_state); |
| 253 | 245 |
| 254 // LTHI always has an active tree. | 246 // LTHI always has an active tree. |
| 255 active_tree_ = | 247 active_tree_ = |
| 256 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), | 248 LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), |
| (...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 // contents of its texture are updated as the last thing before the frame is | 1644 // contents of its texture are updated as the last thing before the frame is |
| 1653 // drawn. | 1645 // drawn. |
| 1654 if (active_tree_->hud_layer()) { | 1646 if (active_tree_->hud_layer()) { |
| 1655 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); | 1647 TRACE_EVENT0("cc", "DrawLayers.UpdateHudTexture"); |
| 1656 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, | 1648 active_tree_->hud_layer()->UpdateHudTexture(draw_mode, |
| 1657 resource_provider_.get()); | 1649 resource_provider_.get()); |
| 1658 } | 1650 } |
| 1659 | 1651 |
| 1660 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { | 1652 if (draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) { |
| 1661 bool disable_picture_quad_image_filtering = | 1653 bool disable_picture_quad_image_filtering = |
| 1662 IsActivelyScrolling() || | 1654 IsActivelyScrolling() || animation_host_->NeedsAnimateLayers(); |
| 1663 (animation_host_ ? animation_host_->NeedsAnimateLayers() | |
| 1664 : animation_registrar_->needs_animate_layers()); | |
| 1665 | 1655 |
| 1666 scoped_ptr<SoftwareRenderer> temp_software_renderer = | 1656 scoped_ptr<SoftwareRenderer> temp_software_renderer = |
| 1667 SoftwareRenderer::Create(this, &settings_.renderer_settings, | 1657 SoftwareRenderer::Create(this, &settings_.renderer_settings, |
| 1668 output_surface_, NULL); | 1658 output_surface_, NULL); |
| 1669 temp_software_renderer->DrawFrame( | 1659 temp_software_renderer->DrawFrame( |
| 1670 &frame->render_passes, active_tree_->device_scale_factor(), | 1660 &frame->render_passes, active_tree_->device_scale_factor(), |
| 1671 DeviceViewport(), DeviceClip(), disable_picture_quad_image_filtering); | 1661 DeviceViewport(), DeviceClip(), disable_picture_quad_image_filtering); |
| 1672 } else { | 1662 } else { |
| 1673 renderer_->DrawFrame(&frame->render_passes, | 1663 renderer_->DrawFrame(&frame->render_passes, |
| 1674 active_tree_->device_scale_factor(), DeviceViewport(), | 1664 active_tree_->device_scale_factor(), DeviceViewport(), |
| (...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3354 for (auto& pair : scrollbar_animation_controllers_) | 3344 for (auto& pair : scrollbar_animation_controllers_) |
| 3355 animated |= pair.second->Animate(monotonic_time); | 3345 animated |= pair.second->Animate(monotonic_time); |
| 3356 return animated; | 3346 return animated; |
| 3357 } | 3347 } |
| 3358 | 3348 |
| 3359 bool LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { | 3349 bool LayerTreeHostImpl::AnimateLayers(base::TimeTicks monotonic_time) { |
| 3360 if (!settings_.accelerated_animation_enabled) | 3350 if (!settings_.accelerated_animation_enabled) |
| 3361 return false; | 3351 return false; |
| 3362 | 3352 |
| 3363 bool animated = false; | 3353 bool animated = false; |
| 3364 if (animation_host_) { | 3354 if (animation_host_->AnimateLayers(monotonic_time)) |
| 3365 if (animation_host_->AnimateLayers(monotonic_time)) | 3355 animated = true; |
| 3366 animated = true; | |
| 3367 } else { | |
| 3368 if (animation_registrar_->AnimateLayers(monotonic_time)) | |
| 3369 animated = true; | |
| 3370 } | |
| 3371 | 3356 |
| 3372 // TODO(crbug.com/551134): Only do this if the animations are on the active | 3357 // TODO(crbug.com/551134): Only do this if the animations are on the active |
| 3373 // tree, or if they are on the pending tree waiting for some future time to | 3358 // tree, or if they are on the pending tree waiting for some future time to |
| 3374 // start. | 3359 // start. |
| 3375 // TODO(crbug.com/551138): We currently have a single signal from the | 3360 // TODO(crbug.com/551138): We currently have a single signal from the |
| 3376 // animation host/registrar, so on the last frame of an animation we will | 3361 // animation host/registrar, so on the last frame of an animation we will |
| 3377 // still request an extra SetNeedsAnimate here. | 3362 // still request an extra SetNeedsAnimate here. |
| 3378 if (animated) | 3363 if (animated) |
| 3379 SetNeedsOneBeginImplFrame(); | 3364 SetNeedsOneBeginImplFrame(); |
| 3380 // TODO(crbug.com/551138): We could return true only if the animations are on | 3365 // TODO(crbug.com/551138): We could return true only if the animations are on |
| 3381 // the active tree. There's no need to cause a draw to take place from | 3366 // the active tree. There's no need to cause a draw to take place from |
| 3382 // animations starting/ticking on the pending tree. | 3367 // animations starting/ticking on the pending tree. |
| 3383 return animated; | 3368 return animated; |
| 3384 } | 3369 } |
| 3385 | 3370 |
| 3386 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { | 3371 void LayerTreeHostImpl::UpdateAnimationState(bool start_ready_animations) { |
| 3387 if (!settings_.accelerated_animation_enabled) | 3372 if (!settings_.accelerated_animation_enabled) |
| 3388 return; | 3373 return; |
| 3389 | 3374 |
| 3390 bool has_active_animations = false; | 3375 bool has_active_animations = false; |
| 3391 scoped_ptr<AnimationEvents> events; | 3376 scoped_ptr<AnimationEvents> events; |
| 3392 | 3377 |
| 3393 if (animation_host_) { | 3378 events = animation_host_->CreateEvents(); |
| 3394 events = animation_host_->CreateEvents(); | 3379 has_active_animations = animation_host_->UpdateAnimationState( |
| 3395 has_active_animations = animation_host_->UpdateAnimationState( | 3380 start_ready_animations, events.get()); |
| 3396 start_ready_animations, events.get()); | |
| 3397 } else { | |
| 3398 events = animation_registrar_->CreateEvents(); | |
| 3399 has_active_animations = animation_registrar_->UpdateAnimationState( | |
| 3400 start_ready_animations, events.get()); | |
| 3401 } | |
| 3402 | 3381 |
| 3403 if (!events->events_.empty()) | 3382 if (!events->events_.empty()) |
| 3404 client_->PostAnimationEventsToMainThreadOnImplThread(std::move(events)); | 3383 client_->PostAnimationEventsToMainThreadOnImplThread(std::move(events)); |
| 3405 | 3384 |
| 3406 if (has_active_animations) | 3385 if (has_active_animations) |
| 3407 SetNeedsOneBeginImplFrame(); | 3386 SetNeedsOneBeginImplFrame(); |
| 3408 } | 3387 } |
| 3409 | 3388 |
| 3410 void LayerTreeHostImpl::ActivateAnimations() { | 3389 void LayerTreeHostImpl::ActivateAnimations() { |
| 3411 if (!settings_.accelerated_animation_enabled) | 3390 if (!settings_.accelerated_animation_enabled) |
| 3412 return; | 3391 return; |
| 3413 | 3392 |
| 3414 bool activated = false; | 3393 const bool activated = animation_host_->ActivateAnimations(); |
| 3415 if (animation_host_) { | |
| 3416 if (animation_host_->ActivateAnimations()) | |
| 3417 activated = true; | |
| 3418 } else { | |
| 3419 if (animation_registrar_->ActivateAnimations()) | |
| 3420 activated = true; | |
| 3421 } | |
| 3422 | |
| 3423 if (activated) { | 3394 if (activated) { |
| 3424 // Activating an animation changes layer draw properties, such as | 3395 // Activating an animation changes layer draw properties, such as |
| 3425 // screen_space_transform_is_animating. So when we see a new animation get | 3396 // screen_space_transform_is_animating. So when we see a new animation get |
| 3426 // activated, we need to update the draw properties on the active tree. | 3397 // activated, we need to update the draw properties on the active tree. |
| 3427 active_tree()->set_needs_update_draw_properties(); | 3398 active_tree()->set_needs_update_draw_properties(); |
| 3428 // Request another frame to run the next tick of the animation. | 3399 // Request another frame to run the next tick of the animation. |
| 3429 SetNeedsOneBeginImplFrame(); | 3400 SetNeedsOneBeginImplFrame(); |
| 3430 } | 3401 } |
| 3431 } | 3402 } |
| 3432 | 3403 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3728 if (!input_handler_client_) | 3699 if (!input_handler_client_) |
| 3729 return; | 3700 return; |
| 3730 input_handler_client_->UpdateRootLayerStateForSynchronousInputHandler( | 3701 input_handler_client_->UpdateRootLayerStateForSynchronousInputHandler( |
| 3731 active_tree_->TotalScrollOffset(), active_tree_->TotalMaxScrollOffset(), | 3702 active_tree_->TotalScrollOffset(), active_tree_->TotalMaxScrollOffset(), |
| 3732 active_tree_->ScrollableSize(), active_tree_->current_page_scale_factor(), | 3703 active_tree_->ScrollableSize(), active_tree_->current_page_scale_factor(), |
| 3733 active_tree_->min_page_scale_factor(), | 3704 active_tree_->min_page_scale_factor(), |
| 3734 active_tree_->max_page_scale_factor()); | 3705 active_tree_->max_page_scale_factor()); |
| 3735 } | 3706 } |
| 3736 | 3707 |
| 3737 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { | 3708 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { |
| 3738 if (animation_host_) | 3709 return animation_host_->ScrollAnimationAbort(false /* needs_completion */); |
| 3739 return animation_host_->ScrollAnimationAbort(false /* needs_completion */); | |
| 3740 | |
| 3741 layer_impl->layer_animation_controller()->AbortAnimations( | |
| 3742 TargetProperty::SCROLL_OFFSET); | |
| 3743 } | 3710 } |
| 3744 | 3711 |
| 3745 void LayerTreeHostImpl::ScrollAnimationCreate( | 3712 void LayerTreeHostImpl::ScrollAnimationCreate( |
| 3746 ScrollNode* scroll_node, | 3713 ScrollNode* scroll_node, |
| 3747 const gfx::ScrollOffset& target_offset, | 3714 const gfx::ScrollOffset& target_offset, |
| 3748 const gfx::ScrollOffset& current_offset) { | 3715 const gfx::ScrollOffset& current_offset) { |
| 3749 if (animation_host_) | 3716 return animation_host_->ImplOnlyScrollAnimationCreate( |
| 3750 return animation_host_->ImplOnlyScrollAnimationCreate( | 3717 scroll_node->owner_id, target_offset, current_offset); |
| 3751 scroll_node->owner_id, target_offset, current_offset); | |
| 3752 | |
| 3753 LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); | |
| 3754 | |
| 3755 scoped_ptr<ScrollOffsetAnimationCurve> curve = | |
| 3756 ScrollOffsetAnimationCurve::Create( | |
| 3757 target_offset, EaseInOutTimingFunction::Create(), | |
| 3758 ScrollOffsetAnimationCurve::DurationBehavior::INVERSE_DELTA); | |
| 3759 curve->SetInitialValue(current_offset); | |
| 3760 | |
| 3761 scoped_ptr<Animation> animation = Animation::Create( | |
| 3762 std::move(curve), AnimationIdProvider::NextAnimationId(), | |
| 3763 AnimationIdProvider::NextGroupId(), TargetProperty::SCROLL_OFFSET); | |
| 3764 animation->set_is_impl_only(true); | |
| 3765 | |
| 3766 layer_impl->layer_animation_controller()->AddAnimation(std::move(animation)); | |
| 3767 } | 3718 } |
| 3768 | 3719 |
| 3769 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( | 3720 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( |
| 3770 ScrollNode* scroll_node, | 3721 ScrollNode* scroll_node, |
| 3771 const gfx::Vector2dF& scroll_delta) { | 3722 const gfx::Vector2dF& scroll_delta) { |
| 3772 if (animation_host_) | 3723 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( |
| 3773 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( | 3724 scroll_node->owner_id, scroll_delta, |
| 3774 scroll_node->owner_id, scroll_delta, | 3725 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( |
| 3775 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( | 3726 scroll_node->id), |
| 3776 scroll_node->id), | 3727 CurrentBeginFrameArgs().frame_time); |
| 3777 CurrentBeginFrameArgs().frame_time); | |
| 3778 | |
| 3779 LayerImpl* layer_impl = active_tree_->LayerById(scroll_node->owner_id); | |
| 3780 | |
| 3781 Animation* animation = | |
| 3782 layer_impl->layer_animation_controller() | |
| 3783 ? layer_impl->layer_animation_controller()->GetAnimation( | |
| 3784 TargetProperty::SCROLL_OFFSET) | |
| 3785 : nullptr; | |
| 3786 if (!animation) | |
| 3787 return false; | |
| 3788 | |
| 3789 ScrollOffsetAnimationCurve* curve = | |
| 3790 animation->curve()->ToScrollOffsetAnimationCurve(); | |
| 3791 | |
| 3792 gfx::ScrollOffset new_target = | |
| 3793 gfx::ScrollOffsetWithDelta(curve->target_value(), scroll_delta); | |
| 3794 new_target.SetToMax(gfx::ScrollOffset()); | |
| 3795 new_target.SetToMin(layer_impl->MaxScrollOffset()); | |
| 3796 | |
| 3797 curve->UpdateTarget( | |
| 3798 animation->TrimTimeToCurrentIteration(CurrentBeginFrameArgs().frame_time) | |
| 3799 .InSecondsF(), | |
| 3800 new_target); | |
| 3801 | |
| 3802 return true; | |
| 3803 } | 3728 } |
| 3804 | 3729 |
| 3805 bool LayerTreeHostImpl::IsLayerInTree(int layer_id, | 3730 bool LayerTreeHostImpl::IsLayerInTree(int layer_id, |
| 3806 LayerTreeType tree_type) const { | 3731 LayerTreeType tree_type) const { |
| 3807 if (tree_type == LayerTreeType::ACTIVE) { | 3732 if (tree_type == LayerTreeType::ACTIVE) { |
| 3808 return active_tree() ? active_tree()->LayerById(layer_id) != nullptr | 3733 return active_tree() ? active_tree()->LayerById(layer_id) != nullptr |
| 3809 : false; | 3734 : false; |
| 3810 } else { | 3735 } else { |
| 3811 if (pending_tree() && pending_tree()->LayerById(layer_id)) | 3736 if (pending_tree() && pending_tree()->LayerById(layer_id)) |
| 3812 return true; | 3737 return true; |
| 3813 if (recycle_tree() && recycle_tree()->LayerById(layer_id)) | 3738 if (recycle_tree() && recycle_tree()->LayerById(layer_id)) |
| 3814 return true; | 3739 return true; |
| 3815 | 3740 |
| 3816 return false; | 3741 return false; |
| 3817 } | 3742 } |
| 3818 } | 3743 } |
| 3819 | 3744 |
| 3820 void LayerTreeHostImpl::SetMutatorsNeedCommit() {} | 3745 void LayerTreeHostImpl::SetMutatorsNeedCommit() {} |
| 3821 | 3746 |
| 3822 void LayerTreeHostImpl::SetMutatorsNeedRebuildPropertyTrees() {} | 3747 void LayerTreeHostImpl::SetMutatorsNeedRebuildPropertyTrees() {} |
| 3823 | 3748 |
| 3824 void LayerTreeHostImpl::SetTreeLayerFilterMutated( | 3749 void LayerTreeHostImpl::SetTreeLayerFilterMutated( |
| 3825 int layer_id, | 3750 int layer_id, |
| 3826 LayerTreeImpl* tree, | 3751 LayerTreeImpl* tree, |
| 3827 const FilterOperations& filters) { | 3752 const FilterOperations& filters) { |
| 3828 if (!tree) | 3753 if (!tree) |
| 3829 return; | 3754 return; |
| 3830 | 3755 |
| 3831 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | 3756 LayerImpl* layer = tree->LayerById(layer_id); |
| 3832 if (layer) | 3757 if (layer) |
| 3833 layer->OnFilterAnimated(filters); | 3758 layer->OnFilterAnimated(filters); |
| 3834 } | 3759 } |
| 3835 | 3760 |
| 3836 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, | 3761 void LayerTreeHostImpl::SetTreeLayerOpacityMutated(int layer_id, |
| 3837 LayerTreeImpl* tree, | 3762 LayerTreeImpl* tree, |
| 3838 float opacity) { | 3763 float opacity) { |
| 3839 if (!tree) | 3764 if (!tree) |
| 3840 return; | 3765 return; |
| 3841 | 3766 |
| 3842 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | 3767 LayerImpl* layer = tree->LayerById(layer_id); |
| 3843 if (layer) | 3768 if (layer) |
| 3844 layer->OnOpacityAnimated(opacity); | 3769 layer->OnOpacityAnimated(opacity); |
| 3845 } | 3770 } |
| 3846 | 3771 |
| 3847 void LayerTreeHostImpl::SetTreeLayerTransformMutated( | 3772 void LayerTreeHostImpl::SetTreeLayerTransformMutated( |
| 3848 int layer_id, | 3773 int layer_id, |
| 3849 LayerTreeImpl* tree, | 3774 LayerTreeImpl* tree, |
| 3850 const gfx::Transform& transform) { | 3775 const gfx::Transform& transform) { |
| 3851 if (!tree) | 3776 if (!tree) |
| 3852 return; | 3777 return; |
| 3853 | 3778 |
| 3854 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | 3779 LayerImpl* layer = tree->LayerById(layer_id); |
| 3855 if (layer) | 3780 if (layer) |
| 3856 layer->OnTransformAnimated(transform); | 3781 layer->OnTransformAnimated(transform); |
| 3857 } | 3782 } |
| 3858 | 3783 |
| 3859 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( | 3784 void LayerTreeHostImpl::SetTreeLayerScrollOffsetMutated( |
| 3860 int layer_id, | 3785 int layer_id, |
| 3861 LayerTreeImpl* tree, | 3786 LayerTreeImpl* tree, |
| 3862 const gfx::ScrollOffset& scroll_offset) { | 3787 const gfx::ScrollOffset& scroll_offset) { |
| 3863 if (!tree) | 3788 if (!tree) |
| 3864 return; | 3789 return; |
| 3865 | 3790 |
| 3866 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | 3791 LayerImpl* layer = tree->LayerById(layer_id); |
| 3867 if (layer) | 3792 if (layer) |
| 3868 layer->OnScrollOffsetAnimated(scroll_offset); | 3793 layer->OnScrollOffsetAnimated(scroll_offset); |
| 3869 } | 3794 } |
| 3870 | 3795 |
| 3871 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( | 3796 void LayerTreeHostImpl::TreeLayerTransformIsPotentiallyAnimatingChanged( |
| 3872 int layer_id, | 3797 int layer_id, |
| 3873 LayerTreeImpl* tree, | 3798 LayerTreeImpl* tree, |
| 3874 bool is_animating) { | 3799 bool is_animating) { |
| 3875 if (!tree) | 3800 if (!tree) |
| 3876 return; | 3801 return; |
| 3877 | 3802 |
| 3878 LayerAnimationValueObserver* layer = tree->LayerById(layer_id); | 3803 LayerImpl* layer = tree->LayerById(layer_id); |
| 3879 if (layer) | 3804 if (layer) |
| 3880 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); | 3805 layer->OnTransformIsPotentiallyAnimatingChanged(is_animating); |
| 3881 } | 3806 } |
| 3882 | 3807 |
| 3883 bool LayerTreeHostImpl::AnimationsPreserveAxisAlignment( | 3808 bool LayerTreeHostImpl::AnimationsPreserveAxisAlignment( |
| 3884 const LayerImpl* layer) const { | 3809 const LayerImpl* layer) const { |
| 3885 return animation_host_ | 3810 return animation_host_ |
| 3886 ? animation_host_->AnimationsPreserveAxisAlignment(layer->id()) | 3811 ? animation_host_->AnimationsPreserveAxisAlignment(layer->id()) |
| 3887 : true; | 3812 : true; |
| 3888 } | 3813 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3949 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { | 3874 void LayerTreeHostImpl::ScrollOffsetAnimationFinished() { |
| 3950 // TODO(majidvp): We should pass in the original starting scroll position here | 3875 // TODO(majidvp): We should pass in the original starting scroll position here |
| 3951 ScrollStateData scroll_state_data; | 3876 ScrollStateData scroll_state_data; |
| 3952 ScrollState scroll_state(scroll_state_data); | 3877 ScrollState scroll_state(scroll_state_data); |
| 3953 ScrollEnd(&scroll_state); | 3878 ScrollEnd(&scroll_state); |
| 3954 } | 3879 } |
| 3955 | 3880 |
| 3956 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( | 3881 gfx::ScrollOffset LayerTreeHostImpl::GetScrollOffsetForAnimation( |
| 3957 int layer_id) const { | 3882 int layer_id) const { |
| 3958 if (active_tree()) { | 3883 if (active_tree()) { |
| 3959 LayerAnimationValueProvider* layer = active_tree()->LayerById(layer_id); | 3884 LayerImpl* layer = active_tree()->LayerById(layer_id); |
| 3960 if (layer) | 3885 if (layer) |
| 3961 return layer->ScrollOffsetForAnimation(); | 3886 return layer->ScrollOffsetForAnimation(); |
| 3962 } | 3887 } |
| 3963 | 3888 |
| 3964 return gfx::ScrollOffset(); | 3889 return gfx::ScrollOffset(); |
| 3965 } | 3890 } |
| 3966 | 3891 |
| 3967 bool LayerTreeHostImpl::SupportsImplScrolling() const { | 3892 bool LayerTreeHostImpl::SupportsImplScrolling() const { |
| 3968 // Supported in threaded mode. | 3893 // Supported in threaded mode. |
| 3969 return task_runner_provider_->HasImplThread(); | 3894 return task_runner_provider_->HasImplThread(); |
| 3970 } | 3895 } |
| 3971 | 3896 |
| 3972 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3897 bool LayerTreeHostImpl::CommitToActiveTree() const { |
| 3973 // In single threaded mode we skip the pending tree and commit directly to the | 3898 // In single threaded mode we skip the pending tree and commit directly to the |
| 3974 // active tree. | 3899 // active tree. |
| 3975 return !task_runner_provider_->HasImplThread(); | 3900 return !task_runner_provider_->HasImplThread(); |
| 3976 } | 3901 } |
| 3977 | 3902 |
| 3978 } // namespace cc | 3903 } // namespace cc |
| OLD | NEW |