Chromium Code Reviews| 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/property_tree_builder.h" | 5 #include "cc/trees/property_tree_builder.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| 11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
| 12 #include "cc/trees/layer_tree_host.h" | 12 #include "cc/trees/layer_tree_host.h" |
| 13 #include "ui/gfx/geometry/point_f.h" | 13 #include "ui/gfx/geometry/point_f.h" |
| 14 #include "ui/gfx/geometry/vector2d_conversions.h" | |
| 14 | 15 |
| 15 namespace cc { | 16 namespace cc { |
| 16 | 17 |
| 17 class LayerTreeHost; | 18 class LayerTreeHost; |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 struct DataForRecursion { | 22 struct DataForRecursion { |
| 22 TransformTree* transform_tree; | 23 TransformTree* transform_tree; |
| 23 ClipTree* clip_tree; | 24 ClipTree* clip_tree; |
| 24 OpacityTree* opacity_tree; | 25 OpacityTree* opacity_tree; |
| 25 Layer* transform_tree_parent; | 26 Layer* transform_tree_parent; |
| 26 Layer* transform_fixed_parent; | 27 Layer* transform_fixed_parent; |
| 27 Layer* render_target; | 28 Layer* render_target; |
| 28 int clip_tree_parent; | 29 int clip_tree_parent; |
| 29 int opacity_tree_parent; | 30 int opacity_tree_parent; |
| 30 const Layer* page_scale_layer; | 31 const Layer* page_scale_layer; |
| 31 float page_scale_factor; | 32 float page_scale_factor; |
| 32 float device_scale_factor; | 33 float device_scale_factor; |
| 33 bool in_subtree_of_page_scale_application_layer; | 34 bool in_subtree_of_page_scale_application_layer; |
| 34 bool should_flatten; | 35 bool should_flatten; |
| 35 const gfx::Transform* device_transform; | 36 const gfx::Transform* device_transform; |
| 37 gfx::Vector2d scroll_compensation_adjustment; | |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 static Layer* GetTransformParent(const DataForRecursion& data, Layer* layer) { | 40 static Layer* GetTransformParent(const DataForRecursion& data, Layer* layer) { |
| 39 return layer->position_constraint().is_fixed_position() | 41 return layer->position_constraint().is_fixed_position() |
| 40 ? data.transform_fixed_parent | 42 ? data.transform_fixed_parent |
| 41 : data.transform_tree_parent; | 43 : data.transform_tree_parent; |
| 42 } | 44 } |
| 43 | 45 |
| 44 static ClipNode* GetClipParent(const DataForRecursion& data, Layer* layer) { | 46 static ClipNode* GetClipParent(const DataForRecursion& data, Layer* layer) { |
| 45 const bool inherits_clip = !layer->parent() || !layer->clip_parent(); | 47 const bool inherits_clip = !layer->parent() || !layer->clip_parent(); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 if (layer->scroll_parent()) { | 136 if (layer->scroll_parent()) { |
| 135 gfx::Transform to_parent; | 137 gfx::Transform to_parent; |
| 136 Layer* source = layer->parent(); | 138 Layer* source = layer->parent(); |
| 137 parent_offset += source->offset_to_transform_parent(); | 139 parent_offset += source->offset_to_transform_parent(); |
| 138 data_from_ancestor.transform_tree->ComputeTransform( | 140 data_from_ancestor.transform_tree->ComputeTransform( |
| 139 source->transform_tree_index(), | 141 source->transform_tree_index(), |
| 140 transform_parent->transform_tree_index(), &to_parent); | 142 transform_parent->transform_tree_index(), &to_parent); |
| 141 parent_offset += to_parent.To2dTranslation(); | 143 parent_offset += to_parent.To2dTranslation(); |
| 142 } else if (!is_fixed) { | 144 } else if (!is_fixed) { |
| 143 parent_offset = transform_parent->offset_to_transform_parent(); | 145 parent_offset = transform_parent->offset_to_transform_parent(); |
| 144 } else if (data_from_ancestor.transform_tree_parent != | 146 } else { |
| 145 data_from_ancestor.transform_fixed_parent) { | 147 if (data_from_ancestor.transform_tree_parent != |
| 146 gfx::Vector2dF fixed_offset = data_from_ancestor.transform_tree_parent | 148 data_from_ancestor.transform_fixed_parent) { |
| 147 ->offset_to_transform_parent(); | 149 gfx::Vector2dF fixed_offset = data_from_ancestor.transform_tree_parent |
| 148 gfx::Transform parent_to_parent; | 150 ->offset_to_transform_parent(); |
| 149 data_from_ancestor.transform_tree->ComputeTransform( | 151 gfx::Transform parent_to_parent; |
| 150 data_from_ancestor.transform_tree_parent->transform_tree_index(), | 152 data_from_ancestor.transform_tree->ComputeTransform( |
| 151 data_from_ancestor.transform_fixed_parent->transform_tree_index(), | 153 data_from_ancestor.transform_tree_parent->transform_tree_index(), |
| 152 &parent_to_parent); | 154 data_from_ancestor.transform_fixed_parent->transform_tree_index(), |
| 155 &parent_to_parent); | |
| 153 | 156 |
| 154 fixed_offset += parent_to_parent.To2dTranslation(); | 157 fixed_offset += parent_to_parent.To2dTranslation(); |
| 155 parent_offset += fixed_offset; | 158 parent_offset += fixed_offset; |
| 159 } | |
| 160 parent_offset += data_from_ancestor.scroll_compensation_adjustment; | |
| 156 } | 161 } |
| 157 } | 162 } |
| 158 | 163 |
| 159 if (layer->IsContainerForFixedPositionLayers() || is_root) | 164 if (layer->IsContainerForFixedPositionLayers() || is_root) |
| 160 data_for_children->transform_fixed_parent = layer; | 165 data_for_children->transform_fixed_parent = layer; |
| 161 data_for_children->transform_tree_parent = layer; | 166 data_for_children->transform_tree_parent = layer; |
| 162 | 167 |
| 168 if (layer->IsContainerForFixedPositionLayers() || is_fixed) | |
| 169 data_for_children->scroll_compensation_adjustment = gfx::Vector2d(); | |
|
ajuma
2015/03/26 18:03:25
Does clearing here when is_fixed is true work when
Ian Vollick
2015/03/30 17:51:25
It does, yeah. The current GraphicsLayer tree is c
| |
| 170 data_for_children->scroll_compensation_adjustment += | |
| 171 gfx::ToRoundedVector2d(layer->ScrollCompensationAdjustment()); | |
|
ajuma
2015/03/26 18:03:25
It's not obvious that rounding is the right thing
Ian Vollick
2015/03/30 17:51:25
You're right -- this isn't the right place for it.
| |
| 172 | |
| 163 if (!requires_node) { | 173 if (!requires_node) { |
| 164 data_for_children->should_flatten |= layer->should_flatten_transform(); | 174 data_for_children->should_flatten |= layer->should_flatten_transform(); |
| 165 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + | 175 gfx::Vector2dF local_offset = layer->position().OffsetFromOrigin() + |
| 166 layer->transform().To2dTranslation(); | 176 layer->transform().To2dTranslation(); |
| 167 layer->set_offset_to_transform_parent(parent_offset + local_offset); | 177 layer->set_offset_to_transform_parent(parent_offset + local_offset); |
| 168 layer->set_should_flatten_transform_from_property_tree( | 178 layer->set_should_flatten_transform_from_property_tree( |
| 169 data_from_ancestor.should_flatten); | 179 data_from_ancestor.should_flatten); |
| 170 layer->set_transform_tree_index(transform_parent->transform_tree_index()); | 180 layer->set_transform_tree_index(transform_parent->transform_tree_index()); |
| 171 return; | 181 return; |
| 172 } | 182 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 data_for_recursion.device_transform = &device_transform; | 329 data_for_recursion.device_transform = &device_transform; |
| 320 | 330 |
| 321 ClipNode root_clip; | 331 ClipNode root_clip; |
| 322 root_clip.data.clip = viewport; | 332 root_clip.data.clip = viewport; |
| 323 root_clip.data.transform_id = 0; | 333 root_clip.data.transform_id = 0; |
| 324 data_for_recursion.clip_tree_parent = clip_tree->Insert(root_clip, 0); | 334 data_for_recursion.clip_tree_parent = clip_tree->Insert(root_clip, 0); |
| 325 BuildPropertyTreesInternal(root_layer, data_for_recursion); | 335 BuildPropertyTreesInternal(root_layer, data_for_recursion); |
| 326 } | 336 } |
| 327 | 337 |
| 328 } // namespace cc | 338 } // namespace cc |
| OLD | NEW |