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/debug/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" |
11 #include "cc/layers/heads_up_display_layer_impl.h" | 11 #include "cc/layers/heads_up_display_layer_impl.h" |
12 #include "cc/layers/layer.h" | 12 #include "cc/layers/layer.h" |
13 #include "cc/layers/layer_impl.h" | 13 #include "cc/layers/layer_impl.h" |
14 #include "cc/layers/layer_iterator.h" | 14 #include "cc/layers/layer_iterator.h" |
15 #include "cc/layers/render_surface.h" | 15 #include "cc/layers/render_surface.h" |
16 #include "cc/layers/render_surface_impl.h" | 16 #include "cc/layers/render_surface_impl.h" |
17 #include "cc/trees/draw_property_utils.h" | 17 #include "cc/trees/draw_property_utils.h" |
18 #include "cc/trees/layer_sorter.h" | 18 #include "cc/trees/layer_sorter.h" |
19 #include "cc/trees/layer_tree_host.h" | 19 #include "cc/trees/layer_tree_host.h" |
(...skipping 19 matching lines...) Expand all Loading... |
39 static void SortLayers(LayerImplList::iterator first, | 39 static void SortLayers(LayerImplList::iterator first, |
40 LayerImplList::iterator end, | 40 LayerImplList::iterator end, |
41 LayerSorter* layer_sorter) { | 41 LayerSorter* layer_sorter) { |
42 DCHECK(layer_sorter); | 42 DCHECK(layer_sorter); |
43 TRACE_EVENT0("cc", "LayerTreeHostCommon::SortLayers"); | 43 TRACE_EVENT0("cc", "LayerTreeHostCommon::SortLayers"); |
44 layer_sorter->Sort(first, end); | 44 layer_sorter->Sort(first, end); |
45 } | 45 } |
46 | 46 |
47 template <typename LayerType> | 47 template <typename LayerType> |
48 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) { | 48 static gfx::Vector2dF GetEffectiveScrollDelta(LayerType* layer) { |
49 gfx::Vector2dF scroll_delta = layer->ScrollDelta(); | 49 // Layer's scroll offset can have an integer part and fractional part. |
| 50 // Due to Blink's limitation, it only counter-scrolls the position-fixed |
| 51 // layer using the integer part of Layer's scroll offset. |
| 52 // CC scrolls the layer using the full scroll offset, so we have to |
| 53 // add the ScrollCompensationAdjustment (fractional part of the scroll |
| 54 // offset) to the effective scroll delta which is used to counter-scroll |
| 55 // the position-fixed layer. |
| 56 gfx::Vector2dF scroll_delta = |
| 57 layer->ScrollDelta() + layer->ScrollCompensationAdjustment(); |
50 // The scroll parent's scroll delta is the amount we've scrolled on the | 58 // The scroll parent's scroll delta is the amount we've scrolled on the |
51 // 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. |
52 // 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 |
53 // 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. |
54 if (layer->scroll_parent()) | 62 if (layer->scroll_parent()) |
55 scroll_delta += layer->scroll_parent()->ScrollDelta(); | 63 scroll_delta += layer->scroll_parent()->ScrollDelta() + |
| 64 layer->ScrollCompensationAdjustment(); |
56 return scroll_delta; | 65 return scroll_delta; |
57 } | 66 } |
58 | 67 |
59 template <typename LayerType> | 68 template <typename LayerType> |
60 static gfx::ScrollOffset GetEffectiveTotalScrollOffset(LayerType* layer) { | 69 static gfx::ScrollOffset GetEffectiveCurrentScrollOffset(LayerType* layer) { |
61 gfx::ScrollOffset offset = layer->TotalScrollOffset(); | 70 gfx::ScrollOffset offset = layer->CurrentScrollOffset(); |
62 // The scroll parent's total scroll offset (scroll offset + scroll delta) | 71 // The scroll parent's total scroll offset (scroll offset + scroll delta) |
63 // 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 |
64 // scroll children's positions by the main thread layer positioning code. | 73 // scroll children's positions by the main thread layer positioning code. |
65 if (layer->scroll_parent()) | 74 if (layer->scroll_parent()) |
66 offset += gfx::ScrollOffset(layer->scroll_parent()->ScrollDelta()); | 75 offset += gfx::ScrollOffset(layer->scroll_parent()->ScrollDelta()); |
67 return offset; | 76 return offset; |
68 } | 77 } |
69 | 78 |
70 inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( | 79 inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( |
71 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... |
1659 | 1668 |
1660 bool animating_transform_to_target = layer->TransformIsAnimating(); | 1669 bool animating_transform_to_target = layer->TransformIsAnimating(); |
1661 bool animating_transform_to_screen = animating_transform_to_target; | 1670 bool animating_transform_to_screen = animating_transform_to_target; |
1662 if (layer->parent()) { | 1671 if (layer->parent()) { |
1663 animating_transform_to_target |= | 1672 animating_transform_to_target |= |
1664 layer->parent()->draw_transform_is_animating(); | 1673 layer->parent()->draw_transform_is_animating(); |
1665 animating_transform_to_screen |= | 1674 animating_transform_to_screen |= |
1666 layer->parent()->screen_space_transform_is_animating(); | 1675 layer->parent()->screen_space_transform_is_animating(); |
1667 } | 1676 } |
1668 gfx::Point3F transform_origin = layer->transform_origin(); | 1677 gfx::Point3F transform_origin = layer->transform_origin(); |
1669 gfx::ScrollOffset scroll_offset = GetEffectiveTotalScrollOffset(layer); | 1678 gfx::ScrollOffset scroll_offset = GetEffectiveCurrentScrollOffset(layer); |
1670 gfx::PointF position = | 1679 gfx::PointF position = |
1671 layer->position() - ScrollOffsetToVector2dF(scroll_offset); | 1680 layer->position() - ScrollOffsetToVector2dF(scroll_offset); |
1672 gfx::Transform combined_transform = data_from_ancestor.parent_matrix; | 1681 gfx::Transform combined_transform = data_from_ancestor.parent_matrix; |
1673 if (!layer->transform().IsIdentity()) { | 1682 if (!layer->transform().IsIdentity()) { |
1674 // LT = Tr[origin] * Tr[origin2transformOrigin] | 1683 // LT = Tr[origin] * Tr[origin2transformOrigin] |
1675 combined_transform.Translate3d(position.x() + transform_origin.x(), | 1684 combined_transform.Translate3d(position.x() + transform_origin.x(), |
1676 position.y() + transform_origin.y(), | 1685 position.y() + transform_origin.y(), |
1677 transform_origin.z()); | 1686 transform_origin.z()); |
1678 // LT = Tr[origin] * Tr[origin2origin] * M[layer] | 1687 // LT = Tr[origin] * Tr[origin2origin] * M[layer] |
1679 combined_transform.PreconcatTransform(layer->transform()); | 1688 combined_transform.PreconcatTransform(layer->transform()); |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2564 inputs->current_render_surface_layer_list_id); | 2573 inputs->current_render_surface_layer_list_id); |
2565 | 2574 |
2566 // The dummy layer list should not have been used. | 2575 // The dummy layer list should not have been used. |
2567 DCHECK_EQ(0u, dummy_layer_list.size()); | 2576 DCHECK_EQ(0u, dummy_layer_list.size()); |
2568 // A root layer render_surface should always exist after | 2577 // A root layer render_surface should always exist after |
2569 // CalculateDrawProperties. | 2578 // CalculateDrawProperties. |
2570 DCHECK(inputs->root_layer->render_surface()); | 2579 DCHECK(inputs->root_layer->render_surface()); |
2571 } | 2580 } |
2572 | 2581 |
2573 } // namespace cc | 2582 } // namespace cc |
OLD | NEW |