Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 2118993002: Detemplatize cc property nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #include "cc/tiles/picture_layer_tiling.h" 75 #include "cc/tiles/picture_layer_tiling.h"
76 #include "cc/tiles/raster_tile_priority_queue.h" 76 #include "cc/tiles/raster_tile_priority_queue.h"
77 #include "cc/tiles/software_image_decode_controller.h" 77 #include "cc/tiles/software_image_decode_controller.h"
78 #include "cc/tiles/tile_task_manager.h" 78 #include "cc/tiles/tile_task_manager.h"
79 #include "cc/trees/damage_tracker.h" 79 #include "cc/trees/damage_tracker.h"
80 #include "cc/trees/draw_property_utils.h" 80 #include "cc/trees/draw_property_utils.h"
81 #include "cc/trees/latency_info_swap_promise_monitor.h" 81 #include "cc/trees/latency_info_swap_promise_monitor.h"
82 #include "cc/trees/layer_tree_host.h" 82 #include "cc/trees/layer_tree_host.h"
83 #include "cc/trees/layer_tree_host_common.h" 83 #include "cc/trees/layer_tree_host_common.h"
84 #include "cc/trees/layer_tree_impl.h" 84 #include "cc/trees/layer_tree_impl.h"
85 #include "cc/trees/scroll_node.h"
85 #include "cc/trees/single_thread_proxy.h" 86 #include "cc/trees/single_thread_proxy.h"
86 #include "cc/trees/tree_synchronizer.h" 87 #include "cc/trees/tree_synchronizer.h"
87 #include "gpu/GLES2/gl2extchromium.h" 88 #include "gpu/GLES2/gl2extchromium.h"
88 #include "gpu/command_buffer/client/gles2_interface.h" 89 #include "gpu/command_buffer/client/gles2_interface.h"
89 #include "ui/gfx/geometry/point_conversions.h" 90 #include "ui/gfx/geometry/point_conversions.h"
90 #include "ui/gfx/geometry/rect_conversions.h" 91 #include "ui/gfx/geometry/rect_conversions.h"
91 #include "ui/gfx/geometry/scroll_offset.h" 92 #include "ui/gfx/geometry/scroll_offset.h"
92 #include "ui/gfx/geometry/size_conversions.h" 93 #include "ui/gfx/geometry/size_conversions.h"
93 #include "ui/gfx/geometry/vector2d_conversions.h" 94 #include "ui/gfx/geometry/vector2d_conversions.h"
94 95
(...skipping 2368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2463 } 2464 }
2464 2465
2465 InputHandler::ScrollStatus LayerTreeHostImpl::TryScroll( 2466 InputHandler::ScrollStatus LayerTreeHostImpl::TryScroll(
2466 const gfx::PointF& screen_space_point, 2467 const gfx::PointF& screen_space_point,
2467 InputHandler::ScrollInputType type, 2468 InputHandler::ScrollInputType type,
2468 const ScrollTree& scroll_tree, 2469 const ScrollTree& scroll_tree,
2469 ScrollNode* scroll_node) const { 2470 ScrollNode* scroll_node) const {
2470 InputHandler::ScrollStatus scroll_status; 2471 InputHandler::ScrollStatus scroll_status;
2471 scroll_status.main_thread_scrolling_reasons = 2472 scroll_status.main_thread_scrolling_reasons =
2472 MainThreadScrollingReason::kNotScrollingOnMain; 2473 MainThreadScrollingReason::kNotScrollingOnMain;
2473 if (!!scroll_node->data.main_thread_scrolling_reasons) { 2474 if (!!scroll_node->main_thread_scrolling_reasons) {
2474 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); 2475 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread");
2475 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; 2476 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD;
2476 scroll_status.main_thread_scrolling_reasons = 2477 scroll_status.main_thread_scrolling_reasons =
2477 scroll_node->data.main_thread_scrolling_reasons; 2478 scroll_node->main_thread_scrolling_reasons;
2478 return scroll_status; 2479 return scroll_status;
2479 } 2480 }
2480 2481
2481 gfx::Transform screen_space_transform = 2482 gfx::Transform screen_space_transform =
2482 scroll_tree.ScreenSpaceTransform(scroll_node->id); 2483 scroll_tree.ScreenSpaceTransform(scroll_node->id);
2483 if (!screen_space_transform.IsInvertible()) { 2484 if (!screen_space_transform.IsInvertible()) {
2484 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); 2485 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform");
2485 scroll_status.thread = InputHandler::SCROLL_IGNORED; 2486 scroll_status.thread = InputHandler::SCROLL_IGNORED;
2486 scroll_status.main_thread_scrolling_reasons = 2487 scroll_status.main_thread_scrolling_reasons =
2487 MainThreadScrollingReason::kNonInvertibleTransform; 2488 MainThreadScrollingReason::kNonInvertibleTransform;
2488 return scroll_status; 2489 return scroll_status;
2489 } 2490 }
2490 2491
2491 if (scroll_node->data.contains_non_fast_scrollable_region) { 2492 if (scroll_node->contains_non_fast_scrollable_region) {
2492 bool clipped = false; 2493 bool clipped = false;
2493 gfx::Transform inverse_screen_space_transform( 2494 gfx::Transform inverse_screen_space_transform(
2494 gfx::Transform::kSkipInitialization); 2495 gfx::Transform::kSkipInitialization);
2495 if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) { 2496 if (!screen_space_transform.GetInverse(&inverse_screen_space_transform)) {
2496 // TODO(shawnsingh): We shouldn't be applying a projection if screen space 2497 // TODO(shawnsingh): We shouldn't be applying a projection if screen space
2497 // transform is uninvertible here. Perhaps we should be returning 2498 // transform is uninvertible here. Perhaps we should be returning
2498 // SCROLL_ON_MAIN_THREAD in this case? 2499 // SCROLL_ON_MAIN_THREAD in this case?
2499 } 2500 }
2500 2501
2501 gfx::PointF hit_test_point_in_layer_space = MathUtil::ProjectPoint( 2502 gfx::PointF hit_test_point_in_layer_space = MathUtil::ProjectPoint(
2502 inverse_screen_space_transform, screen_space_point, &clipped); 2503 inverse_screen_space_transform, screen_space_point, &clipped);
2503 if (!clipped && 2504 if (!clipped &&
2504 active_tree() 2505 active_tree()
2505 ->LayerById(scroll_node->owner_id) 2506 ->LayerById(scroll_node->owner_id)
2506 ->non_fast_scrollable_region() 2507 ->non_fast_scrollable_region()
2507 .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) { 2508 .Contains(gfx::ToRoundedPoint(hit_test_point_in_layer_space))) {
2508 TRACE_EVENT0("cc", 2509 TRACE_EVENT0("cc",
2509 "LayerImpl::tryScroll: Failed NonFastScrollableRegion"); 2510 "LayerImpl::tryScroll: Failed NonFastScrollableRegion");
2510 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD; 2511 scroll_status.thread = InputHandler::SCROLL_ON_MAIN_THREAD;
2511 scroll_status.main_thread_scrolling_reasons = 2512 scroll_status.main_thread_scrolling_reasons =
2512 MainThreadScrollingReason::kNonFastScrollableRegion; 2513 MainThreadScrollingReason::kNonFastScrollableRegion;
2513 return scroll_status; 2514 return scroll_status;
2514 } 2515 }
2515 } 2516 }
2516 2517
2517 if (!scroll_node->data.scrollable) { 2518 if (!scroll_node->scrollable) {
2518 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable"); 2519 TRACE_EVENT0("cc", "LayerImpl::tryScroll: Ignored not scrollable");
2519 scroll_status.thread = InputHandler::SCROLL_IGNORED; 2520 scroll_status.thread = InputHandler::SCROLL_IGNORED;
2520 scroll_status.main_thread_scrolling_reasons = 2521 scroll_status.main_thread_scrolling_reasons =
2521 MainThreadScrollingReason::kNotScrollable; 2522 MainThreadScrollingReason::kNotScrollable;
2522 return scroll_status; 2523 return scroll_status;
2523 } 2524 }
2524 2525
2525 gfx::ScrollOffset max_scroll_offset = 2526 gfx::ScrollOffset max_scroll_offset =
2526 scroll_tree.MaxScrollOffset(scroll_node->id); 2527 scroll_tree.MaxScrollOffset(scroll_node->id);
2527 if (max_scroll_offset.x() <= 0 && max_scroll_offset.y() <= 0) { 2528 if (max_scroll_offset.x() <= 0 && max_scroll_offset.y() <= 0) {
(...skipping 26 matching lines...) Expand all
2554 if (layer_impl) { 2555 if (layer_impl) {
2555 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 2556 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
2556 ScrollNode* scroll_node = scroll_tree.Node(layer_impl->scroll_tree_index()); 2557 ScrollNode* scroll_node = scroll_tree.Node(layer_impl->scroll_tree_index());
2557 for (; scroll_tree.parent(scroll_node); 2558 for (; scroll_tree.parent(scroll_node);
2558 scroll_node = scroll_tree.parent(scroll_node)) { 2559 scroll_node = scroll_tree.parent(scroll_node)) {
2559 // The content layer can also block attempts to scroll outside the main 2560 // The content layer can also block attempts to scroll outside the main
2560 // thread. 2561 // thread.
2561 ScrollStatus status = 2562 ScrollStatus status =
2562 TryScroll(device_viewport_point, type, scroll_tree, scroll_node); 2563 TryScroll(device_viewport_point, type, scroll_tree, scroll_node);
2563 if (status.thread == SCROLL_ON_MAIN_THREAD) { 2564 if (status.thread == SCROLL_ON_MAIN_THREAD) {
2564 if (!!scroll_node->data.main_thread_scrolling_reasons) { 2565 if (!!scroll_node->main_thread_scrolling_reasons) {
2565 DCHECK(MainThreadScrollingReason::MainThreadCanSetScrollReasons( 2566 DCHECK(MainThreadScrollingReason::MainThreadCanSetScrollReasons(
2566 status.main_thread_scrolling_reasons)); 2567 status.main_thread_scrolling_reasons));
2567 } else { 2568 } else {
2568 DCHECK(MainThreadScrollingReason::CompositorCanSetScrollReasons( 2569 DCHECK(MainThreadScrollingReason::CompositorCanSetScrollReasons(
2569 status.main_thread_scrolling_reasons)); 2570 status.main_thread_scrolling_reasons));
2570 } 2571 }
2571 2572
2572 *scroll_on_main_thread = true; 2573 *scroll_on_main_thread = true;
2573 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons; 2574 *main_thread_scrolling_reasons = status.main_thread_scrolling_reasons;
2574 return NULL; 2575 return NULL;
(...skipping 23 matching lines...) Expand all
2598 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents. 2599 // Similar to LayerImpl::HasAncestor, but walks up the scroll parents.
2599 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) { 2600 static bool HasScrollAncestor(LayerImpl* child, LayerImpl* scroll_ancestor) {
2600 DCHECK(scroll_ancestor); 2601 DCHECK(scroll_ancestor);
2601 if (!child) 2602 if (!child)
2602 return false; 2603 return false;
2603 ScrollTree& scroll_tree = 2604 ScrollTree& scroll_tree =
2604 child->layer_tree_impl()->property_trees()->scroll_tree; 2605 child->layer_tree_impl()->property_trees()->scroll_tree;
2605 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index()); 2606 ScrollNode* scroll_node = scroll_tree.Node(child->scroll_tree_index());
2606 for (; scroll_tree.parent(scroll_node); 2607 for (; scroll_tree.parent(scroll_node);
2607 scroll_node = scroll_tree.parent(scroll_node)) { 2608 scroll_node = scroll_tree.parent(scroll_node)) {
2608 if (scroll_node->data.scrollable) 2609 if (scroll_node->scrollable)
2609 return scroll_node->owner_id == scroll_ancestor->id(); 2610 return scroll_node->owner_id == scroll_ancestor->id();
2610 } 2611 }
2611 return false; 2612 return false;
2612 } 2613 }
2613 2614
2614 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl( 2615 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollBeginImpl(
2615 ScrollState* scroll_state, 2616 ScrollState* scroll_state,
2616 LayerImpl* scrolling_layer_impl, 2617 LayerImpl* scrolling_layer_impl,
2617 InputHandler::ScrollInputType type) { 2618 InputHandler::ScrollInputType type) {
2618 DCHECK(scroll_state); 2619 DCHECK(scroll_state);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2748 } 2749 }
2749 2750
2750 gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta( 2751 gfx::Vector2dF LayerTreeHostImpl::ComputeScrollDelta(
2751 ScrollNode* scroll_node, 2752 ScrollNode* scroll_node,
2752 const gfx::Vector2dF& delta) { 2753 const gfx::Vector2dF& delta) {
2753 ScrollTree& scroll_tree = active_tree()->property_trees()->scroll_tree; 2754 ScrollTree& scroll_tree = active_tree()->property_trees()->scroll_tree;
2754 float scale_factor = active_tree()->current_page_scale_factor(); 2755 float scale_factor = active_tree()->current_page_scale_factor();
2755 2756
2756 gfx::Vector2dF adjusted_scroll(delta); 2757 gfx::Vector2dF adjusted_scroll(delta);
2757 adjusted_scroll.Scale(1.f / scale_factor); 2758 adjusted_scroll.Scale(1.f / scale_factor);
2758 if (!scroll_node->data.user_scrollable_horizontal) 2759 if (!scroll_node->user_scrollable_horizontal)
2759 adjusted_scroll.set_x(0); 2760 adjusted_scroll.set_x(0);
2760 if (!scroll_node->data.user_scrollable_vertical) 2761 if (!scroll_node->user_scrollable_vertical)
2761 adjusted_scroll.set_y(0); 2762 adjusted_scroll.set_y(0);
2762 2763
2763 gfx::ScrollOffset old_offset = 2764 gfx::ScrollOffset old_offset =
2764 scroll_tree.current_scroll_offset(scroll_node->owner_id); 2765 scroll_tree.current_scroll_offset(scroll_node->owner_id);
2765 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits( 2766 gfx::ScrollOffset new_offset = scroll_tree.ClampScrollOffsetToLimits(
2766 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node); 2767 old_offset + gfx::ScrollOffset(adjusted_scroll), scroll_node);
2767 2768
2768 gfx::ScrollOffset scrolled = new_offset - old_offset; 2769 gfx::ScrollOffset scrolled = new_offset - old_offset;
2769 return gfx::Vector2dF(scrolled.x(), scrolled.y()); 2770 return gfx::Vector2dF(scrolled.x(), scrolled.y());
2770 } 2771 }
(...skipping 11 matching lines...) Expand all
2782 } 2783 }
2783 2784
2784 scroll_tree.set_currently_scrolling_node(scroll_node->id); 2785 scroll_tree.set_currently_scrolling_node(scroll_node->id);
2785 2786
2786 gfx::ScrollOffset current_offset = 2787 gfx::ScrollOffset current_offset =
2787 scroll_tree.current_scroll_offset(scroll_node->owner_id); 2788 scroll_tree.current_scroll_offset(scroll_node->owner_id);
2788 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits( 2789 gfx::ScrollOffset target_offset = scroll_tree.ClampScrollOffsetToLimits(
2789 current_offset + gfx::ScrollOffset(delta), scroll_node); 2790 current_offset + gfx::ScrollOffset(delta), scroll_node);
2790 DCHECK_EQ( 2791 DCHECK_EQ(
2791 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), 2792 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()),
2792 scroll_node->data.element_id); 2793 scroll_node->element_id);
2793 2794
2794 animation_host_->ImplOnlyScrollAnimationCreate(scroll_node->data.element_id, 2795 animation_host_->ImplOnlyScrollAnimationCreate(scroll_node->element_id,
2795 target_offset, current_offset); 2796 target_offset, current_offset);
2796 2797
2797 SetNeedsOneBeginImplFrame(); 2798 SetNeedsOneBeginImplFrame();
2798 2799
2799 return true; 2800 return true;
2800 } 2801 }
2801 2802
2802 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( 2803 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated(
2803 const gfx::Point& viewport_point, 2804 const gfx::Point& viewport_point,
2804 const gfx::Vector2dF& scroll_delta) { 2805 const gfx::Vector2dF& scroll_delta) {
2805 InputHandler::ScrollStatus scroll_status; 2806 InputHandler::ScrollStatus scroll_status;
2806 scroll_status.main_thread_scrolling_reasons = 2807 scroll_status.main_thread_scrolling_reasons =
2807 MainThreadScrollingReason::kNotScrollingOnMain; 2808 MainThreadScrollingReason::kNotScrollingOnMain;
2808 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 2809 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
2809 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); 2810 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
2810 if (scroll_node) { 2811 if (scroll_node) {
2811 gfx::Vector2dF delta = scroll_delta; 2812 gfx::Vector2dF delta = scroll_delta;
2812 if (!scroll_node->data.user_scrollable_horizontal) 2813 if (!scroll_node->user_scrollable_horizontal)
2813 delta.set_x(0); 2814 delta.set_x(0);
2814 if (!scroll_node->data.user_scrollable_vertical) 2815 if (!scroll_node->user_scrollable_vertical)
2815 delta.set_y(0); 2816 delta.set_y(0);
2816 2817
2817 if (ScrollAnimationUpdateTarget(scroll_node, delta)) { 2818 if (ScrollAnimationUpdateTarget(scroll_node, delta)) {
2818 scroll_status.thread = SCROLL_ON_IMPL_THREAD; 2819 scroll_status.thread = SCROLL_ON_IMPL_THREAD;
2819 } else { 2820 } else {
2820 scroll_status.thread = SCROLL_IGNORED; 2821 scroll_status.thread = SCROLL_IGNORED;
2821 scroll_status.main_thread_scrolling_reasons = 2822 scroll_status.main_thread_scrolling_reasons =
2822 MainThreadScrollingReason::kNotScrollable; 2823 MainThreadScrollingReason::kNotScrollable;
2823 } 2824 }
2824 return scroll_status; 2825 return scroll_status;
2825 } 2826 }
2826 2827
2827 ScrollStateData scroll_state_data; 2828 ScrollStateData scroll_state_data;
2828 scroll_state_data.position_x = viewport_point.x(); 2829 scroll_state_data.position_x = viewport_point.x();
2829 scroll_state_data.position_y = viewport_point.y(); 2830 scroll_state_data.position_y = viewport_point.y();
2830 scroll_state_data.is_in_inertial_phase = true; 2831 scroll_state_data.is_in_inertial_phase = true;
2831 ScrollState scroll_state(scroll_state_data); 2832 ScrollState scroll_state(scroll_state_data);
2832 2833
2833 // ScrollAnimated is used for animated wheel scrolls. We find the first layer 2834 // ScrollAnimated is used for animated wheel scrolls. We find the first layer
2834 // that can scroll and set up an animation of its scroll offset. Note that 2835 // that can scroll and set up an animation of its scroll offset. Note that
2835 // this does not currently go through the scroll customization machinery 2836 // this does not currently go through the scroll customization machinery
2836 // that ScrollBy uses for non-animated wheel scrolls. 2837 // that ScrollBy uses for non-animated wheel scrolls.
2837 scroll_status = ScrollBegin(&scroll_state, WHEEL); 2838 scroll_status = ScrollBegin(&scroll_state, WHEEL);
2838 scroll_node = scroll_tree.CurrentlyScrollingNode(); 2839 scroll_node = scroll_tree.CurrentlyScrollingNode();
2839 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) { 2840 if (scroll_status.thread == SCROLL_ON_IMPL_THREAD) {
2840 gfx::Vector2dF pending_delta = scroll_delta; 2841 gfx::Vector2dF pending_delta = scroll_delta;
2841 if (scroll_node) { 2842 if (scroll_node) {
2842 for (; scroll_tree.parent(scroll_node); 2843 for (; scroll_tree.parent(scroll_node);
2843 scroll_node = scroll_tree.parent(scroll_node)) { 2844 scroll_node = scroll_tree.parent(scroll_node)) {
2844 if (!scroll_node->data.scrollable || 2845 if (!scroll_node->scrollable ||
2845 scroll_node->data.is_outer_viewport_scroll_layer) 2846 scroll_node->is_outer_viewport_scroll_layer)
2846 continue; 2847 continue;
2847 2848
2848 if (scroll_node->data.is_inner_viewport_scroll_layer) { 2849 if (scroll_node->is_inner_viewport_scroll_layer) {
2849 gfx::Vector2dF scrolled = viewport()->ScrollAnimated(pending_delta); 2850 gfx::Vector2dF scrolled = viewport()->ScrollAnimated(pending_delta);
2850 // Viewport::ScrollAnimated returns pending_delta as long as it 2851 // Viewport::ScrollAnimated returns pending_delta as long as it
2851 // starts an animation. 2852 // starts an animation.
2852 if (scrolled == pending_delta) 2853 if (scrolled == pending_delta)
2853 return scroll_status; 2854 return scroll_status;
2854 pending_delta -= scrolled; 2855 pending_delta -= scrolled;
2855 continue; 2856 continue;
2856 } 2857 }
2857 2858
2858 gfx::Vector2dF scroll_delta = 2859 gfx::Vector2dF scroll_delta =
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2988 ScrollState* scroll_state) { 2989 ScrollState* scroll_state) {
2989 DCHECK(scroll_state); 2990 DCHECK(scroll_state);
2990 gfx::Point viewport_point(scroll_state->position_x(), 2991 gfx::Point viewport_point(scroll_state->position_x(),
2991 scroll_state->position_y()); 2992 scroll_state->position_y());
2992 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y()); 2993 const gfx::Vector2dF delta(scroll_state->delta_x(), scroll_state->delta_y());
2993 gfx::Vector2dF applied_delta; 2994 gfx::Vector2dF applied_delta;
2994 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for 2995 // TODO(tdresser): Use a more rational epsilon. See crbug.com/510550 for
2995 // details. 2996 // details.
2996 const float kEpsilon = 0.1f; 2997 const float kEpsilon = 0.1f;
2997 2998
2998 if (scroll_node->data.is_inner_viewport_scroll_layer) { 2999 if (scroll_node->is_inner_viewport_scroll_layer) {
2999 bool affect_top_controls = !wheel_scrolling_; 3000 bool affect_top_controls = !wheel_scrolling_;
3000 Viewport::ScrollResult result = viewport()->ScrollBy( 3001 Viewport::ScrollResult result = viewport()->ScrollBy(
3001 delta, viewport_point, scroll_state->is_direct_manipulation(), 3002 delta, viewport_point, scroll_state->is_direct_manipulation(),
3002 affect_top_controls); 3003 affect_top_controls);
3003 applied_delta = result.consumed_delta; 3004 applied_delta = result.consumed_delta;
3004 scroll_state->set_caused_scroll( 3005 scroll_state->set_caused_scroll(
3005 std::abs(result.content_scrolled_delta.x()) > kEpsilon, 3006 std::abs(result.content_scrolled_delta.x()) > kEpsilon,
3006 std::abs(result.content_scrolled_delta.y()) > kEpsilon); 3007 std::abs(result.content_scrolled_delta.y()) > kEpsilon);
3007 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y()); 3008 scroll_state->ConsumeDelta(applied_delta.x(), applied_delta.y());
3008 } else { 3009 } else {
3009 applied_delta = ScrollSingleNode( 3010 applied_delta = ScrollSingleNode(
3010 scroll_node, delta, viewport_point, 3011 scroll_node, delta, viewport_point,
3011 scroll_state->is_direct_manipulation(), 3012 scroll_state->is_direct_manipulation(),
3012 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree); 3013 &scroll_state->layer_tree_impl()->property_trees()->scroll_tree);
3013 } 3014 }
3014 3015
3015 // If the layer wasn't able to move, try the next one in the hierarchy. 3016 // If the layer wasn't able to move, try the next one in the hierarchy.
3016 bool scrolled = std::abs(applied_delta.x()) > kEpsilon; 3017 bool scrolled = std::abs(applied_delta.x()) > kEpsilon;
3017 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon; 3018 scrolled = scrolled || std::abs(applied_delta.y()) > kEpsilon;
3018 3019
3019 if (scrolled && !scroll_node->data.is_inner_viewport_scroll_layer) { 3020 if (scrolled && !scroll_node->is_inner_viewport_scroll_layer) {
3020 // If the applied delta is within 45 degrees of the input 3021 // If the applied delta is within 45 degrees of the input
3021 // delta, bail out to make it easier to scroll just one layer 3022 // delta, bail out to make it easier to scroll just one layer
3022 // in one direction without affecting any of its parents. 3023 // in one direction without affecting any of its parents.
3023 float angle_threshold = 45; 3024 float angle_threshold = 45;
3024 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) < 3025 if (MathUtil::SmallestAngleBetweenVectors(applied_delta, delta) <
3025 angle_threshold) { 3026 angle_threshold) {
3026 applied_delta = delta; 3027 applied_delta = delta;
3027 } else { 3028 } else {
3028 // Allow further movement only on an axis perpendicular to the direction 3029 // Allow further movement only on an axis perpendicular to the direction
3029 // in which the layer moved. 3030 // in which the layer moved.
(...skipping 17 matching lines...) Expand all
3047 // crbug.com/526462) 3048 // crbug.com/526462)
3048 std::list<const ScrollNode*> current_scroll_chain; 3049 std::list<const ScrollNode*> current_scroll_chain;
3049 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 3050 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
3050 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); 3051 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
3051 if (scroll_node) { 3052 if (scroll_node) {
3052 for (; scroll_tree.parent(scroll_node); 3053 for (; scroll_tree.parent(scroll_node);
3053 scroll_node = scroll_tree.parent(scroll_node)) { 3054 scroll_node = scroll_tree.parent(scroll_node)) {
3054 // Skip the outer viewport scroll layer so that we try to scroll the 3055 // Skip the outer viewport scroll layer so that we try to scroll the
3055 // viewport only once. i.e. The inner viewport layer represents the 3056 // viewport only once. i.e. The inner viewport layer represents the
3056 // viewport. 3057 // viewport.
3057 if (!scroll_node->data.scrollable || 3058 if (!scroll_node->scrollable ||
3058 scroll_node->data.is_outer_viewport_scroll_layer) 3059 scroll_node->is_outer_viewport_scroll_layer)
3059 continue; 3060 continue;
3060 current_scroll_chain.push_front(scroll_node); 3061 current_scroll_chain.push_front(scroll_node);
3061 } 3062 }
3062 } 3063 }
3063 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain, 3064 scroll_state->set_scroll_chain_and_layer_tree(current_scroll_chain,
3064 active_tree()); 3065 active_tree());
3065 scroll_state->DistributeToScrollChainDescendant(); 3066 scroll_state->DistributeToScrollChainDescendant();
3066 } 3067 }
3067 3068
3068 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy( 3069 InputHandlerScrollResult LayerTreeHostImpl::ScrollBy(
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3148 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point, 3149 bool LayerTreeHostImpl::ScrollVerticallyByPage(const gfx::Point& viewport_point,
3149 ScrollDirection direction) { 3150 ScrollDirection direction) {
3150 DCHECK(wheel_scrolling_); 3151 DCHECK(wheel_scrolling_);
3151 3152
3152 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree; 3153 ScrollTree& scroll_tree = active_tree_->property_trees()->scroll_tree;
3153 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode(); 3154 ScrollNode* scroll_node = scroll_tree.CurrentlyScrollingNode();
3154 if (scroll_node) { 3155 if (scroll_node) {
3155 for (; scroll_tree.parent(scroll_node); 3156 for (; scroll_tree.parent(scroll_node);
3156 scroll_node = scroll_tree.parent(scroll_node)) { 3157 scroll_node = scroll_tree.parent(scroll_node)) {
3157 // The inner viewport layer represents the viewport. 3158 // The inner viewport layer represents the viewport.
3158 if (!scroll_node->data.scrollable || 3159 if (!scroll_node->scrollable ||
3159 scroll_node->data.is_outer_viewport_scroll_layer) 3160 scroll_node->is_outer_viewport_scroll_layer)
3160 continue; 3161 continue;
3161 3162
3162 float height = 3163 float height =
3163 scroll_tree.scroll_clip_layer_bounds(scroll_node->id).height(); 3164 scroll_tree.scroll_clip_layer_bounds(scroll_node->id).height();
3164 3165
3165 // These magical values match WebKit and are designed to scroll nearly the 3166 // These magical values match WebKit and are designed to scroll nearly the
3166 // entire visible content height but leave a bit of overlap. 3167 // entire visible content height but leave a bit of overlap.
3167 float page = std::max(height * 0.875f, 1.f); 3168 float page = std::max(height * 0.875f, 1.f);
3168 if (direction == SCROLL_BACKWARD) 3169 if (direction == SCROLL_BACKWARD)
3169 page = -page; 3170 page = -page;
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
3805 3806
3806 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) { 3807 void LayerTreeHostImpl::ScrollAnimationAbort(LayerImpl* layer_impl) {
3807 return animation_host_->ScrollAnimationAbort(false /* needs_completion */); 3808 return animation_host_->ScrollAnimationAbort(false /* needs_completion */);
3808 } 3809 }
3809 3810
3810 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget( 3811 bool LayerTreeHostImpl::ScrollAnimationUpdateTarget(
3811 ScrollNode* scroll_node, 3812 ScrollNode* scroll_node,
3812 const gfx::Vector2dF& scroll_delta) { 3813 const gfx::Vector2dF& scroll_delta) {
3813 DCHECK_EQ( 3814 DCHECK_EQ(
3814 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()), 3815 ElementId(active_tree()->LayerById(scroll_node->owner_id)->element_id()),
3815 scroll_node->data.element_id); 3816 scroll_node->element_id);
3816 3817
3817 return animation_host_->ImplOnlyScrollAnimationUpdateTarget( 3818 return animation_host_->ImplOnlyScrollAnimationUpdateTarget(
3818 scroll_node->data.element_id, scroll_delta, 3819 scroll_node->element_id, scroll_delta,
3819 active_tree_->property_trees()->scroll_tree.MaxScrollOffset( 3820 active_tree_->property_trees()->scroll_tree.MaxScrollOffset(
3820 scroll_node->id), 3821 scroll_node->id),
3821 CurrentBeginFrameArgs().frame_time); 3822 CurrentBeginFrameArgs().frame_time);
3822 } 3823 }
3823 3824
3824 bool LayerTreeHostImpl::IsElementInList(ElementId element_id, 3825 bool LayerTreeHostImpl::IsElementInList(ElementId element_id,
3825 ElementListType list_type) const { 3826 ElementListType list_type) const {
3826 if (list_type == ElementListType::ACTIVE) { 3827 if (list_type == ElementListType::ACTIVE) {
3827 return active_tree() 3828 return active_tree()
3828 ? active_tree()->LayerByElementId(element_id) != nullptr 3829 ? active_tree()->LayerByElementId(element_id) != nullptr
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
4018 return task_runner_provider_->HasImplThread(); 4019 return task_runner_provider_->HasImplThread();
4019 } 4020 }
4020 4021
4021 bool LayerTreeHostImpl::CommitToActiveTree() const { 4022 bool LayerTreeHostImpl::CommitToActiveTree() const {
4022 // In single threaded mode we skip the pending tree and commit directly to the 4023 // In single threaded mode we skip the pending tree and commit directly to the
4023 // active tree. 4024 // active tree.
4024 return !task_runner_provider_->HasImplThread(); 4025 return !task_runner_provider_->HasImplThread();
4025 } 4026 }
4026 4027
4027 } // namespace cc 4028 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698