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