Chromium Code Reviews| 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> |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD); | 148 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD); |
| 149 if (IsWheelBasedScroll(type)) { | 149 if (IsWheelBasedScroll(type)) { |
| 150 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread", | 150 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread", |
| 151 scroll_on_main_thread); | 151 scroll_on_main_thread); |
| 152 } else { | 152 } else { |
| 153 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread", | 153 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread", |
| 154 scroll_on_main_thread); | 154 scroll_on_main_thread); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 // Return true if scroll_ancestor is same as child or its ancestor. | |
| 159 bool isAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { | |
|
bokan
2016/11/11 20:41:53
Lets replace HasScrollAncestor with this function.
| |
| 160 DCHECK(scroll_ancestor); | |
| 161 if (!child) | |
| 162 return false; | |
| 163 if (child->id() == scroll_ancestor->id()) | |
| 164 return true; | |
| 165 ScrollTree& scroll_tree = | |
| 166 child->layer_tree_impl()->property_trees()->scroll_tree; | |
| 167 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); | |
|
bokan
2016/11/11 20:41:53
Put this the for loop initializer below:
for(Scro
lanwei
2016/11/12 02:17:15
Done.
| |
| 168 for (; scroll_tree.parent(scroll_node); | |
|
bokan
2016/11/11 20:41:53
This is still only looping if we have a parent whi
lanwei
2016/11/12 02:17:15
Done.
| |
| 169 scroll_node = scroll_tree.parent(scroll_node)) { | |
| 170 if (scroll_node->owner_id == scroll_ancestor->id()) | |
| 171 return true; | |
| 172 } | |
| 173 return false; | |
| 174 } | |
| 175 | |
| 158 } // namespace | 176 } // namespace |
| 159 | 177 |
| 160 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, | 178 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, |
| 161 "Scheduling.%s.PendingTreeDuration"); | 179 "Scheduling.%s.PendingTreeDuration"); |
| 162 | 180 |
| 163 LayerTreeHostImpl::FrameData::FrameData() | 181 LayerTreeHostImpl::FrameData::FrameData() |
| 164 : render_surface_layer_list(nullptr), | 182 : render_surface_layer_list(nullptr), |
| 165 has_no_damage(false), | 183 has_no_damage(false), |
| 166 may_contain_video(false) {} | 184 may_contain_video(false) {} |
| 167 | 185 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 } | 593 } |
| 576 | 594 |
| 577 return false; | 595 return false; |
| 578 } | 596 } |
| 579 | 597 |
| 580 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( | 598 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( |
| 581 EventListenerClass event_class) const { | 599 EventListenerClass event_class) const { |
| 582 return active_tree_->event_listener_properties(event_class); | 600 return active_tree_->event_listener_properties(event_class); |
| 583 } | 601 } |
| 584 | 602 |
| 585 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( | 603 EventListenerProperties LayerTreeHostImpl::DoTouchHandlersBlockScrollAt( |
| 586 const gfx::Point& viewport_point) { | 604 const gfx::Point& viewport_point) { |
| 587 gfx::PointF device_viewport_point = gfx::ScalePoint( | 605 gfx::PointF device_viewport_point = gfx::ScalePoint( |
| 588 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 606 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
| 589 | 607 |
| 590 // Now determine if there are actually any handlers at that point. | 608 // Now determine if there are actually any handlers at that point. |
| 591 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). | 609 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
| 592 LayerImpl* layer_impl = | 610 LayerImpl* layer_impl = |
| 593 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 611 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
| 594 device_viewport_point); | 612 device_viewport_point); |
| 595 return layer_impl != NULL; | 613 if (layer_impl == NULL) |
| 614 return EventListenerProperties::kNone; | |
| 615 | |
| 616 if (!CurrentlyScrollingLayer()) | |
| 617 return EventListenerProperties::kBlocking; | |
| 618 | |
| 619 bool is_ancestor = | |
| 620 isAncestor(layer_impl, active_tree_->CurrentlyScrollingLayer()); | |
| 621 return is_ancestor ? EventListenerProperties::kBlockingAndPassiveDueToFling | |
| 622 : EventListenerProperties::kBlocking; | |
| 596 } | 623 } |
| 597 | 624 |
| 598 std::unique_ptr<SwapPromiseMonitor> | 625 std::unique_ptr<SwapPromiseMonitor> |
| 599 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 626 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
| 600 ui::LatencyInfo* latency) { | 627 ui::LatencyInfo* latency) { |
| 601 return base::WrapUnique( | 628 return base::WrapUnique( |
| 602 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 629 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
| 603 } | 630 } |
| 604 | 631 |
| 605 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { | 632 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { |
| (...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2676 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( | 2703 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( |
| 2677 device_viewport_point, type, layer_impl, &scroll_on_main_thread, | 2704 device_viewport_point, type, layer_impl, &scroll_on_main_thread, |
| 2678 &scroll_status.main_thread_scrolling_reasons); | 2705 &scroll_status.main_thread_scrolling_reasons); |
| 2679 | 2706 |
| 2680 if (scrolling_layer_impl) | 2707 if (scrolling_layer_impl) |
| 2681 scroll_affects_scroll_handler_ = | 2708 scroll_affects_scroll_handler_ = |
| 2682 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers(); | 2709 scrolling_layer_impl->layer_tree_impl()->have_scroll_event_handlers(); |
| 2683 | 2710 |
| 2684 if (scroll_on_main_thread) { | 2711 if (scroll_on_main_thread) { |
| 2685 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); | 2712 RecordCompositorSlowScrollMetric(type, MAIN_THREAD); |
| 2686 | |
| 2687 scroll_status.thread = SCROLL_ON_MAIN_THREAD; | 2713 scroll_status.thread = SCROLL_ON_MAIN_THREAD; |
| 2688 return scroll_status; | 2714 return scroll_status; |
| 2689 } | 2715 } |
| 2690 | 2716 |
| 2691 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type); | 2717 return ScrollBeginImpl(scroll_state, scrolling_layer_impl, type); |
| 2692 } | 2718 } |
| 2693 | 2719 |
| 2694 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin( | 2720 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimatedBegin( |
| 2695 const gfx::Point& viewport_point) { | 2721 const gfx::Point& viewport_point) { |
| 2696 InputHandler::ScrollStatus scroll_status; | 2722 InputHandler::ScrollStatus scroll_status; |
| (...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4085 if (is_visible) { | 4111 if (is_visible) { |
| 4086 worker_context_visibility_ = | 4112 worker_context_visibility_ = |
| 4087 worker_context->CacheController()->ClientBecameVisible(); | 4113 worker_context->CacheController()->ClientBecameVisible(); |
| 4088 } else { | 4114 } else { |
| 4089 worker_context->CacheController()->ClientBecameNotVisible( | 4115 worker_context->CacheController()->ClientBecameNotVisible( |
| 4090 std::move(worker_context_visibility_)); | 4116 std::move(worker_context_visibility_)); |
| 4091 } | 4117 } |
| 4092 } | 4118 } |
| 4093 | 4119 |
| 4094 } // namespace cc | 4120 } // namespace cc |
| OLD | NEW |