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_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // compositor thread since the commit for this layer tree's source frame. | 59 // compositor thread since the commit for this layer tree's source frame. |
60 // we last reported to the main thread. I.e., it's the discrepancy between | 60 // we last reported to the main thread. I.e., it's the discrepancy between |
61 // a scroll parent's scroll delta and offset, so we must add it here. | 61 // a scroll parent's scroll delta and offset, so we must add it here. |
62 if (layer->scroll_parent()) | 62 if (layer->scroll_parent()) |
63 scroll_delta += layer->scroll_parent()->ScrollDelta() + | 63 scroll_delta += layer->scroll_parent()->ScrollDelta() + |
64 layer->ScrollCompensationAdjustment(); | 64 layer->ScrollCompensationAdjustment(); |
65 return scroll_delta; | 65 return scroll_delta; |
66 } | 66 } |
67 | 67 |
68 template <typename LayerType> | 68 template <typename LayerType> |
69 static gfx::ScrollOffset GetEffectiveTotalScrollOffset(LayerType* layer) { | 69 static gfx::ScrollOffset GetEffectiveCurrentScrollOffset(LayerType* layer) { |
70 gfx::ScrollOffset offset = layer->TotalScrollOffset(); | 70 gfx::ScrollOffset offset = layer->CurrentScrollOffset(); |
71 // The scroll parent's total scroll offset (scroll offset + scroll delta) | 71 // The scroll parent's total scroll offset (scroll offset + scroll delta) |
72 // can't be used because its scroll offset has already been applied to the | 72 // can't be used because its scroll offset has already been applied to the |
73 // scroll children's positions by the main thread layer positioning code. | 73 // scroll children's positions by the main thread layer positioning code. |
74 if (layer->scroll_parent()) | 74 if (layer->scroll_parent()) |
75 offset += gfx::ScrollOffset(layer->scroll_parent()->ScrollDelta()); | 75 offset += gfx::ScrollOffset(layer->scroll_parent()->ScrollDelta()); |
76 return offset; | 76 return offset; |
77 } | 77 } |
78 | 78 |
79 inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( | 79 inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( |
80 const gfx::Rect& target_surface_rect, | 80 const gfx::Rect& target_surface_rect, |
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 | 1668 |
1669 bool animating_transform_to_target = layer->TransformIsAnimating(); | 1669 bool animating_transform_to_target = layer->TransformIsAnimating(); |
1670 bool animating_transform_to_screen = animating_transform_to_target; | 1670 bool animating_transform_to_screen = animating_transform_to_target; |
1671 if (layer->parent()) { | 1671 if (layer->parent()) { |
1672 animating_transform_to_target |= | 1672 animating_transform_to_target |= |
1673 layer->parent()->draw_transform_is_animating(); | 1673 layer->parent()->draw_transform_is_animating(); |
1674 animating_transform_to_screen |= | 1674 animating_transform_to_screen |= |
1675 layer->parent()->screen_space_transform_is_animating(); | 1675 layer->parent()->screen_space_transform_is_animating(); |
1676 } | 1676 } |
1677 gfx::Point3F transform_origin = layer->transform_origin(); | 1677 gfx::Point3F transform_origin = layer->transform_origin(); |
1678 gfx::ScrollOffset scroll_offset = GetEffectiveTotalScrollOffset(layer); | 1678 gfx::ScrollOffset scroll_offset = GetEffectiveCurrentScrollOffset(layer); |
1679 gfx::PointF position = | 1679 gfx::PointF position = |
1680 layer->position() - ScrollOffsetToVector2dF(scroll_offset); | 1680 layer->position() - ScrollOffsetToVector2dF(scroll_offset); |
1681 gfx::Transform combined_transform = data_from_ancestor.parent_matrix; | 1681 gfx::Transform combined_transform = data_from_ancestor.parent_matrix; |
1682 if (!layer->transform().IsIdentity()) { | 1682 if (!layer->transform().IsIdentity()) { |
1683 // LT = Tr[origin] * Tr[origin2transformOrigin] | 1683 // LT = Tr[origin] * Tr[origin2transformOrigin] |
1684 combined_transform.Translate3d(position.x() + transform_origin.x(), | 1684 combined_transform.Translate3d(position.x() + transform_origin.x(), |
1685 position.y() + transform_origin.y(), | 1685 position.y() + transform_origin.y(), |
1686 transform_origin.z()); | 1686 transform_origin.z()); |
1687 // LT = Tr[origin] * Tr[origin2origin] * M[layer] | 1687 // LT = Tr[origin] * Tr[origin2origin] * M[layer] |
1688 combined_transform.PreconcatTransform(layer->transform()); | 1688 combined_transform.PreconcatTransform(layer->transform()); |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 inputs->current_render_surface_layer_list_id); | 2573 inputs->current_render_surface_layer_list_id); |
2574 | 2574 |
2575 // The dummy layer list should not have been used. | 2575 // The dummy layer list should not have been used. |
2576 DCHECK_EQ(0u, dummy_layer_list.size()); | 2576 DCHECK_EQ(0u, dummy_layer_list.size()); |
2577 // A root layer render_surface should always exist after | 2577 // A root layer render_surface should always exist after |
2578 // CalculateDrawProperties. | 2578 // CalculateDrawProperties. |
2579 DCHECK(inputs->root_layer->render_surface()); | 2579 DCHECK(inputs->root_layer->render_surface()); |
2580 } | 2580 } |
2581 | 2581 |
2582 } // namespace cc | 2582 } // namespace cc |
OLD | NEW |