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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 if (source_id == dest_id) | 150 if (source_id == dest_id) |
151 return true; | 151 return true; |
152 | 152 |
153 if (source_id > dest_id) { | 153 if (source_id > dest_id) { |
154 return CombineTransformsBetween(source_id, dest_id, transform); | 154 return CombineTransformsBetween(source_id, dest_id, transform); |
155 } | 155 } |
156 | 156 |
157 return CombineInversesBetween(source_id, dest_id, transform); | 157 return CombineInversesBetween(source_id, dest_id, transform); |
158 } | 158 } |
159 | 159 |
160 bool TransformTree::ComputeTransformWithDestinationSurfaceContentsScale( | |
161 int source_id, | |
162 int dest_id, | |
163 gfx::Transform* transform) const { | |
164 bool success = ComputeTransform(source_id, dest_id, transform); | |
165 | |
166 const TransformNode* dest_node = Node(dest_id); | |
167 if (!dest_node->needs_surface_contents_scale) | |
168 return success; | |
169 | |
170 transform->matrix().postScale(dest_node->surface_contents_scale.x(), | |
171 dest_node->surface_contents_scale.y(), 1.f); | |
172 return success; | |
173 } | |
174 | |
175 bool TransformTree::NeedsSourceToParentUpdate(TransformNode* node) { | 160 bool TransformTree::NeedsSourceToParentUpdate(TransformNode* node) { |
176 return (source_to_parent_updates_allowed() && | 161 return (source_to_parent_updates_allowed() && |
177 node->parent_id != node->source_node_id); | 162 node->parent_id != node->source_node_id); |
178 } | 163 } |
179 | 164 |
180 void TransformTree::ResetChangeTracking() { | 165 void TransformTree::ResetChangeTracking() { |
181 for (int id = 1; id < static_cast<int>(size()); ++id) { | 166 for (int id = 1; id < static_cast<int>(size()); ++id) { |
182 TransformNode* node = Node(id); | 167 TransformNode* node = Node(id); |
183 node->transform_changed = false; | 168 node->transform_changed = false; |
184 } | 169 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 TransformNode* target_node) { | 401 TransformNode* target_node) { |
417 gfx::Transform target_space_transform; | 402 gfx::Transform target_space_transform; |
418 if (node->needs_surface_contents_scale) { | 403 if (node->needs_surface_contents_scale) { |
419 target_space_transform.MakeIdentity(); | 404 target_space_transform.MakeIdentity(); |
420 target_space_transform.Scale(node->surface_contents_scale.x(), | 405 target_space_transform.Scale(node->surface_contents_scale.x(), |
421 node->surface_contents_scale.y()); | 406 node->surface_contents_scale.y()); |
422 } else { | 407 } else { |
423 // In order to include the root transform for the root surface, we walk up | 408 // In order to include the root transform for the root surface, we walk up |
424 // to the root of the transform tree in ComputeTransform. | 409 // to the root of the transform tree in ComputeTransform. |
425 int target_id = target_node->id; | 410 int target_id = target_node->id; |
426 ComputeTransformWithDestinationSurfaceContentsScale( | 411 ComputeTransform(node->id, target_id, &target_space_transform); |
427 node->id, target_id, &target_space_transform); | 412 if (target_id != 0) { |
| 413 target_space_transform.matrix().postScale( |
| 414 target_node->surface_contents_scale.x(), |
| 415 target_node->surface_contents_scale.y(), 1.f); |
| 416 } |
428 } | 417 } |
429 | 418 |
430 gfx::Transform from_target; | 419 gfx::Transform from_target; |
431 if (!target_space_transform.GetInverse(&from_target)) | 420 if (!target_space_transform.GetInverse(&from_target)) |
432 node->ancestors_are_invertible = false; | 421 node->ancestors_are_invertible = false; |
433 SetToTarget(node->id, target_space_transform); | 422 SetToTarget(node->id, target_space_transform); |
434 SetFromTarget(node->id, from_target); | 423 SetFromTarget(node->id, from_target); |
435 } | 424 } |
436 | 425 |
437 void TransformTree::UpdateAnimationProperties(TransformNode* node, | 426 void TransformTree::UpdateAnimationProperties(TransformNode* node, |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 int TransformTree::ContentTargetId(int node_id) const { | 622 int TransformTree::ContentTargetId(int node_id) const { |
634 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 623 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
635 return cached_data_[node_id].content_target_id; | 624 return cached_data_[node_id].content_target_id; |
636 } | 625 } |
637 | 626 |
638 void TransformTree::SetContentTargetId(int node_id, int content_target_id) { | 627 void TransformTree::SetContentTargetId(int node_id, int content_target_id) { |
639 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 628 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
640 cached_data_[node_id].content_target_id = content_target_id; | 629 cached_data_[node_id].content_target_id = content_target_id; |
641 } | 630 } |
642 | 631 |
643 gfx::Transform TransformTree::ToScreenSpaceTransformWithoutSurfaceContentsScale( | |
644 int id) const { | |
645 DCHECK_GT(id, 0); | |
646 if (id == 1) { | |
647 return gfx::Transform(); | |
648 } | |
649 const TransformNode* node = Node(id); | |
650 gfx::Transform screen_space_transform = ToScreen(id); | |
651 if (node->surface_contents_scale.x() != 0.0 && | |
652 node->surface_contents_scale.y() != 0.0) | |
653 screen_space_transform.Scale(1.0 / node->surface_contents_scale.x(), | |
654 1.0 / node->surface_contents_scale.y()); | |
655 return screen_space_transform; | |
656 } | |
657 | |
658 bool TransformTree::operator==(const TransformTree& other) const { | 632 bool TransformTree::operator==(const TransformTree& other) const { |
659 return PropertyTree::operator==(other) && | 633 return PropertyTree::operator==(other) && |
660 source_to_parent_updates_allowed_ == | 634 source_to_parent_updates_allowed_ == |
661 other.source_to_parent_updates_allowed() && | 635 other.source_to_parent_updates_allowed() && |
662 page_scale_factor_ == other.page_scale_factor() && | 636 page_scale_factor_ == other.page_scale_factor() && |
663 device_scale_factor_ == other.device_scale_factor() && | 637 device_scale_factor_ == other.device_scale_factor() && |
664 device_transform_scale_factor_ == | 638 device_transform_scale_factor_ == |
665 other.device_transform_scale_factor() && | 639 other.device_transform_scale_factor() && |
666 nodes_affected_by_inner_viewport_bounds_delta_ == | 640 nodes_affected_by_inner_viewport_bounds_delta_ == |
667 other.nodes_affected_by_inner_viewport_bounds_delta() && | 641 other.nodes_affected_by_inner_viewport_bounds_delta() && |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 // For non-root surfaces, transform only by sub-layer scale. | 873 // For non-root surfaces, transform only by sub-layer scale. |
900 source_id = destination_id; | 874 source_id = destination_id; |
901 } else { | 875 } else { |
902 // The root surface doesn't have the notion of sub-layer scale, but | 876 // The root surface doesn't have the notion of sub-layer scale, but |
903 // instead has a similar notion of transforming from the space of the root | 877 // instead has a similar notion of transforming from the space of the root |
904 // layer to the space of the screen. | 878 // layer to the space of the screen. |
905 DCHECK_EQ(0, destination_id); | 879 DCHECK_EQ(0, destination_id); |
906 source_id = 1; | 880 source_id = 1; |
907 } | 881 } |
908 gfx::Transform transform; | 882 gfx::Transform transform; |
909 property_trees() | 883 property_trees()->transform_tree.ComputeTransform(source_id, destination_id, |
910 ->transform_tree.ComputeTransformWithDestinationSurfaceContentsScale( | 884 &transform); |
911 source_id, destination_id, &transform); | 885 if (destination_id != 0) { |
| 886 transform.matrix().postScale(effect_node->surface_contents_scale.x(), |
| 887 effect_node->surface_contents_scale.y(), |
| 888 1.f); |
| 889 } |
912 it->set_area(MathUtil::MapEnclosingClippedRect(transform, it->area())); | 890 it->set_area(MathUtil::MapEnclosingClippedRect(transform, it->area())); |
913 } | 891 } |
914 } | 892 } |
915 | 893 |
916 bool EffectTree::HasCopyRequests() const { | 894 bool EffectTree::HasCopyRequests() const { |
917 return !copy_requests_.empty(); | 895 return !copy_requests_.empty(); |
918 } | 896 } |
919 | 897 |
920 void EffectTree::ClearCopyRequests() { | 898 void EffectTree::ClearCopyRequests() { |
921 for (auto& node : nodes()) { | 899 for (auto& node : nodes()) { |
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 void PropertyTrees::ResetCachedData() { | 1852 void PropertyTrees::ResetCachedData() { |
1875 cached_data_.property_tree_update_number = 0; | 1853 cached_data_.property_tree_update_number = 0; |
1876 cached_data_.animation_scales = std::vector<AnimationScaleData>( | 1854 cached_data_.animation_scales = std::vector<AnimationScaleData>( |
1877 transform_tree.nodes().size(), AnimationScaleData()); | 1855 transform_tree.nodes().size(), AnimationScaleData()); |
1878 } | 1856 } |
1879 | 1857 |
1880 void PropertyTrees::UpdateCachedNumber() { | 1858 void PropertyTrees::UpdateCachedNumber() { |
1881 cached_data_.property_tree_update_number++; | 1859 cached_data_.property_tree_update_number++; |
1882 } | 1860 } |
1883 | 1861 |
| 1862 gfx::Transform PropertyTrees::ToScreenSpaceTransformWithoutSurfaceContentsScale( |
| 1863 int transform_id, |
| 1864 int effect_id) const { |
| 1865 DCHECK_GT(transform_id, 0); |
| 1866 if (transform_id == 1) { |
| 1867 return gfx::Transform(); |
| 1868 } |
| 1869 gfx::Transform screen_space_transform = transform_tree.ToScreen(transform_id); |
| 1870 const EffectNode* effect_node = effect_tree.Node(effect_id); |
| 1871 |
| 1872 if (effect_node->surface_contents_scale.x() != 0.0 && |
| 1873 effect_node->surface_contents_scale.y() != 0.0) |
| 1874 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), |
| 1875 1.0 / effect_node->surface_contents_scale.y()); |
| 1876 return screen_space_transform; |
| 1877 } |
| 1878 |
1884 } // namespace cc | 1879 } // namespace cc |
OLD | NEW |