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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD); | 147 bool scroll_on_main_thread = (scroll_thread == MAIN_THREAD); |
148 if (IsWheelBasedScroll(type)) { | 148 if (IsWheelBasedScroll(type)) { |
149 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread", | 149 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorWheelScrollUpdateThread", |
150 scroll_on_main_thread); | 150 scroll_on_main_thread); |
151 } else { | 151 } else { |
152 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread", | 152 UMA_HISTOGRAM_BOOLEAN("Renderer4.CompositorTouchScrollUpdateThread", |
153 scroll_on_main_thread); | 153 scroll_on_main_thread); |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
| 157 // Return true if scrollable 'ancestor' is the same layer as 'child' or its |
| 158 // ancestor along the scroll tree. |
| 159 bool IsScrolledBy(LayerImpl* child, LayerImpl* ancestor) { |
| 160 DCHECK(ancestor && ancestor->scrollable()); |
| 161 if (!child) |
| 162 return false; |
| 163 |
| 164 ScrollTree& scroll_tree = |
| 165 child->layer_tree_impl()->property_trees()->scroll_tree; |
| 166 for (ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); |
| 167 scroll_node; scroll_node = scroll_tree.parent(scroll_node)) { |
| 168 if (scroll_node->owner_id == ancestor->id()) |
| 169 return true; |
| 170 } |
| 171 return false; |
| 172 } |
| 173 |
157 } // namespace | 174 } // namespace |
158 | 175 |
159 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, | 176 DEFINE_SCOPED_UMA_HISTOGRAM_TIMER(PendingTreeDurationHistogramTimer, |
160 "Scheduling.%s.PendingTreeDuration"); | 177 "Scheduling.%s.PendingTreeDuration"); |
161 | 178 |
162 LayerTreeHostImpl::FrameData::FrameData() | 179 LayerTreeHostImpl::FrameData::FrameData() |
163 : render_surface_layer_list(nullptr), | 180 : render_surface_layer_list(nullptr), |
164 has_no_damage(false), | 181 has_no_damage(false), |
165 may_contain_video(false) {} | 182 may_contain_video(false) {} |
166 | 183 |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 591 } |
575 | 592 |
576 return false; | 593 return false; |
577 } | 594 } |
578 | 595 |
579 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( | 596 EventListenerProperties LayerTreeHostImpl::GetEventListenerProperties( |
580 EventListenerClass event_class) const { | 597 EventListenerClass event_class) const { |
581 return active_tree_->event_listener_properties(event_class); | 598 return active_tree_->event_listener_properties(event_class); |
582 } | 599 } |
583 | 600 |
584 bool LayerTreeHostImpl::DoTouchEventsBlockScrollAt( | 601 InputHandler::TouchStartEventListenerType |
| 602 LayerTreeHostImpl::EventListenerTypeForTouchStartAt( |
585 const gfx::Point& viewport_point) { | 603 const gfx::Point& viewport_point) { |
586 gfx::PointF device_viewport_point = gfx::ScalePoint( | 604 gfx::PointF device_viewport_point = gfx::ScalePoint( |
587 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 605 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
588 | 606 |
589 // Now determine if there are actually any handlers at that point. | 607 // Now determine if there are actually any handlers at that point. |
590 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). | 608 // TODO(rbyers): Consider also honoring touch-action (crbug.com/347272). |
591 LayerImpl* layer_impl = | 609 LayerImpl* layer_impl = |
592 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( | 610 active_tree_->FindLayerThatIsHitByPointInTouchHandlerRegion( |
593 device_viewport_point); | 611 device_viewport_point); |
594 return layer_impl != NULL; | 612 if (layer_impl == NULL) |
| 613 return InputHandler::TouchStartEventListenerType::NO_HANDLER; |
| 614 |
| 615 if (!CurrentlyScrollingLayer()) |
| 616 return InputHandler::TouchStartEventListenerType::HANDLER; |
| 617 |
| 618 bool is_ancestor = |
| 619 IsScrolledBy(layer_impl, active_tree_->CurrentlyScrollingLayer()); |
| 620 return is_ancestor ? InputHandler::TouchStartEventListenerType:: |
| 621 HANDLER_ON_SCROLLING_LAYER |
| 622 : InputHandler::TouchStartEventListenerType::HANDLER; |
595 } | 623 } |
596 | 624 |
597 std::unique_ptr<SwapPromiseMonitor> | 625 std::unique_ptr<SwapPromiseMonitor> |
598 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( | 626 LayerTreeHostImpl::CreateLatencyInfoSwapPromiseMonitor( |
599 ui::LatencyInfo* latency) { | 627 ui::LatencyInfo* latency) { |
600 return base::WrapUnique( | 628 return base::WrapUnique( |
601 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); | 629 new LatencyInfoSwapPromiseMonitor(latency, NULL, this)); |
602 } | 630 } |
603 | 631 |
604 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { | 632 ScrollElasticityHelper* LayerTreeHostImpl::CreateScrollElasticityHelper() { |
(...skipping 1933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2538 if (IsMainThreadScrolling(status, scroll_node)) { | 2566 if (IsMainThreadScrolling(status, scroll_node)) { |
2539 *scroll_on_main_thread = true; | 2567 *scroll_on_main_thread = true; |
2540 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; | 2568 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; |
2541 return NULL; | 2569 return NULL; |
2542 } | 2570 } |
2543 } | 2571 } |
2544 | 2572 |
2545 return potentially_scrolling_layer_impl; | 2573 return potentially_scrolling_layer_impl; |
2546 } | 2574 } |
2547 | 2575 |
2548 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. | 2576 static bool IsClosestScrollAncestor(LayerImpl* child, |
2549 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { | 2577 LayerImpl* scroll_ancestor) { |
2550 DCHECK(scroll_ancestor); | 2578 DCHECK(scroll_ancestor); |
2551 if (!child) | 2579 if (!child) |
2552 return false; | 2580 return false; |
2553 ScrollTree& scroll_tree = | 2581 ScrollTree& scroll_tree = |
2554 child->layer_tree_impl()->property_trees()->scroll_tree; | 2582 child->layer_tree_impl()->property_trees()->scroll_tree; |
2555 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); | 2583 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); |
2556 for (; scroll_tree.parent(scroll_node); | 2584 for (; scroll_tree.parent(scroll_node); |
2557 scroll_node = scroll_tree.parent(scroll_node)) { | 2585 scroll_node = scroll_tree.parent(scroll_node)) { |
2558 if (scroll_node->scrollable) | 2586 if (scroll_node->scrollable) |
2559 return scroll_node->owner_id == scroll_ancestor->id(); | 2587 return scroll_node->owner_id == scroll_ancestor->id(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2624 gfx::PointF device_viewport_point = gfx::ScalePoint( | 2652 gfx::PointF device_viewport_point = gfx::ScalePoint( |
2625 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); | 2653 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); |
2626 LayerImpl* layer_impl = | 2654 LayerImpl* layer_impl = |
2627 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); | 2655 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); |
2628 | 2656 |
2629 if (layer_impl) { | 2657 if (layer_impl) { |
2630 LayerImpl* scroll_layer_impl = | 2658 LayerImpl* scroll_layer_impl = |
2631 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( | 2659 active_tree_->FindFirstScrollingLayerOrScrollbarLayerThatIsHitByPoint( |
2632 device_viewport_point); | 2660 device_viewport_point); |
2633 if (scroll_layer_impl && | 2661 if (scroll_layer_impl && |
2634 !HasScrollAncestor(layer_impl, scroll_layer_impl)) { | 2662 !IsClosestScrollAncestor(layer_impl, scroll_layer_impl)) { |
2635 scroll_status.thread = SCROLL_UNKNOWN; | 2663 scroll_status.thread = SCROLL_UNKNOWN; |
2636 scroll_status.main_thread_scrolling_reasons = | 2664 scroll_status.main_thread_scrolling_reasons = |
2637 MainThreadScrollingReason::kFailedHitTest; | 2665 MainThreadScrollingReason::kFailedHitTest; |
2638 return scroll_status; | 2666 return scroll_status; |
2639 } | 2667 } |
2640 } | 2668 } |
2641 | 2669 |
2642 bool scroll_on_main_thread = false; | 2670 bool scroll_on_main_thread = false; |
2643 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( | 2671 LayerImpl* scrolling_layer_impl = FindScrollLayerForDeviceViewportPoint( |
2644 device_viewport_point, type, layer_impl, &scroll_on_main_thread, | 2672 device_viewport_point, type, layer_impl, &scroll_on_main_thread, |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4057 worker_context_visibility_ = | 4085 worker_context_visibility_ = |
4058 worker_context->CacheController()->ClientBecameVisible(); | 4086 worker_context->CacheController()->ClientBecameVisible(); |
4059 } else { | 4087 } else { |
4060 worker_context->CacheController()->ClientBecameNotVisible( | 4088 worker_context->CacheController()->ClientBecameNotVisible( |
4061 std::move(worker_context_visibility_)); | 4089 std::move(worker_context_visibility_)); |
4062 } | 4090 } |
4063 } | 4091 } |
4064 } | 4092 } |
4065 | 4093 |
4066 } // namespace cc | 4094 } // namespace cc |
OLD | NEW |