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 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 << " layer: " << layer->id() << " clip id: " << layer->clip_tree_index() | 881 << " layer: " << layer->id() << " clip id: " << layer->clip_tree_index() |
882 << " layer clip: " << layer->clip_rect().ToString() << " v.s. " | 882 << " layer clip: " << layer->clip_rect().ToString() << " v.s. " |
883 << gfx::ToEnclosingRect(accumulated_clip).ToString() | 883 << gfx::ToEnclosingRect(accumulated_clip).ToString() |
884 << " and clip node clip: " | 884 << " and clip node clip: " |
885 << gfx::ToEnclosingRect(clip_tree->Node(layer->clip_tree_index()) | 885 << gfx::ToEnclosingRect(clip_tree->Node(layer->clip_tree_index()) |
886 ->data.clip_in_target_space) | 886 ->data.clip_in_target_space) |
887 .ToString(); | 887 .ToString(); |
888 } | 888 } |
889 } | 889 } |
890 | 890 |
| 891 static int FindTargetTransformTreeIndexFromEffectTree( |
| 892 const EffectTree& effect_tree, |
| 893 const int effect_tree_index) { |
| 894 const EffectNode* node = effect_tree.Node(effect_tree_index); |
| 895 if (node->data.has_render_surface) |
| 896 return node->data.transform_id; |
| 897 node = effect_tree.Node(node->data.target_id); |
| 898 return node->data.transform_id; |
| 899 } |
| 900 |
| 901 static void VerifyDrawTransformsMatch(LayerImpl* layer, |
| 902 PropertyTrees* property_trees) { |
| 903 const int source_id = layer->transform_tree_index(); |
| 904 int destination_id = FindTargetTransformTreeIndexFromEffectTree( |
| 905 property_trees->effect_tree, layer->effect_tree_index()); |
| 906 // TODO(jaydasika) : Remove this after sorting out how sublayer scale works |
| 907 // for these ids. |
| 908 if (destination_id == 0 || destination_id == 1) |
| 909 return; |
| 910 gfx::Transform draw_transform; |
| 911 property_trees->transform_tree.ComputeTransform(source_id, destination_id, |
| 912 &draw_transform); |
| 913 TransformNode* target_node = |
| 914 property_trees->transform_tree.Node(destination_id); |
| 915 draw_transform.matrix().postScale(target_node->data.sublayer_scale.x(), |
| 916 target_node->data.sublayer_scale.y(), 1.f); |
| 917 if (layer->should_flatten_transform_from_property_tree()) |
| 918 draw_transform.FlattenTo2d(); |
| 919 draw_transform.Translate(layer->offset_to_transform_parent().x(), |
| 920 layer->offset_to_transform_parent().y()); |
| 921 DCHECK(draw_transform.ApproximatelyEqual( |
| 922 DrawTransform(layer, property_trees->transform_tree))) |
| 923 << " layer: " << layer->id() << " source transform id: " << source_id |
| 924 << " destination transform id: " << destination_id |
| 925 << " draw transform from transform tree: " |
| 926 << DrawTransform(layer, property_trees->transform_tree).ToString() |
| 927 << " v.s." << draw_transform.ToString(); |
| 928 } |
| 929 |
891 static void ComputeVisibleRectsInternal( | 930 static void ComputeVisibleRectsInternal( |
892 LayerImpl* root_layer, | 931 LayerImpl* root_layer, |
893 PropertyTrees* property_trees, | 932 PropertyTrees* property_trees, |
894 bool can_render_to_separate_surface, | 933 bool can_render_to_separate_surface, |
895 std::vector<LayerImpl*>* visible_layer_list) { | 934 std::vector<LayerImpl*>* visible_layer_list) { |
896 if (property_trees->non_root_surfaces_enabled != | 935 if (property_trees->non_root_surfaces_enabled != |
897 can_render_to_separate_surface) { | 936 can_render_to_separate_surface) { |
898 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; | 937 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; |
899 property_trees->transform_tree.set_needs_update(true); | 938 property_trees->transform_tree.set_needs_update(true); |
900 } | 939 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 | 1012 |
974 void VerifyClipTreeCalculations(const LayerImplList& layer_list, | 1013 void VerifyClipTreeCalculations(const LayerImplList& layer_list, |
975 PropertyTrees* property_trees) { | 1014 PropertyTrees* property_trees) { |
976 if (property_trees->non_root_surfaces_enabled) { | 1015 if (property_trees->non_root_surfaces_enabled) { |
977 ComputeClipsWithEffectTree(property_trees); | 1016 ComputeClipsWithEffectTree(property_trees); |
978 } | 1017 } |
979 for (auto layer : layer_list) | 1018 for (auto layer : layer_list) |
980 ComputeLayerClipRect(property_trees, layer); | 1019 ComputeLayerClipRect(property_trees, layer); |
981 } | 1020 } |
982 | 1021 |
| 1022 void VerifyTransformTreeCalculations(const LayerImplList& layer_list, |
| 1023 PropertyTrees* property_trees) { |
| 1024 for (auto layer : layer_list) |
| 1025 VerifyDrawTransformsMatch(layer, property_trees); |
| 1026 } |
| 1027 |
983 void ComputeVisibleRects(LayerImpl* root_layer, | 1028 void ComputeVisibleRects(LayerImpl* root_layer, |
984 PropertyTrees* property_trees, | 1029 PropertyTrees* property_trees, |
985 bool can_render_to_separate_surface, | 1030 bool can_render_to_separate_surface, |
986 LayerImplList* visible_layer_list) { | 1031 LayerImplList* visible_layer_list) { |
987 for (auto* layer : *root_layer->layer_tree_impl()) { | 1032 for (auto* layer : *root_layer->layer_tree_impl()) { |
988 UpdateRenderSurfaceForLayer(&property_trees->effect_tree, | 1033 UpdateRenderSurfaceForLayer(&property_trees->effect_tree, |
989 can_render_to_separate_surface, layer); | 1034 can_render_to_separate_surface, layer); |
990 EffectNode* node = | 1035 EffectNode* node = |
991 property_trees->effect_tree.Node(layer->effect_tree_index()); | 1036 property_trees->effect_tree.Node(layer->effect_tree_index()); |
992 if (node->owner_id == layer->id()) | 1037 if (node->owner_id == layer->id()) |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1417 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
1373 const Layer* overscroll_elasticity_layer, | 1418 const Layer* overscroll_elasticity_layer, |
1374 const gfx::Vector2dF& elastic_overscroll) { | 1419 const gfx::Vector2dF& elastic_overscroll) { |
1375 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1420 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
1376 elastic_overscroll); | 1421 elastic_overscroll); |
1377 } | 1422 } |
1378 | 1423 |
1379 } // namespace draw_property_utils | 1424 } // namespace draw_property_utils |
1380 | 1425 |
1381 } // namespace cc | 1426 } // namespace cc |
OLD | NEW |