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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (target_surface_rect.Contains(layer_rect_in_target_space)) | 74 if (target_surface_rect.Contains(layer_rect_in_target_space)) |
75 return layer_bound_rect; | 75 return layer_bound_rect; |
76 | 76 |
77 // If the layer doesn't fill up the entire surface, then find the part of | 77 // If the layer doesn't fill up the entire surface, then find the part of |
78 // the surface rect where the layer could be visible. This avoids trying to | 78 // the surface rect where the layer could be visible. This avoids trying to |
79 // project surface rect points that are behind the projection point. | 79 // project surface rect points that are behind the projection point. |
80 gfx::Rect minimal_surface_rect = target_surface_rect; | 80 gfx::Rect minimal_surface_rect = target_surface_rect; |
81 minimal_surface_rect.Intersect(layer_rect_in_target_space); | 81 minimal_surface_rect.Intersect(layer_rect_in_target_space); |
82 | 82 |
83 if (minimal_surface_rect.IsEmpty()) | 83 if (minimal_surface_rect.IsEmpty()) |
84 return gfx::Rect(); | 84 return gfx::Rect(); |
85 | 85 |
86 // Project the corners of the target surface rect into the layer space. | 86 // Project the corners of the target surface rect into the layer space. |
87 // This bounding rectangle may be larger than it needs to be (being | 87 // This bounding rectangle may be larger than it needs to be (being |
88 // axis-aligned), but is a reasonable filter on the space to consider. | 88 // axis-aligned), but is a reasonable filter on the space to consider. |
89 // Non-invertible transforms will create an empty rect here. | 89 // Non-invertible transforms will create an empty rect here. |
90 | 90 |
91 gfx::Transform surface_to_layer(gfx::Transform::kSkipInitialization); | 91 gfx::Transform surface_to_layer(gfx::Transform::kSkipInitialization); |
92 if (!transform.GetInverse(&surface_to_layer)) { | 92 if (!transform.GetInverse(&surface_to_layer)) { |
93 // Because we cannot use the surface bounds to determine what portion of | 93 // Because we cannot use the surface bounds to determine what portion of |
94 // the layer is visible, we must conservatively assume the full layer is | 94 // the layer is visible, we must conservatively assume the full layer is |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 } | 912 } |
913 next_scroll_compensation_matrix = | 913 next_scroll_compensation_matrix = |
914 inverse_surface_draw_transform * next_scroll_compensation_matrix * | 914 inverse_surface_draw_transform * next_scroll_compensation_matrix * |
915 layer->render_surface()->draw_transform(); | 915 layer->render_surface()->draw_transform(); |
916 } | 916 } |
917 | 917 |
918 return next_scroll_compensation_matrix; | 918 return next_scroll_compensation_matrix; |
919 } | 919 } |
920 | 920 |
921 template <typename LayerType> | 921 template <typename LayerType> |
| 922 static inline void UpdateLayerScaleDrawProperties( |
| 923 LayerType* layer, |
| 924 float ideal_contents_scale, |
| 925 float maximum_animation_contents_scale, |
| 926 float page_scale_factor, |
| 927 float device_scale_factor) { |
| 928 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; |
| 929 layer->draw_properties().maximum_animation_contents_scale = |
| 930 maximum_animation_contents_scale; |
| 931 layer->draw_properties().page_scale_factor = page_scale_factor; |
| 932 layer->draw_properties().device_scale_factor = device_scale_factor; |
| 933 } |
| 934 |
| 935 template <typename LayerType> |
922 static inline void CalculateContentsScale( | 936 static inline void CalculateContentsScale( |
923 LayerType* layer, | 937 LayerType* layer, |
924 float contents_scale, | 938 float contents_scale, |
925 float device_scale_factor, | 939 float device_scale_factor, |
926 float page_scale_factor, | 940 float page_scale_factor, |
927 float maximum_animation_contents_scale, | 941 float maximum_animation_contents_scale, |
928 bool animating_transform_to_screen) { | 942 bool animating_transform_to_screen) { |
929 layer->CalculateContentsScale(contents_scale, | 943 layer->CalculateContentsScale(contents_scale, |
930 device_scale_factor, | 944 device_scale_factor, |
931 page_scale_factor, | 945 page_scale_factor, |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1753 layer, | 1767 layer, |
1754 globals.can_adjust_raster_scales, | 1768 globals.can_adjust_raster_scales, |
1755 ideal_contents_scale, | 1769 ideal_contents_scale, |
1756 globals.device_scale_factor, | 1770 globals.device_scale_factor, |
1757 data_from_ancestor.in_subtree_of_page_scale_application_layer | 1771 data_from_ancestor.in_subtree_of_page_scale_application_layer |
1758 ? globals.page_scale_factor | 1772 ? globals.page_scale_factor |
1759 : 1.f, | 1773 : 1.f, |
1760 combined_maximum_animation_contents_scale, | 1774 combined_maximum_animation_contents_scale, |
1761 animating_transform_to_screen); | 1775 animating_transform_to_screen); |
1762 | 1776 |
| 1777 UpdateLayerScaleDrawProperties( |
| 1778 layer, |
| 1779 ideal_contents_scale, |
| 1780 combined_maximum_animation_contents_scale, |
| 1781 data_from_ancestor.in_subtree_of_page_scale_application_layer |
| 1782 ? globals.page_scale_factor |
| 1783 : 1.f, |
| 1784 globals.device_scale_factor); |
| 1785 |
| 1786 LayerType* mask_layer = layer->mask_layer(); |
| 1787 if (mask_layer) { |
| 1788 UpdateLayerScaleDrawProperties( |
| 1789 mask_layer, |
| 1790 ideal_contents_scale, |
| 1791 combined_maximum_animation_contents_scale, |
| 1792 data_from_ancestor.in_subtree_of_page_scale_application_layer |
| 1793 ? globals.page_scale_factor |
| 1794 : 1.f, |
| 1795 globals.device_scale_factor); |
| 1796 } |
| 1797 |
| 1798 LayerType* replica_mask_layer = |
| 1799 layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL; |
| 1800 if (replica_mask_layer) { |
| 1801 UpdateLayerScaleDrawProperties( |
| 1802 replica_mask_layer, |
| 1803 ideal_contents_scale, |
| 1804 combined_maximum_animation_contents_scale, |
| 1805 data_from_ancestor.in_subtree_of_page_scale_application_layer |
| 1806 ? globals.page_scale_factor |
| 1807 : 1.f, |
| 1808 globals.device_scale_factor); |
| 1809 } |
| 1810 |
1763 // The draw_transform that gets computed below is effectively the layer's | 1811 // The draw_transform that gets computed below is effectively the layer's |
1764 // draw_transform, unless the layer itself creates a render_surface. In that | 1812 // draw_transform, unless the layer itself creates a render_surface. In that |
1765 // case, the render_surface re-parents the transforms. | 1813 // case, the render_surface re-parents the transforms. |
1766 layer_draw_properties.target_space_transform = combined_transform; | 1814 layer_draw_properties.target_space_transform = combined_transform; |
1767 // M[draw] = M[parent] * LT * S[layer2content] | 1815 // M[draw] = M[parent] * LT * S[layer2content] |
1768 layer_draw_properties.target_space_transform.Scale( | 1816 layer_draw_properties.target_space_transform.Scale( |
1769 SK_MScalar1 / layer->contents_scale_x(), | 1817 SK_MScalar1 / layer->contents_scale_x(), |
1770 SK_MScalar1 / layer->contents_scale_y()); | 1818 SK_MScalar1 / layer->contents_scale_y()); |
1771 | 1819 |
1772 // The layer's screen_space_transform represents the transform between root | 1820 // The layer's screen_space_transform represents the transform between root |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 inputs->current_render_surface_layer_list_id); | 2475 inputs->current_render_surface_layer_list_id); |
2428 | 2476 |
2429 // The dummy layer list should not have been used. | 2477 // The dummy layer list should not have been used. |
2430 DCHECK_EQ(0u, dummy_layer_list.size()); | 2478 DCHECK_EQ(0u, dummy_layer_list.size()); |
2431 // A root layer render_surface should always exist after | 2479 // A root layer render_surface should always exist after |
2432 // CalculateDrawProperties. | 2480 // CalculateDrawProperties. |
2433 DCHECK(inputs->root_layer->render_surface()); | 2481 DCHECK(inputs->root_layer->render_surface()); |
2434 } | 2482 } |
2435 | 2483 |
2436 } // namespace cc | 2484 } // namespace cc |
OLD | NEW |