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/debug/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1644 } | 1644 } |
1645 | 1645 |
1646 bool animating_transform_to_target = layer->TransformIsAnimating(); | 1646 bool animating_transform_to_target = layer->TransformIsAnimating(); |
1647 bool animating_transform_to_screen = animating_transform_to_target; | 1647 bool animating_transform_to_screen = animating_transform_to_target; |
1648 if (layer->parent()) { | 1648 if (layer->parent()) { |
1649 animating_transform_to_target |= | 1649 animating_transform_to_target |= |
1650 layer->parent()->draw_transform_is_animating(); | 1650 layer->parent()->draw_transform_is_animating(); |
1651 animating_transform_to_screen |= | 1651 animating_transform_to_screen |= |
1652 layer->parent()->screen_space_transform_is_animating(); | 1652 layer->parent()->screen_space_transform_is_animating(); |
1653 } | 1653 } |
1654 | 1654 gfx::Point3F transform_origin = layer->transform_origin(); |
1655 gfx::Size bounds = layer->bounds(); | |
1656 gfx::PointF anchor_point = layer->anchor_point(); | |
1657 gfx::Vector2dF scroll_offset = GetEffectiveTotalScrollOffset(layer); | 1655 gfx::Vector2dF scroll_offset = GetEffectiveTotalScrollOffset(layer); |
1658 gfx::PointF position = layer->position() - scroll_offset; | 1656 gfx::PointF position = layer->position() - scroll_offset; |
1659 | |
1660 gfx::Transform combined_transform = data_from_ancestor.parent_matrix; | 1657 gfx::Transform combined_transform = data_from_ancestor.parent_matrix; |
1661 if (!layer->transform().IsIdentity()) { | 1658 if (!layer->transform().IsIdentity()) { |
1662 // LT = Tr[origin] * Tr[origin2anchor] | 1659 // LT = Tr[origin] * Tr[origin2transformOrigin] |
| 1660 combined_transform.Translate3d(position.x() + transform_origin.x(), |
| 1661 position.y() + transform_origin.y(), |
| 1662 transform_origin.z()); |
| 1663 // LT = Tr[origin] * Tr[origin2origin] * M[layer] |
| 1664 combined_transform.PreconcatTransform(layer->transform()); |
| 1665 // LT = Tr[origin] * Tr[origin2origin] * M[layer] * |
| 1666 // Tr[transformOrigin2origin] |
1663 combined_transform.Translate3d( | 1667 combined_transform.Translate3d( |
1664 position.x() + anchor_point.x() * bounds.width(), | 1668 -transform_origin.x(), -transform_origin.y(), -transform_origin.z()); |
1665 position.y() + anchor_point.y() * bounds.height(), | |
1666 layer->anchor_point_z()); | |
1667 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] | |
1668 combined_transform.PreconcatTransform(layer->transform()); | |
1669 // LT = Tr[origin] * Tr[origin2anchor] * M[layer] * Tr[anchor2origin] | |
1670 combined_transform.Translate3d(-anchor_point.x() * bounds.width(), | |
1671 -anchor_point.y() * bounds.height(), | |
1672 -layer->anchor_point_z()); | |
1673 } else { | 1669 } else { |
1674 combined_transform.Translate(position.x(), position.y()); | 1670 combined_transform.Translate(position.x(), position.y()); |
1675 } | 1671 } |
1676 | 1672 |
1677 gfx::Vector2dF effective_scroll_delta = GetEffectiveScrollDelta(layer); | 1673 gfx::Vector2dF effective_scroll_delta = GetEffectiveScrollDelta(layer); |
1678 if (!animating_transform_to_target && layer->scrollable() && | 1674 if (!animating_transform_to_target && layer->scrollable() && |
1679 combined_transform.IsScaleOrTranslation()) { | 1675 combined_transform.IsScaleOrTranslation()) { |
1680 // Align the scrollable layer's position to screen space pixels to avoid | 1676 // Align the scrollable layer's position to screen space pixels to avoid |
1681 // blurriness. To avoid side-effects, do this only if the transform is | 1677 // blurriness. To avoid side-effects, do this only if the transform is |
1682 // simple. | 1678 // simple. |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 layer->contents_scale_x() / render_surface_sublayer_scale.x(), | 2239 layer->contents_scale_x() / render_surface_sublayer_scale.x(), |
2244 layer->contents_scale_y() / render_surface_sublayer_scale.y()); | 2240 layer->contents_scale_y() / render_surface_sublayer_scale.y()); |
2245 render_surface->SetScreenSpaceTransform(screen_space_transform); | 2241 render_surface->SetScreenSpaceTransform(screen_space_transform); |
2246 | 2242 |
2247 if (layer->replica_layer()) { | 2243 if (layer->replica_layer()) { |
2248 gfx::Transform surface_origin_to_replica_origin_transform; | 2244 gfx::Transform surface_origin_to_replica_origin_transform; |
2249 surface_origin_to_replica_origin_transform.Scale( | 2245 surface_origin_to_replica_origin_transform.Scale( |
2250 render_surface_sublayer_scale.x(), render_surface_sublayer_scale.y()); | 2246 render_surface_sublayer_scale.x(), render_surface_sublayer_scale.y()); |
2251 surface_origin_to_replica_origin_transform.Translate( | 2247 surface_origin_to_replica_origin_transform.Translate( |
2252 layer->replica_layer()->position().x() + | 2248 layer->replica_layer()->position().x() + |
2253 layer->replica_layer()->anchor_point().x() * bounds.width(), | 2249 layer->replica_layer()->transform_origin().x(), |
2254 layer->replica_layer()->position().y() + | 2250 layer->replica_layer()->position().y() + |
2255 layer->replica_layer()->anchor_point().y() * bounds.height()); | 2251 layer->replica_layer()->transform_origin().y()); |
2256 surface_origin_to_replica_origin_transform.PreconcatTransform( | 2252 surface_origin_to_replica_origin_transform.PreconcatTransform( |
2257 layer->replica_layer()->transform()); | 2253 layer->replica_layer()->transform()); |
2258 surface_origin_to_replica_origin_transform.Translate( | 2254 surface_origin_to_replica_origin_transform.Translate( |
2259 -layer->replica_layer()->anchor_point().x() * bounds.width(), | 2255 -layer->replica_layer()->transform_origin().x(), |
2260 -layer->replica_layer()->anchor_point().y() * bounds.height()); | 2256 -layer->replica_layer()->transform_origin().y()); |
2261 surface_origin_to_replica_origin_transform.Scale( | 2257 surface_origin_to_replica_origin_transform.Scale( |
2262 1.0 / render_surface_sublayer_scale.x(), | 2258 1.0 / render_surface_sublayer_scale.x(), |
2263 1.0 / render_surface_sublayer_scale.y()); | 2259 1.0 / render_surface_sublayer_scale.y()); |
2264 | 2260 |
2265 // Compute the replica's "originTransform" that maps from the replica's | 2261 // Compute the replica's "originTransform" that maps from the replica's |
2266 // origin space to the target surface origin space. | 2262 // origin space to the target surface origin space. |
2267 gfx::Transform replica_origin_transform = | 2263 gfx::Transform replica_origin_transform = |
2268 layer->render_surface()->draw_transform() * | 2264 layer->render_surface()->draw_transform() * |
2269 surface_origin_to_replica_origin_transform; | 2265 surface_origin_to_replica_origin_transform; |
2270 render_surface->SetReplicaDrawTransform(replica_origin_transform); | 2266 render_surface->SetReplicaDrawTransform(replica_origin_transform); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2411 inputs->current_render_surface_layer_list_id); | 2407 inputs->current_render_surface_layer_list_id); |
2412 | 2408 |
2413 // The dummy layer list should not have been used. | 2409 // The dummy layer list should not have been used. |
2414 DCHECK_EQ(0u, dummy_layer_list.size()); | 2410 DCHECK_EQ(0u, dummy_layer_list.size()); |
2415 // A root layer render_surface should always exist after | 2411 // A root layer render_surface should always exist after |
2416 // CalculateDrawProperties. | 2412 // CalculateDrawProperties. |
2417 DCHECK(inputs->root_layer->render_surface()); | 2413 DCHECK(inputs->root_layer->render_surface()); |
2418 } | 2414 } |
2419 | 2415 |
2420 } // namespace cc | 2416 } // namespace cc |
OLD | NEW |