| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/draw_property_utils.h" | 5 #include "cc/trees/draw_property_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 // (included) and its target surface (excluded). | 1000 // (included) and its target surface (excluded). |
| 1001 const EffectNode* node = tree.Node(render_surface->EffectTreeIndex()); | 1001 const EffectNode* node = tree.Node(render_surface->EffectTreeIndex()); |
| 1002 float draw_opacity = tree.EffectiveOpacity(node); | 1002 float draw_opacity = tree.EffectiveOpacity(node); |
| 1003 for (node = tree.parent(node); node && !node->data.has_render_surface; | 1003 for (node = tree.parent(node); node && !node->data.has_render_surface; |
| 1004 node = tree.parent(node)) { | 1004 node = tree.parent(node)) { |
| 1005 draw_opacity *= tree.EffectiveOpacity(node); | 1005 draw_opacity *= tree.EffectiveOpacity(node); |
| 1006 } | 1006 } |
| 1007 render_surface->SetDrawOpacity(draw_opacity); | 1007 render_surface->SetDrawOpacity(draw_opacity); |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 static bool LayerCanUseLcdText(const LayerImpl* layer, | |
| 1011 bool layers_always_allowed_lcd_text, | |
| 1012 bool can_use_lcd_text, | |
| 1013 const TransformNode* transform_node, | |
| 1014 const EffectNode* effect_node) { | |
| 1015 if (layers_always_allowed_lcd_text) | |
| 1016 return true; | |
| 1017 if (!can_use_lcd_text) | |
| 1018 return false; | |
| 1019 if (!layer->contents_opaque()) | |
| 1020 return false; | |
| 1021 | |
| 1022 if (effect_node->data.screen_space_opacity != 1.f) | |
| 1023 return false; | |
| 1024 if (!transform_node->data.node_and_ancestors_have_only_integer_translation) | |
| 1025 return false; | |
| 1026 if (static_cast<int>(layer->offset_to_transform_parent().x()) != | |
| 1027 layer->offset_to_transform_parent().x()) | |
| 1028 return false; | |
| 1029 if (static_cast<int>(layer->offset_to_transform_parent().y()) != | |
| 1030 layer->offset_to_transform_parent().y()) | |
| 1031 return false; | |
| 1032 return true; | |
| 1033 } | |
| 1034 | |
| 1035 static gfx::Rect LayerDrawableContentRect( | 1010 static gfx::Rect LayerDrawableContentRect( |
| 1036 const LayerImpl* layer, | 1011 const LayerImpl* layer, |
| 1037 const gfx::Rect& layer_bounds_in_target_space, | 1012 const gfx::Rect& layer_bounds_in_target_space, |
| 1038 const gfx::Rect& clip_rect) { | 1013 const gfx::Rect& clip_rect) { |
| 1039 if (layer->is_clipped()) | 1014 if (layer->is_clipped()) |
| 1040 return IntersectRects(layer_bounds_in_target_space, clip_rect); | 1015 return IntersectRects(layer_bounds_in_target_space, clip_rect); |
| 1041 | 1016 |
| 1042 return layer_bounds_in_target_space; | 1017 return layer_bounds_in_target_space; |
| 1043 } | 1018 } |
| 1044 | 1019 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1063 if (surface_transform_node->data.sublayer_scale.x() != 0 && | 1038 if (surface_transform_node->data.sublayer_scale.x() != 0 && |
| 1064 surface_transform_node->data.sublayer_scale.y() != 0) { | 1039 surface_transform_node->data.sublayer_scale.y() != 0) { |
| 1065 replica_to_surface.Scale( | 1040 replica_to_surface.Scale( |
| 1066 1.0 / surface_transform_node->data.sublayer_scale.x(), | 1041 1.0 / surface_transform_node->data.sublayer_scale.x(), |
| 1067 1.0 / surface_transform_node->data.sublayer_scale.y()); | 1042 1.0 / surface_transform_node->data.sublayer_scale.y()); |
| 1068 } | 1043 } |
| 1069 return replica_to_surface; | 1044 return replica_to_surface; |
| 1070 } | 1045 } |
| 1071 | 1046 |
| 1072 void ComputeLayerDrawProperties(LayerImpl* layer, | 1047 void ComputeLayerDrawProperties(LayerImpl* layer, |
| 1073 const PropertyTrees* property_trees, | 1048 const PropertyTrees* property_trees) { |
| 1074 bool layers_always_allowed_lcd_text, | |
| 1075 bool can_use_lcd_text) { | |
| 1076 const TransformNode* transform_node = | 1049 const TransformNode* transform_node = |
| 1077 property_trees->transform_tree.Node(layer->transform_tree_index()); | 1050 property_trees->transform_tree.Node(layer->transform_tree_index()); |
| 1078 const EffectNode* effect_node = | |
| 1079 property_trees->effect_tree.Node(layer->effect_tree_index()); | |
| 1080 const ClipNode* clip_node = | 1051 const ClipNode* clip_node = |
| 1081 property_trees->clip_tree.Node(layer->clip_tree_index()); | 1052 property_trees->clip_tree.Node(layer->clip_tree_index()); |
| 1082 | 1053 |
| 1083 layer->draw_properties().screen_space_transform = | 1054 layer->draw_properties().screen_space_transform = |
| 1084 ScreenSpaceTransformInternal(layer, transform_node); | 1055 ScreenSpaceTransformInternal(layer, transform_node); |
| 1085 if (property_trees->non_root_surfaces_enabled) { | 1056 if (property_trees->non_root_surfaces_enabled) { |
| 1086 layer->draw_properties().target_space_transform = | 1057 layer->draw_properties().target_space_transform = |
| 1087 DrawTransform(layer, property_trees->transform_tree); | 1058 DrawTransform(layer, property_trees->transform_tree); |
| 1088 } else { | 1059 } else { |
| 1089 layer->draw_properties().target_space_transform = | 1060 layer->draw_properties().target_space_transform = |
| 1090 layer->draw_properties().screen_space_transform; | 1061 layer->draw_properties().screen_space_transform; |
| 1091 } | 1062 } |
| 1092 layer->draw_properties().screen_space_transform_is_animating = | 1063 layer->draw_properties().screen_space_transform_is_animating = |
| 1093 transform_node->data.to_screen_is_potentially_animated; | 1064 transform_node->data.to_screen_is_potentially_animated; |
| 1094 if (layer->layer_tree_impl() | 1065 if (layer->layer_tree_impl() |
| 1095 ->settings() | 1066 ->settings() |
| 1096 .layer_transforms_should_scale_layer_contents) { | 1067 .layer_transforms_should_scale_layer_contents) { |
| 1097 layer->draw_properties().maximum_animation_contents_scale = | 1068 layer->draw_properties().maximum_animation_contents_scale = |
| 1098 transform_node->data.combined_maximum_animation_target_scale; | 1069 transform_node->data.combined_maximum_animation_target_scale; |
| 1099 layer->draw_properties().starting_animation_contents_scale = | 1070 layer->draw_properties().starting_animation_contents_scale = |
| 1100 transform_node->data.combined_starting_animation_scale; | 1071 transform_node->data.combined_starting_animation_scale; |
| 1101 } else { | 1072 } else { |
| 1102 layer->draw_properties().maximum_animation_contents_scale = 0.f; | 1073 layer->draw_properties().maximum_animation_contents_scale = 0.f; |
| 1103 layer->draw_properties().starting_animation_contents_scale = 0.f; | 1074 layer->draw_properties().starting_animation_contents_scale = 0.f; |
| 1104 } | 1075 } |
| 1105 | 1076 |
| 1106 layer->draw_properties().opacity = | 1077 layer->draw_properties().opacity = |
| 1107 LayerDrawOpacity(layer, property_trees->effect_tree); | 1078 LayerDrawOpacity(layer, property_trees->effect_tree); |
| 1108 layer->draw_properties().can_use_lcd_text = | |
| 1109 LayerCanUseLcdText(layer, layers_always_allowed_lcd_text, | |
| 1110 can_use_lcd_text, transform_node, effect_node); | |
| 1111 if (property_trees->non_root_surfaces_enabled) { | 1079 if (property_trees->non_root_surfaces_enabled) { |
| 1112 layer->draw_properties().is_clipped = clip_node->data.layers_are_clipped; | 1080 layer->draw_properties().is_clipped = clip_node->data.layers_are_clipped; |
| 1113 } else { | 1081 } else { |
| 1114 layer->draw_properties().is_clipped = | 1082 layer->draw_properties().is_clipped = |
| 1115 clip_node->data.layers_are_clipped_when_surfaces_disabled; | 1083 clip_node->data.layers_are_clipped_when_surfaces_disabled; |
| 1116 } | 1084 } |
| 1117 | 1085 |
| 1118 gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect( | 1086 gfx::Rect bounds_in_target_space = MathUtil::MapEnclosingClippedRect( |
| 1119 layer->draw_properties().target_space_transform, | 1087 layer->draw_properties().target_space_transform, |
| 1120 gfx::Rect(layer->bounds())); | 1088 gfx::Rect(layer->bounds())); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1214 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1247 const Layer* overscroll_elasticity_layer, | 1215 const Layer* overscroll_elasticity_layer, |
| 1248 const gfx::Vector2dF& elastic_overscroll) { | 1216 const gfx::Vector2dF& elastic_overscroll) { |
| 1249 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1217 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1250 elastic_overscroll); | 1218 elastic_overscroll); |
| 1251 } | 1219 } |
| 1252 | 1220 |
| 1253 } // namespace draw_property_utils | 1221 } // namespace draw_property_utils |
| 1254 | 1222 |
| 1255 } // namespace cc | 1223 } // namespace cc |
| OLD | NEW |