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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 false); | 338 false); |
339 scoped_ptr<LayerImpl> clip_layer_scoped_ptr( | 339 scoped_ptr<LayerImpl> clip_layer_scoped_ptr( |
340 LayerImpl::Create(host_impl.active_tree(), 4)); | 340 LayerImpl::Create(host_impl.active_tree(), 4)); |
341 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); | 341 LayerImpl* clip_layer = clip_layer_scoped_ptr.get(); |
342 | 342 |
343 scroll_layer->SetScrollClipLayer(clip_layer->id()); | 343 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
344 clip_layer->SetBounds( | 344 clip_layer->SetBounds( |
345 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), | 345 gfx::Size(scroll_layer->bounds().width() + kMaxScrollOffset.x(), |
346 scroll_layer->bounds().height() + kMaxScrollOffset.y())); | 346 scroll_layer->bounds().height() + kMaxScrollOffset.y())); |
347 scroll_layer->SetScrollClipLayer(clip_layer->id()); | 347 scroll_layer->SetScrollClipLayer(clip_layer->id()); |
348 scroll_layer->SetScrollDelta(kScrollDelta); | 348 SetScrollOffsetDelta(scroll_layer, kScrollDelta); |
349 gfx::Transform impl_transform; | 349 gfx::Transform impl_transform; |
350 scroll_layer->AddChild(std::move(sublayer_scoped_ptr)); | 350 scroll_layer->AddChild(std::move(sublayer_scoped_ptr)); |
351 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); | 351 LayerImpl* scroll_layer_raw_ptr = scroll_layer_scoped_ptr.get(); |
352 clip_layer->AddChild(std::move(scroll_layer_scoped_ptr)); | 352 clip_layer->AddChild(std::move(scroll_layer_scoped_ptr)); |
353 scroll_layer_raw_ptr->PushScrollOffsetFromMainThread(kScrollOffset); | 353 scroll_layer_raw_ptr->layer_tree_impl() |
354 ->property_trees() | |
355 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer_raw_ptr->id(), | |
356 kScrollOffset); | |
354 | 357 |
355 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); | 358 scoped_ptr<LayerImpl> root(LayerImpl::Create(host_impl.active_tree(), 3)); |
356 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), | 359 SetLayerPropertiesForTesting(root.get(), identity_matrix, gfx::Point3F(), |
357 gfx::PointF(), gfx::Size(3, 4), true, false, | 360 gfx::PointF(), gfx::Size(3, 4), true, false, |
358 false); | 361 false); |
359 root->AddChild(std::move(clip_layer_scoped_ptr)); | 362 root->AddChild(std::move(clip_layer_scoped_ptr)); |
360 root->SetHasRenderSurface(true); | 363 root->SetHasRenderSurface(true); |
361 | 364 |
362 ExecuteCalculateDrawProperties( | 365 ExecuteCalculateDrawProperties( |
363 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); | 366 root.get(), kDeviceScale, kPageScale, scroll_layer->parent()); |
(...skipping 6742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7106 // + container | 7109 // + container |
7107 // + scroller | 7110 // + scroller |
7108 // + fixed | 7111 // + fixed |
7109 // | 7112 // |
7110 FakeImplTaskRunnerProvider task_runner_provider; | 7113 FakeImplTaskRunnerProvider task_runner_provider; |
7111 TestSharedBitmapManager shared_bitmap_manager; | 7114 TestSharedBitmapManager shared_bitmap_manager; |
7112 TestTaskGraphRunner task_graph_runner; | 7115 TestTaskGraphRunner task_graph_runner; |
7113 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 7116 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
7114 &task_graph_runner); | 7117 &task_graph_runner); |
7115 host_impl.CreatePendingTree(); | 7118 host_impl.CreatePendingTree(); |
7116 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | 7119 scoped_ptr<LayerImpl> root_ptr = |
7120 LayerImpl::Create(host_impl.active_tree(), 1); | |
7121 LayerImpl* root = root_ptr.get(); | |
7117 scoped_ptr<LayerImpl> container = | 7122 scoped_ptr<LayerImpl> container = |
7118 LayerImpl::Create(host_impl.active_tree(), 2); | 7123 LayerImpl::Create(host_impl.active_tree(), 2); |
7119 LayerImpl* container_layer = container.get(); | 7124 LayerImpl* container_layer = container.get(); |
7120 scoped_ptr<LayerImpl> scroller = | 7125 scoped_ptr<LayerImpl> scroller = |
7121 LayerImpl::Create(host_impl.active_tree(), 3); | 7126 LayerImpl::Create(host_impl.active_tree(), 3); |
7122 LayerImpl* scroll_layer = scroller.get(); | 7127 LayerImpl* scroll_layer = scroller.get(); |
7123 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4); | 7128 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4); |
7124 LayerImpl* fixed_layer = fixed.get(); | 7129 LayerImpl* fixed_layer = fixed.get(); |
7125 | 7130 |
7126 container->SetIsContainerForFixedPositionLayers(true); | 7131 container->SetIsContainerForFixedPositionLayers(true); |
7127 | 7132 |
7128 LayerPositionConstraint constraint; | 7133 LayerPositionConstraint constraint; |
7129 constraint.set_is_fixed_position(true); | 7134 constraint.set_is_fixed_position(true); |
7130 fixed->SetPositionConstraint(constraint); | 7135 fixed->SetPositionConstraint(constraint); |
7131 | 7136 |
7132 scroller->SetScrollClipLayer(container->id()); | 7137 scroller->SetScrollClipLayer(container->id()); |
7133 | 7138 |
7134 gfx::Transform identity_transform; | 7139 gfx::Transform identity_transform; |
7135 gfx::Transform container_transform; | 7140 gfx::Transform container_transform; |
7136 container_transform.Translate3d(10.0, 20.0, 0.0); | 7141 container_transform.Translate3d(10.0, 20.0, 0.0); |
7137 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); | 7142 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); |
7138 | 7143 |
7139 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), | 7144 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
7140 gfx::PointF(), gfx::Size(50, 50), true, false, | 7145 gfx::PointF(), gfx::Size(50, 50), true, false, |
7141 true); | 7146 true); |
7142 SetLayerPropertiesForTesting(container.get(), container_transform, | 7147 SetLayerPropertiesForTesting(container.get(), container_transform, |
7143 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | 7148 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), |
7144 true, false, false); | 7149 true, false, false); |
7145 SetLayerPropertiesForTesting(scroller.get(), identity_transform, | 7150 SetLayerPropertiesForTesting(scroller.get(), identity_transform, |
7146 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), | 7151 gfx::Point3F(), gfx::PointF(), gfx::Size(30, 30), |
7147 true, false, false); | 7152 true, false, false); |
7148 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), | 7153 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), |
7149 gfx::PointF(), gfx::Size(50, 50), true, false, | 7154 gfx::PointF(), gfx::Size(50, 50), true, false, |
7150 false); | 7155 false); |
7151 | 7156 |
7152 root->SetDrawsContent(true); | 7157 root->SetDrawsContent(true); |
7153 container->SetDrawsContent(true); | 7158 container->SetDrawsContent(true); |
7154 scroller->SetDrawsContent(true); | 7159 scroller->SetDrawsContent(true); |
7155 fixed->SetDrawsContent(true); | 7160 fixed->SetDrawsContent(true); |
7156 scroller->AddChild(std::move(fixed)); | 7161 scroller->AddChild(std::move(fixed)); |
7157 container->AddChild(std::move(scroller)); | 7162 container->AddChild(std::move(scroller)); |
7158 root->AddChild(std::move(container)); | 7163 root->AddChild(std::move(container)); |
7159 | 7164 |
7160 // Rounded to integers already. | 7165 // Rounded to integers already. |
7161 { | 7166 { |
7167 root->layer_tree_impl()->SetRootLayer(std::move(root_ptr)); | |
7168 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | |
7162 gfx::Vector2dF scroll_delta(3.0, 5.0); | 7169 gfx::Vector2dF scroll_delta(3.0, 5.0); |
7163 scroll_layer->SetScrollDelta(scroll_delta); | 7170 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
7164 | 7171 |
7165 LayerImplList render_surface_layer_list; | 7172 LayerImplList render_surface_layer_list; |
7166 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 7173 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
7167 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7174 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7168 root.get(), root->bounds(), &render_surface_layer_list, | 7175 root, root->bounds(), &render_surface_layer_list, |
7169 root->layer_tree_impl()->current_render_surface_list_id()); | 7176 root->layer_tree_impl()->current_render_surface_list_id()); |
7177 root->layer_tree_impl() | |
7178 ->property_trees() | |
7179 ->transform_tree.set_source_to_parent_updates_allowed(false); | |
ajuma
2016/03/09 16:05:17
This is really something that should always be fal
sunxd
2016/03/09 16:41:24
No, only these two tests fail. This is understanda
ajuma
2016/03/09 16:48:41
It's mimicking building property trees, but for us
| |
7170 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7180 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7171 | 7181 |
7172 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7182 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7173 container_layer->draw_properties().screen_space_transform, | 7183 container_layer->draw_properties().screen_space_transform, |
7174 fixed_layer->draw_properties().screen_space_transform); | 7184 fixed_layer->draw_properties().screen_space_transform); |
7175 EXPECT_VECTOR_EQ( | 7185 EXPECT_VECTOR_EQ( |
7176 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7186 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7177 container_offset); | 7187 container_offset); |
7178 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 7188 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
7179 .screen_space_transform.To2dTranslation(), | 7189 .screen_space_transform.To2dTranslation(), |
7180 container_offset - scroll_delta); | 7190 container_offset - scroll_delta); |
7181 } | 7191 } |
7182 | 7192 |
7183 // Scroll delta requiring rounding. | 7193 // Scroll delta requiring rounding. |
7184 { | 7194 { |
7195 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | |
7196 | |
7185 gfx::Vector2dF scroll_delta(4.1f, 8.1f); | 7197 gfx::Vector2dF scroll_delta(4.1f, 8.1f); |
7186 scroll_layer->SetScrollDelta(scroll_delta); | 7198 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
7187 | 7199 |
7188 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); | 7200 gfx::Vector2dF rounded_scroll_delta(4.f, 8.f); |
7189 | 7201 |
7190 LayerImplList render_surface_layer_list; | 7202 LayerImplList render_surface_layer_list; |
7191 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 7203 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
7192 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7204 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7193 root.get(), root->bounds(), &render_surface_layer_list, | 7205 root, root->bounds(), &render_surface_layer_list, |
7194 root->layer_tree_impl()->current_render_surface_list_id()); | 7206 root->layer_tree_impl()->current_render_surface_list_id()); |
7207 root->layer_tree_impl() | |
7208 ->property_trees() | |
7209 ->transform_tree.set_source_to_parent_updates_allowed(false); | |
7195 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7210 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7196 | 7211 |
7197 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7212 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7198 container_layer->draw_properties().screen_space_transform, | 7213 container_layer->draw_properties().screen_space_transform, |
7199 fixed_layer->draw_properties().screen_space_transform); | 7214 fixed_layer->draw_properties().screen_space_transform); |
7200 EXPECT_VECTOR_EQ( | 7215 EXPECT_VECTOR_EQ( |
7201 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7216 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7202 container_offset); | 7217 container_offset); |
7203 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() | 7218 EXPECT_VECTOR_EQ(scroll_layer->draw_properties() |
7204 .screen_space_transform.To2dTranslation(), | 7219 .screen_space_transform.To2dTranslation(), |
7205 container_offset - rounded_scroll_delta); | 7220 container_offset - rounded_scroll_delta); |
7206 } | 7221 } |
7207 | 7222 |
7208 // Scale is applied earlier in the tree. | 7223 // Scale is applied earlier in the tree. |
7209 { | 7224 { |
7225 SetScrollOffsetDelta(scroll_layer, gfx::Vector2dF()); | |
7210 gfx::Transform scaled_container_transform = container_transform; | 7226 gfx::Transform scaled_container_transform = container_transform; |
7211 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); | 7227 scaled_container_transform.Scale3d(2.0, 2.0, 1.0); |
7212 container_layer->SetTransform(scaled_container_transform); | 7228 container_layer->SetTransform(scaled_container_transform); |
7213 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 7229 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
7214 root->layer_tree_impl() | 7230 root->layer_tree_impl() |
7215 ->property_trees() | 7231 ->property_trees() |
7216 ->transform_tree.set_source_to_parent_updates_allowed(true); | 7232 ->transform_tree.set_source_to_parent_updates_allowed(true); |
7217 | 7233 |
7234 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | |
7235 | |
7218 gfx::Vector2dF scroll_delta(4.5f, 8.5f); | 7236 gfx::Vector2dF scroll_delta(4.5f, 8.5f); |
7219 scroll_layer->SetScrollDelta(scroll_delta); | 7237 SetScrollOffsetDelta(scroll_layer, scroll_delta); |
7220 | 7238 |
7221 LayerImplList render_surface_layer_list; | 7239 LayerImplList render_surface_layer_list; |
7222 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 7240 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
7223 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7241 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7224 root.get(), root->bounds(), &render_surface_layer_list, | 7242 root, root->bounds(), &render_surface_layer_list, |
7225 root->layer_tree_impl()->current_render_surface_list_id()); | 7243 root->layer_tree_impl()->current_render_surface_list_id()); |
7244 root->layer_tree_impl() | |
7245 ->property_trees() | |
7246 ->transform_tree.set_source_to_parent_updates_allowed(false); | |
7226 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7247 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7227 | 7248 |
7228 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7249 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7229 container_layer->draw_properties().screen_space_transform, | 7250 container_layer->draw_properties().screen_space_transform, |
7230 fixed_layer->draw_properties().screen_space_transform); | 7251 fixed_layer->draw_properties().screen_space_transform); |
7231 EXPECT_VECTOR_EQ( | 7252 EXPECT_VECTOR_EQ( |
7232 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7253 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7233 container_offset); | 7254 container_offset); |
7234 | 7255 |
7235 container_layer->SetTransform(container_transform); | 7256 container_layer->SetTransform(container_transform); |
7236 } | 7257 } |
7237 } | 7258 } |
7238 | 7259 |
7239 TEST_F(LayerTreeHostCommonTest, | 7260 TEST_F(LayerTreeHostCommonTest, |
7240 ScrollCompensationMainScrollOffsetFractionalPart) { | 7261 ScrollCompensationMainScrollOffsetFractionalPart) { |
7241 // This test verifies that a scrolling layer that has fractional scroll offset | 7262 // This test verifies that a scrolling layer that has fractional scroll offset |
7242 // from main doesn't move a fixed position child. | 7263 // from main doesn't move a fixed position child. |
7243 // | 7264 // |
7244 // + root | 7265 // + root |
7245 // + container | 7266 // + container |
7246 // + scroller | 7267 // + scroller |
7247 // + fixed | 7268 // + fixed |
7248 // | 7269 // |
7249 FakeImplTaskRunnerProvider task_runner_provider; | 7270 FakeImplTaskRunnerProvider task_runner_provider; |
7250 TestSharedBitmapManager shared_bitmap_manager; | 7271 TestSharedBitmapManager shared_bitmap_manager; |
7251 TestTaskGraphRunner task_graph_runner; | 7272 TestTaskGraphRunner task_graph_runner; |
7252 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 7273 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
7253 &task_graph_runner); | 7274 &task_graph_runner); |
7254 host_impl.CreatePendingTree(); | 7275 host_impl.CreatePendingTree(); |
7255 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | 7276 scoped_ptr<LayerImpl> root_ptr = |
7277 LayerImpl::Create(host_impl.active_tree(), 1); | |
7278 LayerImpl* root = root_ptr.get(); | |
7256 scoped_ptr<LayerImpl> container = | 7279 scoped_ptr<LayerImpl> container = |
7257 LayerImpl::Create(host_impl.active_tree(), 2); | 7280 LayerImpl::Create(host_impl.active_tree(), 2); |
7258 LayerImpl* container_layer = container.get(); | 7281 LayerImpl* container_layer = container.get(); |
7259 scoped_ptr<LayerImpl> scroller = | 7282 scoped_ptr<LayerImpl> scroller = |
7260 LayerImpl::Create(host_impl.active_tree(), 3); | 7283 LayerImpl::Create(host_impl.active_tree(), 3); |
7261 LayerImpl* scroll_layer = scroller.get(); | 7284 LayerImpl* scroll_layer = scroller.get(); |
7262 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4); | 7285 scoped_ptr<LayerImpl> fixed = LayerImpl::Create(host_impl.active_tree(), 4); |
7263 LayerImpl* fixed_layer = fixed.get(); | 7286 LayerImpl* fixed_layer = fixed.get(); |
7264 | 7287 |
7265 container->SetIsContainerForFixedPositionLayers(true); | 7288 container->SetIsContainerForFixedPositionLayers(true); |
7266 | 7289 |
7267 LayerPositionConstraint constraint; | 7290 LayerPositionConstraint constraint; |
7268 constraint.set_is_fixed_position(true); | 7291 constraint.set_is_fixed_position(true); |
7269 container->SetDrawsContent(true); | 7292 container->SetDrawsContent(true); |
7270 fixed->SetDrawsContent(true); | 7293 fixed->SetDrawsContent(true); |
7271 fixed->SetPositionConstraint(constraint); | 7294 fixed->SetPositionConstraint(constraint); |
7272 | 7295 |
7273 scroller->SetDrawsContent(true); | 7296 scroller->SetDrawsContent(true); |
7274 scroller->SetScrollClipLayer(container->id()); | 7297 scroller->SetScrollClipLayer(container->id()); |
7275 | 7298 |
7276 gfx::Transform identity_transform; | 7299 gfx::Transform identity_transform; |
7277 gfx::Transform container_transform; | 7300 gfx::Transform container_transform; |
7278 container_transform.Translate3d(10.0, 20.0, 0.0); | 7301 container_transform.Translate3d(10.0, 20.0, 0.0); |
7279 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); | 7302 gfx::Vector2dF container_offset = container_transform.To2dTranslation(); |
7280 | 7303 |
7281 SetLayerPropertiesForTesting(root.get(), identity_transform, gfx::Point3F(), | 7304 SetLayerPropertiesForTesting(root, identity_transform, gfx::Point3F(), |
7282 gfx::PointF(), gfx::Size(50, 50), true, false, | 7305 gfx::PointF(), gfx::Size(50, 50), true, false, |
7283 true); | 7306 true); |
7284 SetLayerPropertiesForTesting(container.get(), container_transform, | 7307 SetLayerPropertiesForTesting(container.get(), container_transform, |
7285 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), | 7308 gfx::Point3F(), gfx::PointF(), gfx::Size(40, 40), |
7286 true, false, false); | 7309 true, false, false); |
7287 SetLayerPropertiesForTesting(scroller.get(), identity_transform, | 7310 SetLayerPropertiesForTesting(scroller.get(), identity_transform, |
7288 gfx::Point3F(), gfx::PointF(0.0, 0.0), | 7311 gfx::Point3F(), gfx::PointF(0.0, 0.0), |
7289 gfx::Size(30, 30), true, false, false); | 7312 gfx::Size(30, 30), true, false, false); |
7290 | 7313 |
7291 gfx::ScrollOffset scroll_offset(3.3, 4.2); | 7314 gfx::ScrollOffset scroll_offset(3.3, 4.2); |
7292 gfx::Vector2dF main_scroll_fractional_part(0.3f, 0.2f); | 7315 gfx::Vector2dF main_scroll_fractional_part(0.3f, 0.2f); |
7293 gfx::Vector2dF scroll_delta(0.1f, 0.4f); | 7316 gfx::Vector2dF scroll_delta(0.1f, 0.4f); |
7294 // Blink only uses the integer part of the scroll_offset for fixed | 7317 // Blink only uses the integer part of the scroll_offset for fixed |
7295 // position layer. | 7318 // position layer. |
7296 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), | 7319 SetLayerPropertiesForTesting(fixed.get(), identity_transform, gfx::Point3F(), |
7297 gfx::PointF(3.0f, 4.0f), gfx::Size(50, 50), true, | 7320 gfx::PointF(3.0f, 4.0f), gfx::Size(50, 50), true, |
7298 false, false); | 7321 false, false); |
7299 scroll_layer->PushScrollOffsetFromMainThread(scroll_offset); | 7322 scroll_layer->layer_tree_impl() |
7300 scroll_layer->SetScrollDelta(scroll_delta); | 7323 ->property_trees() |
7324 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | |
7325 scroll_offset); | |
7326 | |
7301 scroll_layer->SetScrollCompensationAdjustment(main_scroll_fractional_part); | 7327 scroll_layer->SetScrollCompensationAdjustment(main_scroll_fractional_part); |
7302 | 7328 |
7303 scroller->AddChild(std::move(fixed)); | 7329 scroller->AddChild(std::move(fixed)); |
7304 container->AddChild(std::move(scroller)); | 7330 container->AddChild(std::move(scroller)); |
7305 root->AddChild(std::move(container)); | 7331 root->AddChild(std::move(container)); |
7306 | 7332 |
7333 root->layer_tree_impl()->SetRootLayer(std::move(root_ptr)); | |
7334 root->layer_tree_impl()->BuildPropertyTreesForTesting(); | |
7335 | |
7336 SetScrollOffsetDelta(scroll_layer, scroll_delta); | |
7337 | |
7307 LayerImplList render_surface_layer_list; | 7338 LayerImplList render_surface_layer_list; |
7308 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); | 7339 root->layer_tree_impl()->IncrementRenderSurfaceListIdForTesting(); |
7309 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 7340 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
7310 root.get(), root->bounds(), &render_surface_layer_list, | 7341 root, root->bounds(), &render_surface_layer_list, |
7311 root->layer_tree_impl()->current_render_surface_list_id()); | 7342 root->layer_tree_impl()->current_render_surface_list_id()); |
7343 root->layer_tree_impl() | |
7344 ->property_trees() | |
7345 ->transform_tree.set_source_to_parent_updates_allowed(false); | |
7312 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 7346 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
7313 | 7347 |
7314 EXPECT_TRANSFORMATION_MATRIX_EQ( | 7348 EXPECT_TRANSFORMATION_MATRIX_EQ( |
7315 container_layer->draw_properties().screen_space_transform, | 7349 container_layer->draw_properties().screen_space_transform, |
7316 fixed_layer->draw_properties().screen_space_transform); | 7350 fixed_layer->draw_properties().screen_space_transform); |
7317 EXPECT_VECTOR_EQ( | 7351 EXPECT_VECTOR_EQ( |
7318 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), | 7352 fixed_layer->draw_properties().screen_space_transform.To2dTranslation(), |
7319 container_offset); | 7353 container_offset); |
7320 | 7354 |
7321 gfx::ScrollOffset effective_scroll_offset = | 7355 gfx::ScrollOffset effective_scroll_offset = |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7373 end_operations.AppendMatrix(end_scale); | 7407 end_operations.AppendMatrix(end_scale); |
7374 if (layer_settings().use_compositor_animation_timelines) { | 7408 if (layer_settings().use_compositor_animation_timelines) { |
7375 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), | 7409 AddAnimatedTransformToLayerWithPlayer(animated_layer->id(), timeline_impl(), |
7376 1.0, start_operations, | 7410 1.0, start_operations, |
7377 end_operations); | 7411 end_operations); |
7378 } else { | 7412 } else { |
7379 AddAnimatedTransformToLayer(animated_layer, 1.0, start_operations, | 7413 AddAnimatedTransformToLayer(animated_layer, 1.0, start_operations, |
7380 end_operations); | 7414 end_operations); |
7381 } | 7415 } |
7382 gfx::Vector2dF scroll_delta(5.f, 9.f); | 7416 gfx::Vector2dF scroll_delta(5.f, 9.f); |
7383 scroller->SetScrollDelta(scroll_delta); | 7417 SetScrollOffsetDelta(scroller, scroll_delta); |
7384 | 7418 |
7385 ExecuteCalculateDrawProperties(root); | 7419 ExecuteCalculateDrawProperties(root); |
7386 | 7420 |
7387 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); | 7421 gfx::Vector2dF expected_draw_transform_translation(-7.5f, -13.5f); |
7388 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, | 7422 EXPECT_VECTOR2DF_EQ(expected_draw_transform_translation, |
7389 scroller->DrawTransform().To2dTranslation()); | 7423 scroller->DrawTransform().To2dTranslation()); |
7390 } | 7424 } |
7391 | 7425 |
7392 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { | 7426 class AnimationScaleFactorTrackingLayerImpl : public LayerImpl { |
7393 public: | 7427 public: |
(...skipping 2805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10199 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10233 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10200 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10234 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10201 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10235 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10202 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10236 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10203 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10237 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10204 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10238 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10205 } | 10239 } |
10206 | 10240 |
10207 } // namespace | 10241 } // namespace |
10208 } // namespace cc | 10242 } // namespace cc |
OLD | NEW |