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 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 requires_high_res_to_draw_(false), | 230 requires_high_res_to_draw_(false), |
231 required_for_draw_tile_is_top_of_raster_queue_(false) { | 231 required_for_draw_tile_is_top_of_raster_queue_(false) { |
232 DCHECK(proxy_->IsImplThread()); | 232 DCHECK(proxy_->IsImplThread()); |
233 DidVisibilityChange(this, visible_); | 233 DidVisibilityChange(this, visible_); |
234 animation_registrar_->set_supports_scroll_animations( | 234 animation_registrar_->set_supports_scroll_animations( |
235 proxy_->SupportsImplScrolling()); | 235 proxy_->SupportsImplScrolling()); |
236 | 236 |
237 SetDebugState(settings.initial_debug_state); | 237 SetDebugState(settings.initial_debug_state); |
238 | 238 |
239 // LTHI always has an active tree. | 239 // LTHI always has an active tree. |
240 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>()); | 240 active_tree_ = LayerTreeImpl::create(this, new SyncedProperty<ScaleGroup>(), |
| 241 new SyncedElasticOverscroll); |
241 | 242 |
242 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 243 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
243 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); | 244 TRACE_DISABLED_BY_DEFAULT("cc.debug"), "cc::LayerTreeHostImpl", id_); |
244 | 245 |
245 if (settings.calculate_top_controls_position) { | 246 if (settings.calculate_top_controls_position) { |
246 top_controls_manager_ = | 247 top_controls_manager_ = |
247 TopControlsManager::Create(this, | 248 TopControlsManager::Create(this, |
248 settings.top_controls_show_threshold, | 249 settings.top_controls_show_threshold, |
249 settings.top_controls_hide_threshold); | 250 settings.top_controls_hide_threshold); |
250 } | 251 } |
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); | 1095 EnforceManagedMemoryPolicy(ManagedMemoryPolicy(0)); |
1095 } | 1096 } |
1096 | 1097 |
1097 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 1098 void LayerTreeHostImpl::BlockNotifyReadyToActivateForTesting(bool block) { |
1098 NOTREACHED(); | 1099 NOTREACHED(); |
1099 } | 1100 } |
1100 | 1101 |
1101 void LayerTreeHostImpl::ResetTreesForTesting() { | 1102 void LayerTreeHostImpl::ResetTreesForTesting() { |
1102 if (active_tree_) | 1103 if (active_tree_) |
1103 active_tree_->DetachLayerTree(); | 1104 active_tree_->DetachLayerTree(); |
1104 active_tree_ = | 1105 active_tree_ = LayerTreeImpl::create(this, active_tree()->page_scale_factor(), |
1105 LayerTreeImpl::create(this, active_tree()->page_scale_factor()); | 1106 active_tree()->elastic_overscroll()); |
1106 if (pending_tree_) | 1107 if (pending_tree_) |
1107 pending_tree_->DetachLayerTree(); | 1108 pending_tree_->DetachLayerTree(); |
1108 pending_tree_ = nullptr; | 1109 pending_tree_ = nullptr; |
1109 if (recycle_tree_) | 1110 if (recycle_tree_) |
1110 recycle_tree_->DetachLayerTree(); | 1111 recycle_tree_->DetachLayerTree(); |
1111 recycle_tree_ = nullptr; | 1112 recycle_tree_ = nullptr; |
1112 } | 1113 } |
1113 | 1114 |
1114 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( | 1115 void LayerTreeHostImpl::EnforceManagedMemoryPolicy( |
1115 const ManagedMemoryPolicy& policy) { | 1116 const ManagedMemoryPolicy& policy) { |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 | 1742 |
1742 return NULL; | 1743 return NULL; |
1743 } | 1744 } |
1744 | 1745 |
1745 void LayerTreeHostImpl::CreatePendingTree() { | 1746 void LayerTreeHostImpl::CreatePendingTree() { |
1746 CHECK(!pending_tree_); | 1747 CHECK(!pending_tree_); |
1747 if (recycle_tree_) | 1748 if (recycle_tree_) |
1748 recycle_tree_.swap(pending_tree_); | 1749 recycle_tree_.swap(pending_tree_); |
1749 else | 1750 else |
1750 pending_tree_ = | 1751 pending_tree_ = |
1751 LayerTreeImpl::create(this, active_tree()->page_scale_factor()); | 1752 LayerTreeImpl::create(this, active_tree()->page_scale_factor(), |
| 1753 active_tree()->elastic_overscroll()); |
1752 | 1754 |
1753 // Update the delta from the active tree, which may have | 1755 // Update the delta from the active tree, which may have |
1754 // adjusted its delta prior to the pending tree being created. | 1756 // adjusted its delta prior to the pending tree being created. |
1755 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); | 1757 DCHECK_EQ(0.f, pending_tree_->sent_top_controls_delta()); |
1756 pending_tree_->set_top_controls_delta( | 1758 pending_tree_->set_top_controls_delta( |
1757 active_tree_->top_controls_delta() - | 1759 active_tree_->top_controls_delta() - |
1758 active_tree_->sent_top_controls_delta()); | 1760 active_tree_->sent_top_controls_delta()); |
1759 pending_tree_->set_top_controls_height(active_tree_->top_controls_height()); | 1761 pending_tree_->set_top_controls_height(active_tree_->top_controls_height()); |
1760 | 1762 |
1761 client_->OnCanDrawStateChanged(CanDraw()); | 1763 client_->OnCanDrawStateChanged(CanDraw()); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2001 | 2003 |
2002 *raster_worker_pool = | 2004 *raster_worker_pool = |
2003 GpuRasterWorkerPool::Create(task_runner, | 2005 GpuRasterWorkerPool::Create(task_runner, |
2004 context_provider, | 2006 context_provider, |
2005 resource_provider_.get(), | 2007 resource_provider_.get(), |
2006 settings_.use_distance_field_text); | 2008 settings_.use_distance_field_text); |
2007 return; | 2009 return; |
2008 } | 2010 } |
2009 | 2011 |
2010 if (GetRendererCapabilities().using_image) { | 2012 if (GetRendererCapabilities().using_image) { |
2011 unsigned image_target = GL_TEXTURE_2D; | 2013 unsigned image_target = settings_.use_image_texture_target; |
2012 #if defined(OS_MACOSX) | 2014 DCHECK_IMPLIES( |
2013 // GL_TEXTURE_RECTANGLE_ARB target is required by IOSurface backed images. | 2015 image_target == GL_TEXTURE_RECTANGLE_ARB, |
2014 DCHECK(context_provider->ContextCapabilities().gpu.texture_rectangle); | 2016 context_provider->ContextCapabilities().gpu.texture_rectangle); |
2015 image_target = GL_TEXTURE_RECTANGLE_ARB; | 2017 DCHECK_IMPLIES( |
2016 #endif | 2018 image_target == GL_TEXTURE_EXTERNAL_OES, |
2017 if (settings_.use_image_external) { | 2019 context_provider->ContextCapabilities().gpu.egl_image_external); |
2018 DCHECK(context_provider->ContextCapabilities().gpu.egl_image_external); | |
2019 image_target = GL_TEXTURE_EXTERNAL_OES; | |
2020 } | |
2021 | 2020 |
2022 if (settings_.use_zero_copy || IsSynchronousSingleThreaded()) { | 2021 if (settings_.use_zero_copy || IsSynchronousSingleThreaded()) { |
2023 *resource_pool = | 2022 *resource_pool = |
2024 ResourcePool::Create(resource_provider_.get(), image_target, | 2023 ResourcePool::Create(resource_provider_.get(), image_target, |
2025 resource_provider_->best_texture_format()); | 2024 resource_provider_->best_texture_format()); |
2026 | 2025 |
2027 TaskGraphRunner* task_graph_runner; | 2026 TaskGraphRunner* task_graph_runner; |
2028 if (IsSynchronousSingleThreaded()) { | 2027 if (IsSynchronousSingleThreaded()) { |
2029 DCHECK(!single_thread_synchronous_task_graph_runner_); | 2028 DCHECK(!single_thread_synchronous_task_graph_runner_); |
2030 single_thread_synchronous_task_graph_runner_.reset(new TaskGraphRunner); | 2029 single_thread_synchronous_task_graph_runner_.reset(new TaskGraphRunner); |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 did_scroll_x |= did_move_layer_x; | 2673 did_scroll_x |= did_move_layer_x; |
2675 did_scroll_y |= did_move_layer_y; | 2674 did_scroll_y |= did_move_layer_y; |
2676 if (!did_move_layer_x && !did_move_layer_y) { | 2675 if (!did_move_layer_x && !did_move_layer_y) { |
2677 if (allow_bubbling_for_current_layer || !did_lock_scrolling_layer_) | 2676 if (allow_bubbling_for_current_layer || !did_lock_scrolling_layer_) |
2678 continue; | 2677 continue; |
2679 else | 2678 else |
2680 break; | 2679 break; |
2681 } | 2680 } |
2682 | 2681 |
2683 did_lock_scrolling_layer_ = true; | 2682 did_lock_scrolling_layer_ = true; |
2684 if (!allow_bubbling_for_current_layer) { | 2683 |
| 2684 // When scrolls are allowed to bubble, it's important that the original |
| 2685 // scrolling layer be preserved. This ensures that, after a scroll bubbles, |
| 2686 // the user can reverse scroll directions and immediately resume scrolling |
| 2687 // the original layer that scrolled. |
| 2688 if (!should_bubble_scrolls_) |
2685 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2689 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
| 2690 |
| 2691 if (!allow_bubbling_for_current_layer) |
2686 break; | 2692 break; |
2687 } | |
2688 | 2693 |
2689 if (allow_unrestricted_bubbling_for_current_layer) { | 2694 if (allow_unrestricted_bubbling_for_current_layer) { |
2690 pending_delta -= applied_delta; | 2695 pending_delta -= applied_delta; |
2691 } else { | 2696 } else { |
2692 // If the applied delta is within 45 degrees of the input delta, bail out | 2697 // If the applied delta is within 45 degrees of the input delta, bail out |
2693 // to make it easier to scroll just one layer in one direction without | 2698 // to make it easier to scroll just one layer in one direction without |
2694 // affecting any of its parents. | 2699 // affecting any of its parents. |
2695 float angle_threshold = 45; | 2700 float angle_threshold = 45; |
2696 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, pending_delta) < | 2701 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, pending_delta) < |
2697 angle_threshold) { | 2702 angle_threshold) { |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3015 for (size_t i = 0; i < layer_impl->children().size(); ++i) | 3020 for (size_t i = 0; i < layer_impl->children().size(); ++i) |
3016 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); | 3021 CollectScrollDeltas(scroll_info, layer_impl->children()[i]); |
3017 } | 3022 } |
3018 | 3023 |
3019 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { | 3024 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::ProcessScrollDeltas() { |
3020 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); | 3025 scoped_ptr<ScrollAndScaleSet> scroll_info(new ScrollAndScaleSet()); |
3021 | 3026 |
3022 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); | 3027 CollectScrollDeltas(scroll_info.get(), active_tree_->root_layer()); |
3023 scroll_info->page_scale_delta = | 3028 scroll_info->page_scale_delta = |
3024 active_tree_->page_scale_factor()->PullDeltaForMainThread(); | 3029 active_tree_->page_scale_factor()->PullDeltaForMainThread(); |
| 3030 scroll_info->elastic_overscroll_delta = |
| 3031 active_tree_->elastic_overscroll()->PullDeltaForMainThread(); |
3025 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); | 3032 scroll_info->swap_promises.swap(swap_promises_for_main_thread_scroll_update_); |
3026 scroll_info->top_controls_delta = active_tree()->top_controls_delta(); | 3033 scroll_info->top_controls_delta = active_tree()->top_controls_delta(); |
3027 active_tree_->set_sent_top_controls_delta(scroll_info->top_controls_delta); | 3034 active_tree_->set_sent_top_controls_delta(scroll_info->top_controls_delta); |
3028 | 3035 |
3029 return scroll_info.Pass(); | 3036 return scroll_info.Pass(); |
3030 } | 3037 } |
3031 | 3038 |
3032 void LayerTreeHostImpl::SetFullRootLayerDamage() { | 3039 void LayerTreeHostImpl::SetFullRootLayerDamage() { |
3033 SetViewportDamage(gfx::Rect(DrawViewportSize())); | 3040 SetViewportDamage(gfx::Rect(DrawViewportSize())); |
3034 } | 3041 } |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3477 } | 3484 } |
3478 | 3485 |
3479 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3486 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
3480 std::vector<PictureLayerImpl*>::iterator it = | 3487 std::vector<PictureLayerImpl*>::iterator it = |
3481 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3488 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
3482 DCHECK(it != picture_layers_.end()); | 3489 DCHECK(it != picture_layers_.end()); |
3483 picture_layers_.erase(it); | 3490 picture_layers_.erase(it); |
3484 } | 3491 } |
3485 | 3492 |
3486 } // namespace cc | 3493 } // namespace cc |
OLD | NEW |