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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 float maximum_animation_contents_scale, | 925 float maximum_animation_contents_scale, |
926 float page_scale_factor, | 926 float page_scale_factor, |
927 float device_scale_factor) { | 927 float device_scale_factor) { |
928 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; | 928 layer->draw_properties().ideal_contents_scale = ideal_contents_scale; |
929 layer->draw_properties().maximum_animation_contents_scale = | 929 layer->draw_properties().maximum_animation_contents_scale = |
930 maximum_animation_contents_scale; | 930 maximum_animation_contents_scale; |
931 layer->draw_properties().page_scale_factor = page_scale_factor; | 931 layer->draw_properties().page_scale_factor = page_scale_factor; |
932 layer->draw_properties().device_scale_factor = device_scale_factor; | 932 layer->draw_properties().device_scale_factor = device_scale_factor; |
933 } | 933 } |
934 | 934 |
935 static inline void CalculateContentsScale( | 935 static inline void CalculateContentsScale(LayerImpl* layer, |
936 LayerImpl* layer, | 936 float contents_scale) { |
937 float contents_scale, | |
938 float device_scale_factor, | |
939 float page_scale_factor, | |
940 float maximum_animation_contents_scale, | |
941 bool animating_transform_to_screen) { | |
942 // LayerImpl has all of its content scales and bounds pushed from the Main | 937 // LayerImpl has all of its content scales and bounds pushed from the Main |
943 // thread during commit and just uses those values as-is. | 938 // thread during commit and just uses those values as-is. |
944 } | 939 } |
945 | 940 |
946 static inline void CalculateContentsScale( | 941 static inline void CalculateContentsScale(Layer* layer, float contents_scale) { |
947 Layer* layer, | |
948 float contents_scale, | |
949 float device_scale_factor, | |
950 float page_scale_factor, | |
951 float maximum_animation_contents_scale, | |
952 bool animating_transform_to_screen) { | |
953 layer->CalculateContentsScale(contents_scale, | 942 layer->CalculateContentsScale(contents_scale, |
954 device_scale_factor, | |
955 page_scale_factor, | |
956 maximum_animation_contents_scale, | |
957 animating_transform_to_screen, | |
958 &layer->draw_properties().contents_scale_x, | 943 &layer->draw_properties().contents_scale_x, |
959 &layer->draw_properties().contents_scale_y, | 944 &layer->draw_properties().contents_scale_y, |
960 &layer->draw_properties().content_bounds); | 945 &layer->draw_properties().content_bounds); |
961 | 946 |
962 Layer* mask_layer = layer->mask_layer(); | 947 Layer* mask_layer = layer->mask_layer(); |
963 if (mask_layer) { | 948 if (mask_layer) { |
964 mask_layer->CalculateContentsScale( | 949 mask_layer->CalculateContentsScale( |
965 contents_scale, | 950 contents_scale, |
966 device_scale_factor, | |
967 page_scale_factor, | |
968 maximum_animation_contents_scale, | |
969 animating_transform_to_screen, | |
970 &mask_layer->draw_properties().contents_scale_x, | 951 &mask_layer->draw_properties().contents_scale_x, |
971 &mask_layer->draw_properties().contents_scale_y, | 952 &mask_layer->draw_properties().contents_scale_y, |
972 &mask_layer->draw_properties().content_bounds); | 953 &mask_layer->draw_properties().content_bounds); |
973 } | 954 } |
974 | 955 |
975 Layer* replica_mask_layer = | 956 Layer* replica_mask_layer = |
976 layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL; | 957 layer->replica_layer() ? layer->replica_layer()->mask_layer() : NULL; |
977 if (replica_mask_layer) { | 958 if (replica_mask_layer) { |
978 replica_mask_layer->CalculateContentsScale( | 959 replica_mask_layer->CalculateContentsScale( |
979 contents_scale, | 960 contents_scale, |
980 device_scale_factor, | |
981 page_scale_factor, | |
982 maximum_animation_contents_scale, | |
983 animating_transform_to_screen, | |
984 &replica_mask_layer->draw_properties().contents_scale_x, | 961 &replica_mask_layer->draw_properties().contents_scale_x, |
985 &replica_mask_layer->draw_properties().contents_scale_y, | 962 &replica_mask_layer->draw_properties().contents_scale_y, |
986 &replica_mask_layer->draw_properties().content_bounds); | 963 &replica_mask_layer->draw_properties().content_bounds); |
987 } | 964 } |
988 } | 965 } |
989 | 966 |
990 static inline void UpdateLayerContentsScale( | 967 static inline void UpdateLayerContentsScale( |
991 LayerImpl* layer, | 968 LayerImpl* layer, |
992 bool can_adjust_raster_scale, | 969 bool can_adjust_raster_scale, |
993 float ideal_contents_scale, | 970 float ideal_contents_scale, |
994 float device_scale_factor, | 971 float device_scale_factor, |
995 float page_scale_factor, | 972 float page_scale_factor, |
996 float maximum_animation_contents_scale, | |
997 bool animating_transform_to_screen) { | 973 bool animating_transform_to_screen) { |
998 CalculateContentsScale(layer, | 974 CalculateContentsScale(layer, ideal_contents_scale); |
999 ideal_contents_scale, | |
1000 device_scale_factor, | |
1001 page_scale_factor, | |
1002 maximum_animation_contents_scale, | |
1003 animating_transform_to_screen); | |
1004 } | 975 } |
1005 | 976 |
1006 static inline void UpdateLayerContentsScale( | 977 static inline void UpdateLayerContentsScale( |
1007 Layer* layer, | 978 Layer* layer, |
1008 bool can_adjust_raster_scale, | 979 bool can_adjust_raster_scale, |
1009 float ideal_contents_scale, | 980 float ideal_contents_scale, |
1010 float device_scale_factor, | 981 float device_scale_factor, |
1011 float page_scale_factor, | 982 float page_scale_factor, |
1012 float maximum_animation_contents_scale, | |
1013 bool animating_transform_to_screen) { | 983 bool animating_transform_to_screen) { |
1014 if (can_adjust_raster_scale) { | 984 if (can_adjust_raster_scale) { |
1015 float ideal_raster_scale = | 985 float ideal_raster_scale = |
1016 ideal_contents_scale / (device_scale_factor * page_scale_factor); | 986 ideal_contents_scale / (device_scale_factor * page_scale_factor); |
1017 | 987 |
1018 bool need_to_set_raster_scale = layer->raster_scale_is_unknown(); | 988 bool need_to_set_raster_scale = layer->raster_scale_is_unknown(); |
1019 | 989 |
1020 // If we've previously saved a raster_scale but the ideal changes, things | 990 // If we've previously saved a raster_scale but the ideal changes, things |
1021 // are unpredictable and we should just use 1. | 991 // are unpredictable and we should just use 1. |
1022 if (!need_to_set_raster_scale && layer->raster_scale() != 1.f && | 992 if (!need_to_set_raster_scale && layer->raster_scale() != 1.f && |
(...skipping 12 matching lines...) Expand all Loading... |
1035 | 1005 |
1036 float raster_scale = 1.f; | 1006 float raster_scale = 1.f; |
1037 if (!layer->raster_scale_is_unknown()) | 1007 if (!layer->raster_scale_is_unknown()) |
1038 raster_scale = layer->raster_scale(); | 1008 raster_scale = layer->raster_scale(); |
1039 | 1009 |
1040 gfx::Size old_content_bounds = layer->content_bounds(); | 1010 gfx::Size old_content_bounds = layer->content_bounds(); |
1041 float old_contents_scale_x = layer->contents_scale_x(); | 1011 float old_contents_scale_x = layer->contents_scale_x(); |
1042 float old_contents_scale_y = layer->contents_scale_y(); | 1012 float old_contents_scale_y = layer->contents_scale_y(); |
1043 | 1013 |
1044 float contents_scale = raster_scale * device_scale_factor * page_scale_factor; | 1014 float contents_scale = raster_scale * device_scale_factor * page_scale_factor; |
1045 CalculateContentsScale(layer, | 1015 CalculateContentsScale(layer, contents_scale); |
1046 contents_scale, | |
1047 device_scale_factor, | |
1048 page_scale_factor, | |
1049 maximum_animation_contents_scale, | |
1050 animating_transform_to_screen); | |
1051 | 1016 |
1052 if (layer->content_bounds() != old_content_bounds || | 1017 if (layer->content_bounds() != old_content_bounds || |
1053 layer->contents_scale_x() != old_contents_scale_x || | 1018 layer->contents_scale_x() != old_contents_scale_x || |
1054 layer->contents_scale_y() != old_contents_scale_y) | 1019 layer->contents_scale_y() != old_contents_scale_y) |
1055 layer->SetNeedsPushProperties(); | 1020 layer->SetNeedsPushProperties(); |
1056 } | 1021 } |
1057 | 1022 |
1058 static inline void CalculateAnimationContentsScale( | 1023 static inline void CalculateAnimationContentsScale( |
1059 Layer* layer, | 1024 Layer* layer, |
1060 bool ancestor_is_animating_scale, | 1025 bool ancestor_is_animating_scale, |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 combined_transform_scales.y()) | 1739 combined_transform_scales.y()) |
1775 : layer_scale_factors; | 1740 : layer_scale_factors; |
1776 UpdateLayerContentsScale( | 1741 UpdateLayerContentsScale( |
1777 layer, | 1742 layer, |
1778 globals.can_adjust_raster_scales, | 1743 globals.can_adjust_raster_scales, |
1779 ideal_contents_scale, | 1744 ideal_contents_scale, |
1780 globals.device_scale_factor, | 1745 globals.device_scale_factor, |
1781 data_from_ancestor.in_subtree_of_page_scale_application_layer | 1746 data_from_ancestor.in_subtree_of_page_scale_application_layer |
1782 ? globals.page_scale_factor | 1747 ? globals.page_scale_factor |
1783 : 1.f, | 1748 : 1.f, |
1784 combined_maximum_animation_contents_scale, | |
1785 animating_transform_to_screen); | 1749 animating_transform_to_screen); |
1786 | 1750 |
1787 UpdateLayerScaleDrawProperties( | 1751 UpdateLayerScaleDrawProperties( |
1788 layer, | 1752 layer, |
1789 ideal_contents_scale, | 1753 ideal_contents_scale, |
1790 combined_maximum_animation_contents_scale, | 1754 combined_maximum_animation_contents_scale, |
1791 data_from_ancestor.in_subtree_of_page_scale_application_layer | 1755 data_from_ancestor.in_subtree_of_page_scale_application_layer |
1792 ? globals.page_scale_factor | 1756 ? globals.page_scale_factor |
1793 : 1.f, | 1757 : 1.f, |
1794 globals.device_scale_factor); | 1758 globals.device_scale_factor); |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2485 inputs->current_render_surface_layer_list_id); | 2449 inputs->current_render_surface_layer_list_id); |
2486 | 2450 |
2487 // The dummy layer list should not have been used. | 2451 // The dummy layer list should not have been used. |
2488 DCHECK_EQ(0u, dummy_layer_list.size()); | 2452 DCHECK_EQ(0u, dummy_layer_list.size()); |
2489 // A root layer render_surface should always exist after | 2453 // A root layer render_surface should always exist after |
2490 // CalculateDrawProperties. | 2454 // CalculateDrawProperties. |
2491 DCHECK(inputs->root_layer->render_surface()); | 2455 DCHECK(inputs->root_layer->render_surface()); |
2492 } | 2456 } |
2493 | 2457 |
2494 } // namespace cc | 2458 } // namespace cc |
OLD | NEW |