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

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

Issue 1457803003: cc:: Don't use cached screen space transform for layers not in RSLL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 #include "cc/raster/tile_task_worker_pool.h" 61 #include "cc/raster/tile_task_worker_pool.h"
62 #include "cc/raster/zero_copy_tile_task_worker_pool.h" 62 #include "cc/raster/zero_copy_tile_task_worker_pool.h"
63 #include "cc/resources/memory_history.h" 63 #include "cc/resources/memory_history.h"
64 #include "cc/resources/resource_pool.h" 64 #include "cc/resources/resource_pool.h"
65 #include "cc/resources/ui_resource_bitmap.h" 65 #include "cc/resources/ui_resource_bitmap.h"
66 #include "cc/scheduler/delay_based_time_source.h" 66 #include "cc/scheduler/delay_based_time_source.h"
67 #include "cc/tiles/eviction_tile_priority_queue.h" 67 #include "cc/tiles/eviction_tile_priority_queue.h"
68 #include "cc/tiles/picture_layer_tiling.h" 68 #include "cc/tiles/picture_layer_tiling.h"
69 #include "cc/tiles/raster_tile_priority_queue.h" 69 #include "cc/tiles/raster_tile_priority_queue.h"
70 #include "cc/trees/damage_tracker.h" 70 #include "cc/trees/damage_tracker.h"
71 #include "cc/trees/draw_property_utils.h"
71 #include "cc/trees/latency_info_swap_promise_monitor.h" 72 #include "cc/trees/latency_info_swap_promise_monitor.h"
72 #include "cc/trees/layer_tree_host.h" 73 #include "cc/trees/layer_tree_host.h"
73 #include "cc/trees/layer_tree_host_common.h" 74 #include "cc/trees/layer_tree_host_common.h"
74 #include "cc/trees/layer_tree_impl.h" 75 #include "cc/trees/layer_tree_impl.h"
75 #include "cc/trees/single_thread_proxy.h" 76 #include "cc/trees/single_thread_proxy.h"
76 #include "cc/trees/tree_synchronizer.h" 77 #include "cc/trees/tree_synchronizer.h"
77 #include "gpu/GLES2/gl2extchromium.h" 78 #include "gpu/GLES2/gl2extchromium.h"
78 #include "gpu/command_buffer/client/gles2_interface.h" 79 #include "gpu/command_buffer/client/gles2_interface.h"
79 #include "ui/gfx/geometry/rect_conversions.h" 80 #include "ui/gfx/geometry/rect_conversions.h"
80 #include "ui/gfx/geometry/scroll_offset.h" 81 #include "ui/gfx/geometry/scroll_offset.h"
(...skipping 2487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 ScrollAnimationCreate(layer_impl, target_offset, current_offset); 2569 ScrollAnimationCreate(layer_impl, target_offset, current_offset);
2569 2570
2570 SetNeedsAnimate(); 2571 SetNeedsAnimate();
2571 return SCROLL_STARTED; 2572 return SCROLL_STARTED;
2572 } 2573 }
2573 } 2574 }
2574 ScrollEnd(); 2575 ScrollEnd();
2575 return scroll_status; 2576 return scroll_status;
2576 } 2577 }
2577 2578
2579 const gfx::Transform LayerTreeHostImpl::LayerScreenSpaceTransform(
2580 const LayerImpl* layer) {
2581 const bool is_active_tree = layer->layer_tree_impl() == active_tree();
2582 LayerTreeImpl* layer_tree_impl =
2583 is_active_tree ? active_tree() : pending_tree();
2584 DCHECK(layer_tree_impl);
2585 const bool use_property_trees =
2586 layer_tree_impl->settings().use_property_trees ||
2587 layer_tree_impl->settings().verify_property_trees;
ajuma 2015/11/18 23:03:42 You can use settings_ here, no need to go through
jaydasika 2015/11/19 01:10:10 Done.
2588 if (!use_property_trees)
2589 return layer->screen_space_transform();
2590 return layer->IsDrawnRenderSurfaceLayerListMember()
2591 ? layer->screen_space_transform()
2592 : ScreenSpaceTransformFromPropertyTrees(
2593 layer, layer_tree_impl->property_trees()->transform_tree);
2594 }
2595
2578 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( 2596 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta(
2579 LayerImpl* layer_impl, 2597 LayerImpl* layer_impl,
2580 const gfx::PointF& viewport_point, 2598 const gfx::PointF& viewport_point,
2581 const gfx::Vector2dF& viewport_delta) { 2599 const gfx::Vector2dF& viewport_delta) {
2582 // Layers with non-invertible screen space transforms should not have passed 2600 // Layers with non-invertible screen space transforms should not have passed
2583 // the scroll hit test in the first place. 2601 // the scroll hit test in the first place.
2584 DCHECK(layer_impl->screen_space_transform().IsInvertible()); 2602 const gfx::Transform screen_space_transform =
2603 LayerScreenSpaceTransform(layer_impl);
2604 DCHECK(screen_space_transform.IsInvertible());
2585 gfx::Transform inverse_screen_space_transform( 2605 gfx::Transform inverse_screen_space_transform(
2586 gfx::Transform::kSkipInitialization); 2606 gfx::Transform::kSkipInitialization);
2587 bool did_invert = layer_impl->screen_space_transform().GetInverse( 2607 bool did_invert =
2588 &inverse_screen_space_transform); 2608 screen_space_transform.GetInverse(&inverse_screen_space_transform);
2589 // TODO(shawnsingh): With the advent of impl-side scrolling for non-root 2609 // TODO(shawnsingh): With the advent of impl-side scrolling for non-root
2590 // layers, we may need to explicitly handle uninvertible transforms here. 2610 // layers, we may need to explicitly handle uninvertible transforms here.
2591 DCHECK(did_invert); 2611 DCHECK(did_invert);
2592 2612
2593 float scale_from_viewport_to_screen_space = 2613 float scale_from_viewport_to_screen_space =
2594 active_tree_->device_scale_factor(); 2614 active_tree_->device_scale_factor();
2595 gfx::PointF screen_space_point = 2615 gfx::PointF screen_space_point =
2596 gfx::ScalePoint(viewport_point, scale_from_viewport_to_screen_space); 2616 gfx::ScalePoint(viewport_point, scale_from_viewport_to_screen_space);
2597 2617
2598 gfx::Vector2dF screen_space_delta = viewport_delta; 2618 gfx::Vector2dF screen_space_delta = viewport_delta;
(...skipping 23 matching lines...) Expand all
2622 layer_impl->ScrollBy(local_end_point - local_start_point); 2642 layer_impl->ScrollBy(local_end_point - local_start_point);
2623 gfx::ScrollOffset scrolled = 2643 gfx::ScrollOffset scrolled =
2624 layer_impl->CurrentScrollOffset() - previous_offset; 2644 layer_impl->CurrentScrollOffset() - previous_offset;
2625 2645
2626 // Get the end point in the layer's content space so we can apply its 2646 // Get the end point in the layer's content space so we can apply its
2627 // ScreenSpaceTransform. 2647 // ScreenSpaceTransform.
2628 gfx::PointF actual_local_end_point = 2648 gfx::PointF actual_local_end_point =
2629 local_start_point + gfx::Vector2dF(scrolled.x(), scrolled.y()); 2649 local_start_point + gfx::Vector2dF(scrolled.x(), scrolled.y());
2630 2650
2631 // Calculate the applied scroll delta in viewport space coordinates. 2651 // Calculate the applied scroll delta in viewport space coordinates.
2632 gfx::PointF actual_screen_space_end_point = 2652 gfx::PointF actual_screen_space_end_point = MathUtil::MapPoint(
2633 MathUtil::MapPoint(layer_impl->screen_space_transform(), 2653 screen_space_transform, actual_local_end_point, &end_clipped);
2634 actual_local_end_point, &end_clipped);
2635 DCHECK(!end_clipped); 2654 DCHECK(!end_clipped);
2636 if (end_clipped) 2655 if (end_clipped)
2637 return gfx::Vector2dF(); 2656 return gfx::Vector2dF();
2638 gfx::PointF actual_viewport_end_point = 2657 gfx::PointF actual_viewport_end_point =
2639 gfx::ScalePoint(actual_screen_space_end_point, 2658 gfx::ScalePoint(actual_screen_space_end_point,
2640 1.f / scale_from_viewport_to_screen_space); 2659 1.f / scale_from_viewport_to_screen_space);
2641 return actual_viewport_end_point - viewport_point; 2660 return actual_viewport_end_point - viewport_point;
2642 } 2661 }
2643 2662
2644 static gfx::Vector2dF ScrollLayerWithLocalDelta( 2663 static gfx::Vector2dF ScrollLayerWithLocalDelta(
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 2909
2891 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer( 2910 float LayerTreeHostImpl::DeviceSpaceDistanceToLayer(
2892 const gfx::PointF& device_viewport_point, 2911 const gfx::PointF& device_viewport_point,
2893 LayerImpl* layer_impl) { 2912 LayerImpl* layer_impl) {
2894 if (!layer_impl) 2913 if (!layer_impl)
2895 return std::numeric_limits<float>::max(); 2914 return std::numeric_limits<float>::max();
2896 2915
2897 gfx::Rect layer_impl_bounds(layer_impl->bounds()); 2916 gfx::Rect layer_impl_bounds(layer_impl->bounds());
2898 2917
2899 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect( 2918 gfx::RectF device_viewport_layer_impl_bounds = MathUtil::MapClippedRect(
2900 layer_impl->screen_space_transform(), gfx::RectF(layer_impl_bounds)); 2919 LayerScreenSpaceTransform(layer_impl), gfx::RectF(layer_impl_bounds));
2901 2920
2902 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint( 2921 return device_viewport_layer_impl_bounds.ManhattanDistanceToPoint(
2903 device_viewport_point); 2922 device_viewport_point);
2904 } 2923 }
2905 2924
2906 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) { 2925 void LayerTreeHostImpl::MouseMoveAt(const gfx::Point& viewport_point) {
2907 gfx::PointF device_viewport_point = gfx::ScalePoint( 2926 gfx::PointF device_viewport_point = gfx::ScalePoint(
2908 gfx::PointF(viewport_point), active_tree_->device_scale_factor()); 2927 gfx::PointF(viewport_point), active_tree_->device_scale_factor());
2909 LayerImpl* layer_impl = 2928 LayerImpl* layer_impl =
2910 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point); 2929 active_tree_->FindLayerThatIsHitByPoint(device_viewport_point);
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
3697 return task_runner_provider_->HasImplThread(); 3716 return task_runner_provider_->HasImplThread();
3698 } 3717 }
3699 3718
3700 bool LayerTreeHostImpl::CommitToActiveTree() const { 3719 bool LayerTreeHostImpl::CommitToActiveTree() const {
3701 // In single threaded mode we skip the pending tree and commit directly to the 3720 // In single threaded mode we skip the pending tree and commit directly to the
3702 // active tree. 3721 // active tree.
3703 return !task_runner_provider_->HasImplThread(); 3722 return !task_runner_provider_->HasImplThread();
3704 } 3723 }
3705 3724
3706 } // namespace cc 3725 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698