Chromium Code Reviews| 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 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 902 } | 902 } |
| 903 next_scroll_compensation_matrix = | 903 next_scroll_compensation_matrix = |
| 904 inverse_surface_draw_transform * next_scroll_compensation_matrix * | 904 inverse_surface_draw_transform * next_scroll_compensation_matrix * |
| 905 layer->render_surface()->draw_transform(); | 905 layer->render_surface()->draw_transform(); |
| 906 } | 906 } |
| 907 | 907 |
| 908 return next_scroll_compensation_matrix; | 908 return next_scroll_compensation_matrix; |
| 909 } | 909 } |
| 910 | 910 |
| 911 template <typename LayerType> | 911 template <typename LayerType> |
| 912 static inline void UpdateLayerDrawProperties( | |
|
danakj
2014/06/12 16:00:46
rename to UpdateLayerScaleDrawProperties, this nam
| |
| 913 LayerType* layer, | |
| 914 float ideal_contents_scale, | |
| 915 float maximum_animation_contents_scale, | |
| 916 float page_scale_factor, | |
| 917 float device_scale_factor) { | |
| 918 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | |
| 919 layer->draw_properties().maximum_animation_contents_scale = | |
| 920 maximum_animation_contents_scale; | |
| 921 layer->draw_properties().page_scale_factor = page_scale_factor; | |
| 922 layer->draw_properties().device_scale_factor = device_scale_factor; | |
| 923 } | |
| 924 | |
| 925 template <typename LayerType> | |
| 912 static inline void CalculateContentsScale( | 926 static inline void CalculateContentsScale( |
| 913 LayerType* layer, | 927 LayerType* layer, |
| 914 float contents_scale, | 928 float contents_scale, |
| 915 float device_scale_factor, | 929 float device_scale_factor, |
| 916 float page_scale_factor, | 930 float page_scale_factor, |
| 917 float maximum_animation_contents_scale, | 931 float maximum_animation_contents_scale, |
| 918 bool animating_transform_to_screen) { | 932 bool animating_transform_to_screen) { |
| 919 layer->CalculateContentsScale(contents_scale, | 933 layer->CalculateContentsScale(contents_scale, |
| 920 device_scale_factor, | 934 device_scale_factor, |
| 921 page_scale_factor, | 935 page_scale_factor, |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1733 layer, | 1747 layer, |
| 1734 globals.can_adjust_raster_scales, | 1748 globals.can_adjust_raster_scales, |
| 1735 ideal_contents_scale, | 1749 ideal_contents_scale, |
| 1736 globals.device_scale_factor, | 1750 globals.device_scale_factor, |
| 1737 data_from_ancestor.in_subtree_of_page_scale_application_layer | 1751 data_from_ancestor.in_subtree_of_page_scale_application_layer |
| 1738 ? globals.page_scale_factor | 1752 ? globals.page_scale_factor |
| 1739 : 1.f, | 1753 : 1.f, |
| 1740 combined_maximum_animation_contents_scale, | 1754 combined_maximum_animation_contents_scale, |
| 1741 animating_transform_to_screen); | 1755 animating_transform_to_screen); |
| 1742 | 1756 |
| 1757 UpdateLayerDrawProperties( | |
| 1758 layer, | |
| 1759 ideal_contents_scale, | |
| 1760 combined_maximum_animation_contents_scale, | |
| 1761 data_from_ancestor.in_subtree_of_page_scale_application_layer | |
| 1762 ? globals.page_scale_factor | |
| 1763 : 1.f, | |
| 1764 globals.device_scale_factor); | |
| 1765 | |
| 1766 LayerType* mask_layer = layer->mask_layer(); | |
| 1767 if (mask_layer) { | |
| 1768 UpdateLayerDrawProperties( | |
| 1769 mask_layer, | |
| 1770 ideal_contents_scale, | |
| 1771 combined_maximum_animation_contents_scale, | |
| 1772 data_from_ancestor.in_subtree_of_page_scale_application_layer | |
| 1773 ? globals.page_scale_factor | |
| 1774 : 1.f, | |
| 1775 globals.device_scale_factor); | |
| 1776 } | |
| 1777 | |
| 1778 LayerType* replica_mask_layer = | |
| 1779 layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL; | |
| 1780 if (replica_mask_layer) { | |
| 1781 UpdateLayerDrawProperties( | |
| 1782 replica_mask_layer, | |
| 1783 ideal_contents_scale, | |
| 1784 combined_maximum_animation_contents_scale, | |
| 1785 data_from_ancestor.in_subtree_of_page_scale_application_layer | |
| 1786 ? globals.page_scale_factor | |
| 1787 : 1.f, | |
| 1788 globals.device_scale_factor); | |
| 1789 } | |
| 1790 | |
| 1743 // The draw_transform that gets computed below is effectively the layer's | 1791 // The draw_transform that gets computed below is effectively the layer's |
| 1744 // draw_transform, unless the layer itself creates a render_surface. In that | 1792 // draw_transform, unless the layer itself creates a render_surface. In that |
| 1745 // case, the render_surface re-parents the transforms. | 1793 // case, the render_surface re-parents the transforms. |
| 1746 layer_draw_properties.target_space_transform = combined_transform; | 1794 layer_draw_properties.target_space_transform = combined_transform; |
| 1747 // M[draw] = M[parent] * LT * S[layer2content] | 1795 // M[draw] = M[parent] * LT * S[layer2content] |
| 1748 layer_draw_properties.target_space_transform.Scale( | 1796 layer_draw_properties.target_space_transform.Scale( |
| 1749 SK_MScalar1 / layer->contents_scale_x(), | 1797 SK_MScalar1 / layer->contents_scale_x(), |
| 1750 SK_MScalar1 / layer->contents_scale_y()); | 1798 SK_MScalar1 / layer->contents_scale_y()); |
| 1751 | 1799 |
| 1752 // The layer's screen_space_transform represents the transform between root | 1800 // The layer's screen_space_transform represents the transform between root |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2407 inputs->current_render_surface_layer_list_id); | 2455 inputs->current_render_surface_layer_list_id); |
| 2408 | 2456 |
| 2409 // The dummy layer list should not have been used. | 2457 // The dummy layer list should not have been used. |
| 2410 DCHECK_EQ(0u, dummy_layer_list.size()); | 2458 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 2411 // A root layer render_surface should always exist after | 2459 // A root layer render_surface should always exist after |
| 2412 // CalculateDrawProperties. | 2460 // CalculateDrawProperties. |
| 2413 DCHECK(inputs->root_layer->render_surface()); | 2461 DCHECK(inputs->root_layer->render_surface()); |
| 2414 } | 2462 } |
| 2415 | 2463 |
| 2416 } // namespace cc | 2464 } // namespace cc |
| OLD | NEW |