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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 gfx::SizeF(active_tree_->InnerViewportContainerLayer()->bounds()); | 471 gfx::SizeF(active_tree_->InnerViewportContainerLayer()->bounds()); |
472 | 472 |
473 // Easing constants experimentally determined. | 473 // Easing constants experimentally determined. |
474 scoped_ptr<TimingFunction> timing_function = | 474 scoped_ptr<TimingFunction> timing_function = |
475 CubicBezierTimingFunction::Create(.8, 0, .3, .9); | 475 CubicBezierTimingFunction::Create(.8, 0, .3, .9); |
476 | 476 |
477 // TODO(miletus) : Pass in ScrollOffset. | 477 // TODO(miletus) : Pass in ScrollOffset. |
478 page_scale_animation_ = PageScaleAnimation::Create( | 478 page_scale_animation_ = PageScaleAnimation::Create( |
479 ScrollOffsetToVector2dF(scroll_total), | 479 ScrollOffsetToVector2dF(scroll_total), |
480 active_tree_->current_page_scale_factor(), viewport_size, | 480 active_tree_->current_page_scale_factor(), viewport_size, |
481 scaled_scrollable_size, timing_function.Pass()); | 481 scaled_scrollable_size, std::move(timing_function)); |
482 | 482 |
483 if (anchor_point) { | 483 if (anchor_point) { |
484 gfx::Vector2dF anchor(target_offset); | 484 gfx::Vector2dF anchor(target_offset); |
485 page_scale_animation_->ZoomWithAnchor(anchor, | 485 page_scale_animation_->ZoomWithAnchor(anchor, |
486 page_scale, | 486 page_scale, |
487 duration.InSecondsF()); | 487 duration.InSecondsF()); |
488 } else { | 488 } else { |
489 gfx::Vector2dF scaled_target_offset = target_offset; | 489 gfx::Vector2dF scaled_target_offset = target_offset; |
490 page_scale_animation_->ZoomTo(scaled_target_offset, | 490 page_scale_animation_->ZoomTo(scaled_target_offset, |
491 page_scale, | 491 page_scale, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 DCHECK(!scroll_elasticity_helper_); | 604 DCHECK(!scroll_elasticity_helper_); |
605 if (settings_.enable_elastic_overscroll) { | 605 if (settings_.enable_elastic_overscroll) { |
606 scroll_elasticity_helper_.reset( | 606 scroll_elasticity_helper_.reset( |
607 ScrollElasticityHelper::CreateForLayerTreeHostImpl(this)); | 607 ScrollElasticityHelper::CreateForLayerTreeHostImpl(this)); |
608 } | 608 } |
609 return scroll_elasticity_helper_.get(); | 609 return scroll_elasticity_helper_.get(); |
610 } | 610 } |
611 | 611 |
612 void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( | 612 void LayerTreeHostImpl::QueueSwapPromiseForMainThreadScrollUpdate( |
613 scoped_ptr<SwapPromise> swap_promise) { | 613 scoped_ptr<SwapPromise> swap_promise) { |
614 swap_promises_for_main_thread_scroll_update_.push_back(swap_promise.Pass()); | 614 swap_promises_for_main_thread_scroll_update_.push_back( |
| 615 std::move(swap_promise)); |
615 } | 616 } |
616 | 617 |
617 void LayerTreeHostImpl::TrackDamageForAllSurfaces( | 618 void LayerTreeHostImpl::TrackDamageForAllSurfaces( |
618 LayerImpl* root_draw_layer, | 619 LayerImpl* root_draw_layer, |
619 const LayerImplList& render_surface_layer_list) { | 620 const LayerImplList& render_surface_layer_list) { |
620 // For now, we use damage tracking to compute a global scissor. To do this, we | 621 // For now, we use damage tracking to compute a global scissor. To do this, we |
621 // must compute all damage tracking before drawing anything, so that we know | 622 // must compute all damage tracking before drawing anything, so that we know |
622 // the root damage rect. The root damage rect is then used to scissor each | 623 // the root damage rect. The root damage rect is then used to scissor each |
623 // surface. | 624 // surface. |
624 size_t render_surface_layer_list_size = render_surface_layer_list.size(); | 625 size_t render_surface_layer_list_size = render_surface_layer_list.size(); |
(...skipping 27 matching lines...) Expand all Loading... |
652 value->BeginDictionary(); | 653 value->BeginDictionary(); |
653 render_passes[i]->AsValueInto(value); | 654 render_passes[i]->AsValueInto(value); |
654 value->EndDictionary(); | 655 value->EndDictionary(); |
655 } | 656 } |
656 value->EndArray(); | 657 value->EndArray(); |
657 } | 658 } |
658 } | 659 } |
659 | 660 |
660 void LayerTreeHostImpl::FrameData::AppendRenderPass( | 661 void LayerTreeHostImpl::FrameData::AppendRenderPass( |
661 scoped_ptr<RenderPass> render_pass) { | 662 scoped_ptr<RenderPass> render_pass) { |
662 render_passes.push_back(render_pass.Pass()); | 663 render_passes.push_back(std::move(render_pass)); |
663 } | 664 } |
664 | 665 |
665 DrawMode LayerTreeHostImpl::GetDrawMode() const { | 666 DrawMode LayerTreeHostImpl::GetDrawMode() const { |
666 if (resourceless_software_draw_) { | 667 if (resourceless_software_draw_) { |
667 return DRAW_MODE_RESOURCELESS_SOFTWARE; | 668 return DRAW_MODE_RESOURCELESS_SOFTWARE; |
668 } else if (output_surface_->context_provider()) { | 669 } else if (output_surface_->context_provider()) { |
669 return DRAW_MODE_HARDWARE; | 670 return DRAW_MODE_HARDWARE; |
670 } else { | 671 } else { |
671 return DRAW_MODE_SOFTWARE; | 672 return DRAW_MODE_SOFTWARE; |
672 } | 673 } |
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2217 | 2218 |
2218 base::TimeTicks start_time = start_of_main_frame_args.frame_time; | 2219 base::TimeTicks start_time = start_of_main_frame_args.frame_time; |
2219 base::TimeTicks end_time = expected_next_main_frame_args.frame_time; | 2220 base::TimeTicks end_time = expected_next_main_frame_args.frame_time; |
2220 frame_timing_tracker_->SaveMainFrameTimeStamps( | 2221 frame_timing_tracker_->SaveMainFrameTimeStamps( |
2221 request_ids, start_time, end_time, active_tree_->source_frame_number()); | 2222 request_ids, start_time, end_time, active_tree_->source_frame_number()); |
2222 } | 2223 } |
2223 | 2224 |
2224 void LayerTreeHostImpl::PostFrameTimingEvents( | 2225 void LayerTreeHostImpl::PostFrameTimingEvents( |
2225 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 2226 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
2226 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 2227 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
2227 client_->PostFrameTimingEventsOnImplThread(composite_events.Pass(), | 2228 client_->PostFrameTimingEventsOnImplThread(std::move(composite_events), |
2228 main_frame_events.Pass()); | 2229 std::move(main_frame_events)); |
2229 } | 2230 } |
2230 | 2231 |
2231 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { | 2232 void LayerTreeHostImpl::CleanUpTileManagerAndUIResources() { |
2232 ClearUIResources(); | 2233 ClearUIResources(); |
2233 tile_manager_->FinishTasksAndCleanUp(); | 2234 tile_manager_->FinishTasksAndCleanUp(); |
2234 resource_pool_ = nullptr; | 2235 resource_pool_ = nullptr; |
2235 tile_task_worker_pool_ = nullptr; | 2236 tile_task_worker_pool_ = nullptr; |
2236 single_thread_synchronous_task_graph_runner_ = nullptr; | 2237 single_thread_synchronous_task_graph_runner_ = nullptr; |
2237 } | 2238 } |
2238 | 2239 |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3021 | 3022 |
3022 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 3023 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
3023 scroll_info->page_scale_delta = | 3024 scroll_info->page_scale_delta = |
3024 active_tree_->page_scale_factor()->PullDeltaForMainThread(); | 3025 active_tree_->page_scale_factor()->PullDeltaForMainThread(); |
3025 scroll_info->top_controls_delta = | 3026 scroll_info->top_controls_delta = |
3026 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread(); | 3027 active_tree()->top_controls_shown_ratio()->PullDeltaForMainThread(); |
3027 scroll_info->elastic_overscroll_delta = | 3028 scroll_info->elastic_overscroll_delta = |
3028 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); | 3029 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); |
3029 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); | 3030 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); |
3030 | 3031 |
3031 return scroll_info.Pass(); | 3032 return scroll_info; |
3032 } | 3033 } |
3033 | 3034 |
3034 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 3035 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
3035 SetViewportDamage(gfx::Rect(DrawViewportSize())); | 3036 SetViewportDamage(gfx::Rect(DrawViewportSize())); |
3036 } | 3037 } |
3037 | 3038 |
3038 void LayerTreeHostImpl::ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta) { | 3039 void LayerTreeHostImpl::ScrollViewportInnerFirst(gfx::Vector2dF scroll_delta) { |
3039 DCHECK(InnerViewportScrollLayer()); | 3040 DCHECK(InnerViewportScrollLayer()); |
3040 LayerImpl* scroll_layer = InnerViewportScrollLayer(); | 3041 LayerImpl* scroll_layer = InnerViewportScrollLayer(); |
3041 | 3042 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3148 events = animation_host_->CreateEvents(); | 3149 events = animation_host_->CreateEvents(); |
3149 has_active_animations = animation_host_->UpdateAnimationState( | 3150 has_active_animations = animation_host_->UpdateAnimationState( |
3150 start_ready_animations, events.get()); | 3151 start_ready_animations, events.get()); |
3151 } else { | 3152 } else { |
3152 events = animation_registrar_->CreateEvents(); | 3153 events = animation_registrar_->CreateEvents(); |
3153 has_active_animations = animation_registrar_->UpdateAnimationState( | 3154 has_active_animations = animation_registrar_->UpdateAnimationState( |
3154 start_ready_animations, events.get()); | 3155 start_ready_animations, events.get()); |
3155 } | 3156 } |
3156 | 3157 |
3157 if (!events->empty()) | 3158 if (!events->empty()) |
3158 client_->PostAnimationEventsToMainThreadOnImplThread(events.Pass()); | 3159 client_->PostAnimationEventsToMainThreadOnImplThread(std::move(events)); |
3159 | 3160 |
3160 if (has_active_animations) | 3161 if (has_active_animations) |
3161 SetNeedsAnimate(); | 3162 SetNeedsAnimate(); |
3162 } | 3163 } |
3163 | 3164 |
3164 void LayerTreeHostImpl::ActivateAnimations() { | 3165 void LayerTreeHostImpl::ActivateAnimations() { |
3165 if (!settings_.accelerated_animation_enabled) | 3166 if (!settings_.accelerated_animation_enabled) |
3166 return; | 3167 return; |
3167 | 3168 |
3168 bool activated = false; | 3169 bool activated = false; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3443 evicted_ui_resources_.find(uid); | 3444 evicted_ui_resources_.find(uid); |
3444 if (found_in_evicted == evicted_ui_resources_.end()) | 3445 if (found_in_evicted == evicted_ui_resources_.end()) |
3445 return; | 3446 return; |
3446 evicted_ui_resources_.erase(found_in_evicted); | 3447 evicted_ui_resources_.erase(found_in_evicted); |
3447 if (evicted_ui_resources_.empty()) | 3448 if (evicted_ui_resources_.empty()) |
3448 client_->OnCanDrawStateChanged(CanDraw()); | 3449 client_->OnCanDrawStateChanged(CanDraw()); |
3449 } | 3450 } |
3450 | 3451 |
3451 void LayerTreeHostImpl::ScheduleMicroBenchmark( | 3452 void LayerTreeHostImpl::ScheduleMicroBenchmark( |
3452 scoped_ptr<MicroBenchmarkImpl> benchmark) { | 3453 scoped_ptr<MicroBenchmarkImpl> benchmark) { |
3453 micro_benchmark_controller_.ScheduleRun(benchmark.Pass()); | 3454 micro_benchmark_controller_.ScheduleRun(std::move(benchmark)); |
3454 } | 3455 } |
3455 | 3456 |
3456 void LayerTreeHostImpl::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) { | 3457 void LayerTreeHostImpl::InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor) { |
3457 swap_promise_monitor_.insert(monitor); | 3458 swap_promise_monitor_.insert(monitor); |
3458 } | 3459 } |
3459 | 3460 |
3460 void LayerTreeHostImpl::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { | 3461 void LayerTreeHostImpl::RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor) { |
3461 swap_promise_monitor_.erase(monitor); | 3462 swap_promise_monitor_.erase(monitor); |
3462 } | 3463 } |
3463 | 3464 |
(...skipping 27 matching lines...) Expand all Loading... |
3491 return animation_host_->ImplOnlyScrollAnimationCreate( | 3492 return animation_host_->ImplOnlyScrollAnimationCreate( |
3492 layer_impl->id(), target_offset, current_offset); | 3493 layer_impl->id(), target_offset, current_offset); |
3493 | 3494 |
3494 scoped_ptr<ScrollOffsetAnimationCurve> curve = | 3495 scoped_ptr<ScrollOffsetAnimationCurve> curve = |
3495 ScrollOffsetAnimationCurve::Create( | 3496 ScrollOffsetAnimationCurve::Create( |
3496 target_offset, EaseInOutTimingFunction::Create(), | 3497 target_offset, EaseInOutTimingFunction::Create(), |
3497 ScrollOffsetAnimationCurve::DurationBehavior::CONSTANT); | 3498 ScrollOffsetAnimationCurve::DurationBehavior::CONSTANT); |
3498 curve->SetInitialValue(current_offset); | 3499 curve->SetInitialValue(current_offset); |
3499 | 3500 |
3500 scoped_ptr<Animation> animation = Animation::Create( | 3501 scoped_ptr<Animation> animation = Animation::Create( |
3501 curve.Pass(), AnimationIdProvider::NextAnimationId(), | 3502 std::move(curve), AnimationIdProvider::NextAnimationId(), |
3502 AnimationIdProvider::NextGroupId(), Animation::SCROLL_OFFSET); | 3503 AnimationIdProvider::NextGroupId(), Animation::SCROLL_OFFSET); |
3503 animation->set_is_impl_only(true); | 3504 animation->set_is_impl_only(true); |
3504 | 3505 |
3505 layer_impl->layer_animation_controller()->AddAnimation(animation.Pass()); | 3506 layer_impl->layer_animation_controller()->AddAnimation(std::move(animation)); |
3506 } | 3507 } |
3507 | 3508 |
3508 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( | 3509 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( |
3509 LayerImpl* layer_impl, | 3510 LayerImpl* layer_impl, |
3510 const gfx::Vector2dF& scroll_delta) { | 3511 const gfx::Vector2dF& scroll_delta) { |
3511 if (animation_host_) | 3512 if (animation_host_) |
3512 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( | 3513 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( |
3513 layer_impl->id(), scroll_delta, layer_impl->MaxScrollOffset(), | 3514 layer_impl->id(), scroll_delta, layer_impl->MaxScrollOffset(), |
3514 CurrentBeginFrameArgs().frame_time); | 3515 CurrentBeginFrameArgs().frame_time); |
3515 | 3516 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3696 return task_runner_provider_->HasImplThread(); | 3697 return task_runner_provider_->HasImplThread(); |
3697 } | 3698 } |
3698 | 3699 |
3699 bool LayerTreeHostImpl::CommitToActiveTree() const { | 3700 bool LayerTreeHostImpl::CommitToActiveTree() const { |
3700 // In single threaded mode we skip the pending tree and commit directly to the | 3701 // In single threaded mode we skip the pending tree and commit directly to the |
3701 // active tree. | 3702 // active tree. |
3702 return !task_runner_provider_->HasImplThread(); | 3703 return !task_runner_provider_->HasImplThread(); |
3703 } | 3704 } |
3704 | 3705 |
3705 } // namespace cc | 3706 } // namespace cc |
OLD | NEW |