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

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

Issue 584503005: Make scroll offset type of float in cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: link crbug to TODO Created 6 years, 2 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
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.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_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // The scroll parent's scroll delta is the amount we've scrolled on the 45 // The scroll parent's scroll delta is the amount we've scrolled on the
46 // compositor thread since the commit for this layer tree's source frame. 46 // compositor thread since the commit for this layer tree's source frame.
47 // we last reported to the main thread. I.e., it's the discrepancy between 47 // we last reported to the main thread. I.e., it's the discrepancy between
48 // a scroll parent's scroll delta and offset, so we must add it here. 48 // a scroll parent's scroll delta and offset, so we must add it here.
49 if (layer->scroll_parent()) 49 if (layer->scroll_parent())
50 scroll_delta += layer->scroll_parent()->ScrollDelta(); 50 scroll_delta += layer->scroll_parent()->ScrollDelta();
51 return scroll_delta; 51 return scroll_delta;
52 } 52 }
53 53
54 template <typename LayerType> 54 template <typename LayerType>
55 static gfx::Vector2dF GetEffectiveTotalScrollOffset(LayerType* layer) { 55 static gfx::ScrollOffset GetEffectiveTotalScrollOffset(LayerType* layer) {
56 gfx::Vector2dF offset = layer->TotalScrollOffset(); 56 gfx::ScrollOffset offset = layer->TotalScrollOffset();
57 // The scroll parent's total scroll offset (scroll offset + scroll delta) 57 // The scroll parent's total scroll offset (scroll offset + scroll delta)
58 // can't be used because its scroll offset has already been applied to the 58 // can't be used because its scroll offset has already been applied to the
59 // scroll children's positions by the main thread layer positioning code. 59 // scroll children's positions by the main thread layer positioning code.
60 if (layer->scroll_parent()) 60 if (layer->scroll_parent())
61 offset += layer->scroll_parent()->ScrollDelta(); 61 offset += gfx::ScrollOffset(layer->scroll_parent()->ScrollDelta());
62 return offset; 62 return offset;
63 } 63 }
64 64
65 inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( 65 inline gfx::Rect CalculateVisibleRectWithCachedLayerRect(
66 const gfx::Rect& target_surface_rect, 66 const gfx::Rect& target_surface_rect,
67 const gfx::Rect& layer_bound_rect, 67 const gfx::Rect& layer_bound_rect,
68 const gfx::Rect& layer_rect_in_target_space, 68 const gfx::Rect& layer_rect_in_target_space,
69 const gfx::Transform& transform) { 69 const gfx::Transform& transform) {
70 if (layer_rect_in_target_space.IsEmpty()) 70 if (layer_rect_in_target_space.IsEmpty())
71 return gfx::Rect(); 71 return gfx::Rect();
(...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 1638
1639 bool animating_transform_to_target = layer->TransformIsAnimating(); 1639 bool animating_transform_to_target = layer->TransformIsAnimating();
1640 bool animating_transform_to_screen = animating_transform_to_target; 1640 bool animating_transform_to_screen = animating_transform_to_target;
1641 if (layer->parent()) { 1641 if (layer->parent()) {
1642 animating_transform_to_target |= 1642 animating_transform_to_target |=
1643 layer->parent()->draw_transform_is_animating(); 1643 layer->parent()->draw_transform_is_animating();
1644 animating_transform_to_screen |= 1644 animating_transform_to_screen |=
1645 layer->parent()->screen_space_transform_is_animating(); 1645 layer->parent()->screen_space_transform_is_animating();
1646 } 1646 }
1647 gfx::Point3F transform_origin = layer->transform_origin(); 1647 gfx::Point3F transform_origin = layer->transform_origin();
1648 gfx::Vector2dF scroll_offset = GetEffectiveTotalScrollOffset(layer); 1648 gfx::ScrollOffset scroll_offset = GetEffectiveTotalScrollOffset(layer);
1649 gfx::PointF position = layer->position() - scroll_offset; 1649 gfx::PointF position =
1650 layer->position() - ScrollOffsetToVector2dF(scroll_offset);
1650 gfx::Transform combined_transform = data_from_ancestor.parent_matrix; 1651 gfx::Transform combined_transform = data_from_ancestor.parent_matrix;
1651 if (!layer->transform().IsIdentity()) { 1652 if (!layer->transform().IsIdentity()) {
1652 // LT = Tr[origin] * Tr[origin2transformOrigin] 1653 // LT = Tr[origin] * Tr[origin2transformOrigin]
1653 combined_transform.Translate3d(position.x() + transform_origin.x(), 1654 combined_transform.Translate3d(position.x() + transform_origin.x(),
1654 position.y() + transform_origin.y(), 1655 position.y() + transform_origin.y(),
1655 transform_origin.z()); 1656 transform_origin.z());
1656 // LT = Tr[origin] * Tr[origin2origin] * M[layer] 1657 // LT = Tr[origin] * Tr[origin2origin] * M[layer]
1657 combined_transform.PreconcatTransform(layer->transform()); 1658 combined_transform.PreconcatTransform(layer->transform());
1658 // LT = Tr[origin] * Tr[origin2origin] * M[layer] * 1659 // LT = Tr[origin] * Tr[origin2origin] * M[layer] *
1659 // Tr[transformOrigin2origin] 1660 // Tr[transformOrigin2origin]
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 inputs->current_render_surface_layer_list_id); 2437 inputs->current_render_surface_layer_list_id);
2437 2438
2438 // The dummy layer list should not have been used. 2439 // The dummy layer list should not have been used.
2439 DCHECK_EQ(0u, dummy_layer_list.size()); 2440 DCHECK_EQ(0u, dummy_layer_list.size());
2440 // A root layer render_surface should always exist after 2441 // A root layer render_surface should always exist after
2441 // CalculateDrawProperties. 2442 // CalculateDrawProperties.
2442 DCHECK(inputs->root_layer->render_surface()); 2443 DCHECK(inputs->root_layer->render_surface());
2443 } 2444 }
2444 2445
2445 } // namespace cc 2446 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698