| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // the inner a different size from the outer. We'll reuse its layer | 364 // the inner a different size from the outer. We'll reuse its layer |
| 365 // hierarchy but adjust the sizing to our needs. | 365 // hierarchy but adjust the sizing to our needs. |
| 366 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); | 366 CreateScrollAndContentsLayers(host_impl_->active_tree(), content_size); |
| 367 | 367 |
| 368 LayerImpl* content_layer = host_impl_->OuterViewportScrollLayer() | 368 LayerImpl* content_layer = host_impl_->OuterViewportScrollLayer() |
| 369 ->test_properties() | 369 ->test_properties() |
| 370 ->children.back(); | 370 ->children.back(); |
| 371 content_layer->SetBounds(content_size); | 371 content_layer->SetBounds(content_size); |
| 372 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); | 372 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); |
| 373 | 373 |
| 374 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent(); | 374 LayerImpl* outer_clip = |
| 375 host_impl_->OuterViewportScrollLayer()->test_properties()->parent; |
| 375 outer_clip->SetBounds(viewport_size); | 376 outer_clip->SetBounds(viewport_size); |
| 376 | 377 |
| 377 LayerImpl* inner_clip_layer = | 378 LayerImpl* inner_clip_layer = host_impl_->InnerViewportScrollLayer() |
| 378 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 379 ->test_properties() |
| 380 ->parent->test_properties() |
| 381 ->parent; |
| 379 inner_clip_layer->SetBounds(viewport_size); | 382 inner_clip_layer->SetBounds(viewport_size); |
| 380 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); | 383 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); |
| 381 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 384 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 382 | 385 |
| 383 host_impl_->SetViewportSize(viewport_size); | 386 host_impl_->SetViewportSize(viewport_size); |
| 384 host_impl_->active_tree()->DidBecomeActive(); | 387 host_impl_->active_tree()->DidBecomeActive(); |
| 385 | 388 |
| 386 return content_layer; | 389 return content_layer; |
| 387 } | 390 } |
| 388 | 391 |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 } | 1220 } |
| 1218 | 1221 |
| 1219 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1222 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
| 1220 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1223 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1221 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1224 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1222 | 1225 |
| 1223 gfx::Size overflow_size(400, 400); | 1226 gfx::Size overflow_size(400, 400); |
| 1224 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); | 1227 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
| 1225 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; | 1228 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
| 1226 overflow->SetBounds(overflow_size); | 1229 overflow->SetBounds(overflow_size); |
| 1227 overflow->SetScrollClipLayer(scroll_layer->parent()->parent()->id()); | 1230 overflow->SetScrollClipLayer( |
| 1231 scroll_layer->test_properties()->parent->test_properties()->parent->id()); |
| 1228 overflow->layer_tree_impl() | 1232 overflow->layer_tree_impl() |
| 1229 ->property_trees() | 1233 ->property_trees() |
| 1230 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), | 1234 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), |
| 1231 gfx::ScrollOffset()); | 1235 gfx::ScrollOffset()); |
| 1232 overflow->SetPosition(gfx::PointF()); | 1236 overflow->SetPosition(gfx::PointF()); |
| 1233 | 1237 |
| 1234 SetNeedsRebuildPropertyTrees(); | 1238 SetNeedsRebuildPropertyTrees(); |
| 1235 DrawFrame(); | 1239 DrawFrame(); |
| 1236 gfx::Point scroll_position(10, 10); | 1240 gfx::Point scroll_position(10, 10); |
| 1237 | 1241 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 did_request_next_frame_ = false; | 1477 did_request_next_frame_ = false; |
| 1474 | 1478 |
| 1475 // The next frame after activating, we'll tick the animation again. | 1479 // The next frame after activating, we'll tick the animation again. |
| 1476 host_impl_->Animate(); | 1480 host_impl_->Animate(); |
| 1477 // An animation exists on the active layer. Doing Animate() requests another | 1481 // An animation exists on the active layer. Doing Animate() requests another |
| 1478 // frame after the current one. | 1482 // frame after the current one. |
| 1479 EXPECT_TRUE(did_request_next_frame_); | 1483 EXPECT_TRUE(did_request_next_frame_); |
| 1480 did_request_next_frame_ = false; | 1484 did_request_next_frame_ = false; |
| 1481 | 1485 |
| 1482 // Destroy layer, unregister animation target (element). | 1486 // Destroy layer, unregister animation target (element). |
| 1483 child->SetParent(nullptr); | 1487 child->test_properties()->parent = nullptr; |
| 1484 root->RemoveChildForTesting(child); | 1488 root->RemoveChildForTesting(child); |
| 1485 child = nullptr; | 1489 child = nullptr; |
| 1486 | 1490 |
| 1487 // Doing Animate() doesn't request another frame after the current one. | 1491 // Doing Animate() doesn't request another frame after the current one. |
| 1488 host_impl_->Animate(); | 1492 host_impl_->Animate(); |
| 1489 EXPECT_FALSE(did_request_next_frame_); | 1493 EXPECT_FALSE(did_request_next_frame_); |
| 1490 | 1494 |
| 1491 host_impl_->Animate(); | 1495 host_impl_->Animate(); |
| 1492 EXPECT_FALSE(did_request_next_frame_); | 1496 EXPECT_FALSE(did_request_next_frame_); |
| 1493 } | 1497 } |
| (...skipping 2813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4307 host_impl_->top_controls_manager()->ControlsTopOffset()); | 4311 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 4308 | 4312 |
| 4309 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4313 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 4310 EXPECT_FLOAT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4314 EXPECT_FLOAT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4311 EXPECT_FLOAT_EQ(-50.f, | 4315 EXPECT_FLOAT_EQ(-50.f, |
| 4312 host_impl_->top_controls_manager()->ControlsTopOffset()); | 4316 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 4313 | 4317 |
| 4314 host_impl_->DidChangeTopControlsPosition(); | 4318 host_impl_->DidChangeTopControlsPosition(); |
| 4315 | 4319 |
| 4316 // Now that top controls have moved, expect the clip to resize. | 4320 // Now that top controls have moved, expect the clip to resize. |
| 4317 LayerImpl* inner_clip_ptr = | 4321 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4318 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4322 ->test_properties() |
| 4323 ->parent->test_properties() |
| 4324 ->parent; |
| 4319 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4325 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4320 } | 4326 } |
| 4321 | 4327 |
| 4322 // Test that the top_controls delta and sent delta are appropriately | 4328 // Test that the top_controls delta and sent delta are appropriately |
| 4323 // applied on sync tree activation. The total top controls offset shouldn't | 4329 // applied on sync tree activation. The total top controls offset shouldn't |
| 4324 // change after the activation. | 4330 // change after the activation. |
| 4325 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { | 4331 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { |
| 4326 settings_ = DefaultSettings(); | 4332 settings_ = DefaultSettings(); |
| 4327 CreateHostImpl(settings_, CreateOutputSurface()); | 4333 CreateHostImpl(settings_, CreateOutputSurface()); |
| 4328 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4334 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4329 layer_size_, layer_size_, layer_size_); | 4335 layer_size_, layer_size_, layer_size_); |
| 4330 DrawFrame(); | 4336 DrawFrame(); |
| 4331 | 4337 |
| 4332 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4338 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4333 20.f / top_controls_height_); | 4339 20.f / top_controls_height_); |
| 4334 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4340 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4335 host_impl_->active_tree()->SetCurrentTopControlsShownRatio( | 4341 host_impl_->active_tree()->SetCurrentTopControlsShownRatio( |
| 4336 15.f / top_controls_height_); | 4342 15.f / top_controls_height_); |
| 4337 host_impl_->active_tree() | 4343 host_impl_->active_tree() |
| 4338 ->top_controls_shown_ratio() | 4344 ->top_controls_shown_ratio() |
| 4339 ->PullDeltaForMainThread(); | 4345 ->PullDeltaForMainThread(); |
| 4340 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4346 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 4341 host_impl_->sync_tree()->PushTopControlsFromMainThread(15.f / | 4347 host_impl_->sync_tree()->PushTopControlsFromMainThread(15.f / |
| 4342 top_controls_height_); | 4348 top_controls_height_); |
| 4343 | 4349 |
| 4344 host_impl_->DidChangeTopControlsPosition(); | 4350 host_impl_->DidChangeTopControlsPosition(); |
| 4345 LayerImpl* inner_clip_ptr = | 4351 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4346 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4352 ->test_properties() |
| 4353 ->parent->test_properties() |
| 4354 ->parent; |
| 4347 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4355 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4348 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4356 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4349 | 4357 |
| 4350 host_impl_->ActivateSyncTree(); | 4358 host_impl_->ActivateSyncTree(); |
| 4351 | 4359 |
| 4352 inner_clip_ptr = host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4360 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4361 ->test_properties() |
| 4362 ->parent->test_properties() |
| 4363 ->parent; |
| 4353 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4364 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4354 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4365 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4355 | 4366 |
| 4356 EXPECT_FLOAT_EQ( | 4367 EXPECT_FLOAT_EQ( |
| 4357 -15.f, host_impl_->active_tree()->top_controls_shown_ratio()->Delta() * | 4368 -15.f, host_impl_->active_tree()->top_controls_shown_ratio()->Delta() * |
| 4358 top_controls_height_); | 4369 top_controls_height_); |
| 4359 EXPECT_FLOAT_EQ( | 4370 EXPECT_FLOAT_EQ( |
| 4360 15.f, | 4371 15.f, |
| 4361 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * | 4372 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * |
| 4362 top_controls_height_); | 4373 top_controls_height_); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4375 | 4386 |
| 4376 host_impl_->sync_tree()->PushTopControlsFromMainThread(1.f); | 4387 host_impl_->sync_tree()->PushTopControlsFromMainThread(1.f); |
| 4377 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 4388 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 4378 | 4389 |
| 4379 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4390 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4380 1.f); | 4391 1.f); |
| 4381 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4392 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4382 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4393 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 4383 | 4394 |
| 4384 host_impl_->DidChangeTopControlsPosition(); | 4395 host_impl_->DidChangeTopControlsPosition(); |
| 4385 LayerImpl* inner_clip_ptr = | 4396 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4386 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4397 ->test_properties() |
| 4398 ->parent->test_properties() |
| 4399 ->parent; |
| 4387 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4400 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4388 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4401 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4389 | 4402 |
| 4390 host_impl_->sync_tree()->root_layer()->SetBounds( | 4403 host_impl_->sync_tree()->root_layer()->SetBounds( |
| 4391 gfx::Size(inner_clip_ptr->bounds().width(), | 4404 gfx::Size(inner_clip_ptr->bounds().width(), |
| 4392 inner_clip_ptr->bounds().height() - 50.f)); | 4405 inner_clip_ptr->bounds().height() - 50.f)); |
| 4393 | 4406 |
| 4394 host_impl_->ActivateSyncTree(); | 4407 host_impl_->ActivateSyncTree(); |
| 4395 | 4408 |
| 4396 inner_clip_ptr = | 4409 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4397 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4410 ->test_properties() |
| 4411 ->parent->test_properties() |
| 4412 ->parent; |
| 4398 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4413 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4399 | 4414 |
| 4400 // The total bounds should remain unchanged since the bounds delta should | 4415 // The total bounds should remain unchanged since the bounds delta should |
| 4401 // account for the difference between the layout height and the current | 4416 // account for the difference between the layout height and the current |
| 4402 // top controls offset. | 4417 // top controls offset. |
| 4403 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4418 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4404 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), inner_clip_ptr->bounds_delta()); | 4419 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), inner_clip_ptr->bounds_delta()); |
| 4405 | 4420 |
| 4406 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 4421 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 4407 host_impl_->DidChangeTopControlsPosition(); | 4422 host_impl_->DidChangeTopControlsPosition(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4605 host_impl_ | 4620 host_impl_ |
| 4606 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4621 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4607 InputHandler::TOUCHSCREEN) | 4622 InputHandler::TOUCHSCREEN) |
| 4608 .thread); | 4623 .thread); |
| 4609 | 4624 |
| 4610 host_impl_->top_controls_manager()->ScrollBegin(); | 4625 host_impl_->top_controls_manager()->ScrollBegin(); |
| 4611 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); | 4626 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); |
| 4612 host_impl_->top_controls_manager()->ScrollEnd(); | 4627 host_impl_->top_controls_manager()->ScrollEnd(); |
| 4613 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4628 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4614 // Now that top controls have moved, expect the clip to resize. | 4629 // Now that top controls have moved, expect the clip to resize. |
| 4615 LayerImpl* inner_clip_ptr = | 4630 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4616 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4631 ->test_properties() |
| 4632 ->parent->test_properties() |
| 4633 ->parent; |
| 4617 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4634 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4618 | 4635 |
| 4619 host_impl_->ScrollEnd(EndState().get()); | 4636 host_impl_->ScrollEnd(EndState().get()); |
| 4620 | 4637 |
| 4621 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4638 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4622 host_impl_ | 4639 host_impl_ |
| 4623 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4640 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4624 InputHandler::TOUCHSCREEN) | 4641 InputHandler::TOUCHSCREEN) |
| 4625 .thread); | 4642 .thread); |
| 4626 | 4643 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4875 status.main_thread_scrolling_reasons); | 4892 status.main_thread_scrolling_reasons); |
| 4876 } | 4893 } |
| 4877 | 4894 |
| 4878 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 4895 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
| 4879 gfx::Size viewport_size(20, 20); | 4896 gfx::Size viewport_size(20, 20); |
| 4880 float page_scale = 2.f; | 4897 float page_scale = 2.f; |
| 4881 | 4898 |
| 4882 SetupScrollAndContentsLayers(viewport_size); | 4899 SetupScrollAndContentsLayers(viewport_size); |
| 4883 | 4900 |
| 4884 // Setup the layers so that the outer viewport is scrollable. | 4901 // Setup the layers so that the outer viewport is scrollable. |
| 4885 host_impl_->active_tree()->InnerViewportScrollLayer()->parent()->SetBounds( | 4902 host_impl_->active_tree() |
| 4886 viewport_size); | 4903 ->InnerViewportScrollLayer() |
| 4904 ->test_properties() |
| 4905 ->parent->SetBounds(viewport_size); |
| 4887 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( | 4906 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( |
| 4888 gfx::Size(40, 40)); | 4907 gfx::Size(40, 40)); |
| 4889 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 4908 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 4890 DrawFrame(); | 4909 DrawFrame(); |
| 4891 | 4910 |
| 4892 LayerImpl* root_scroll = | 4911 LayerImpl* root_scroll = |
| 4893 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4912 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4894 LayerImpl* inner_scroll = | 4913 LayerImpl* inner_scroll = |
| 4895 host_impl_->active_tree()->InnerViewportScrollLayer(); | 4914 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 4896 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 4915 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4921 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); | 4940 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
| 4922 } | 4941 } |
| 4923 | 4942 |
| 4924 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) { | 4943 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) { |
| 4925 gfx::Size viewport_size(20, 20); | 4944 gfx::Size viewport_size(20, 20); |
| 4926 float page_scale = 2.f; | 4945 float page_scale = 2.f; |
| 4927 | 4946 |
| 4928 SetupScrollAndContentsLayers(viewport_size); | 4947 SetupScrollAndContentsLayers(viewport_size); |
| 4929 | 4948 |
| 4930 // Setup the layers so that the outer viewport is scrollable. | 4949 // Setup the layers so that the outer viewport is scrollable. |
| 4931 host_impl_->active_tree()->InnerViewportScrollLayer()->parent()->SetBounds( | 4950 host_impl_->active_tree() |
| 4932 viewport_size); | 4951 ->InnerViewportScrollLayer() |
| 4952 ->test_properties() |
| 4953 ->parent->SetBounds(viewport_size); |
| 4933 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( | 4954 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( |
| 4934 gfx::Size(40, 40)); | 4955 gfx::Size(40, 40)); |
| 4935 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 4956 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 4936 DrawFrame(); | 4957 DrawFrame(); |
| 4937 | 4958 |
| 4938 LayerImpl* root_scroll = | 4959 LayerImpl* root_scroll = |
| 4939 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4960 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4940 LayerImpl* inner_scroll = | 4961 LayerImpl* inner_scroll = |
| 4941 host_impl_->active_tree()->InnerViewportScrollLayer(); | 4962 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 4942 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 4963 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5572 } | 5593 } |
| 5573 | 5594 |
| 5574 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { | 5595 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { |
| 5575 LayerImpl* scroll_layer = | 5596 LayerImpl* scroll_layer = |
| 5576 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5597 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5577 | 5598 |
| 5578 // Scale the layer to twice its normal size. | 5599 // Scale the layer to twice its normal size. |
| 5579 int scale = 2; | 5600 int scale = 2; |
| 5580 gfx::Transform scale_transform; | 5601 gfx::Transform scale_transform; |
| 5581 scale_transform.Scale(scale, scale); | 5602 scale_transform.Scale(scale, scale); |
| 5582 scroll_layer->parent()->SetTransform(scale_transform); | 5603 scroll_layer->test_properties()->parent->SetTransform(scale_transform); |
| 5583 | 5604 |
| 5584 gfx::Size surface_size(50, 50); | 5605 gfx::Size surface_size(50, 50); |
| 5585 host_impl_->SetViewportSize(surface_size); | 5606 host_impl_->SetViewportSize(surface_size); |
| 5586 SetNeedsRebuildPropertyTrees(); | 5607 SetNeedsRebuildPropertyTrees(); |
| 5587 DrawFrame(); | 5608 DrawFrame(); |
| 5588 | 5609 |
| 5589 // Scroll down in screen coordinates with a gesture. | 5610 // Scroll down in screen coordinates with a gesture. |
| 5590 gfx::Vector2d scroll_delta(0, 10); | 5611 gfx::Vector2d scroll_delta(0, 10); |
| 5591 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5612 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5592 host_impl_ | 5613 host_impl_ |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5697 gfx::SizeF scrollable_size_; | 5718 gfx::SizeF scrollable_size_; |
| 5698 float page_scale_factor_; | 5719 float page_scale_factor_; |
| 5699 float min_page_scale_factor_; | 5720 float min_page_scale_factor_; |
| 5700 float max_page_scale_factor_; | 5721 float max_page_scale_factor_; |
| 5701 }; | 5722 }; |
| 5702 | 5723 |
| 5703 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { | 5724 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
| 5704 TestInputHandlerClient scroll_watcher; | 5725 TestInputHandlerClient scroll_watcher; |
| 5705 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 5726 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
| 5706 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5727 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5707 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 5728 LayerImpl* clip_layer = |
| 5729 scroll_layer->test_properties()->parent->test_properties()->parent; |
| 5708 SetNeedsRebuildPropertyTrees(); | 5730 SetNeedsRebuildPropertyTrees(); |
| 5709 clip_layer->SetBounds(gfx::Size(10, 20)); | 5731 clip_layer->SetBounds(gfx::Size(10, 20)); |
| 5710 RebuildPropertyTrees(); | 5732 RebuildPropertyTrees(); |
| 5711 | 5733 |
| 5712 host_impl_->BindToClient(&scroll_watcher); | 5734 host_impl_->BindToClient(&scroll_watcher); |
| 5713 | 5735 |
| 5714 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); | 5736 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); |
| 5715 scroll_layer->layer_tree_impl() | 5737 scroll_layer->layer_tree_impl() |
| 5716 ->property_trees() | 5738 ->property_trees() |
| 5717 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 5739 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5808 gfx::Point translated_point; | 5830 gfx::Point translated_point; |
| 5809 target_space_transform.TransformPoint(&translated_point); | 5831 target_space_transform.TransformPoint(&translated_point); |
| 5810 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); | 5832 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); |
| 5811 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); | 5833 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); |
| 5812 } | 5834 } |
| 5813 | 5835 |
| 5814 TEST_F(LayerTreeHostImplTest, | 5836 TEST_F(LayerTreeHostImplTest, |
| 5815 ExternalRootLayerScrollOffsetDelegationReflectedInNextDraw) { | 5837 ExternalRootLayerScrollOffsetDelegationReflectedInNextDraw) { |
| 5816 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 5838 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
| 5817 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5839 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5818 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 5840 LayerImpl* clip_layer = |
| 5841 scroll_layer->test_properties()->parent->test_properties()->parent; |
| 5819 clip_layer->SetBounds(gfx::Size(10, 20)); | 5842 clip_layer->SetBounds(gfx::Size(10, 20)); |
| 5820 scroll_layer->SetDrawsContent(true); | 5843 scroll_layer->SetDrawsContent(true); |
| 5821 | 5844 |
| 5822 // Draw first frame to clear any pending draws and check scroll. | 5845 // Draw first frame to clear any pending draws and check scroll. |
| 5823 DrawFrame(); | 5846 DrawFrame(); |
| 5824 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); | 5847 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); |
| 5825 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); | 5848 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); |
| 5826 | 5849 |
| 5827 // Set external scroll delta on delegate and notify LayerTreeHost. | 5850 // Set external scroll delta on delegate and notify LayerTreeHost. |
| 5828 gfx::ScrollOffset scroll_offset(10.f, 10.f); | 5851 gfx::ScrollOffset scroll_offset(10.f, 10.f); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6080 host_impl_->ScrollEnd(EndState().get()); | 6103 host_impl_->ScrollEnd(EndState().get()); |
| 6081 } | 6104 } |
| 6082 } | 6105 } |
| 6083 | 6106 |
| 6084 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 6107 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
| 6085 InputHandlerScrollResult scroll_result; | 6108 InputHandlerScrollResult scroll_result; |
| 6086 LayerTreeSettings settings = DefaultSettings(); | 6109 LayerTreeSettings settings = DefaultSettings(); |
| 6087 CreateHostImpl(settings, CreateOutputSurface()); | 6110 CreateHostImpl(settings, CreateOutputSurface()); |
| 6088 | 6111 |
| 6089 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 6112 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
| 6090 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 6113 LayerImpl* clip_layer = |
| 6114 scroll_layer->test_properties()->parent->test_properties()->parent; |
| 6091 clip_layer->SetBounds(gfx::Size(50, 50)); | 6115 clip_layer->SetBounds(gfx::Size(50, 50)); |
| 6092 SetNeedsRebuildPropertyTrees(); | 6116 SetNeedsRebuildPropertyTrees(); |
| 6093 RebuildPropertyTrees(); | 6117 RebuildPropertyTrees(); |
| 6094 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6118 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 6095 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6119 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 6096 DrawFrame(); | 6120 DrawFrame(); |
| 6097 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6121 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6098 | 6122 |
| 6099 // Even though the layer can't scroll the overscroll still happens. | 6123 // Even though the layer can't scroll the overscroll still happens. |
| 6100 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6124 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| (...skipping 4733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10834 | 10858 |
| 10835 // Re-initialize with a software output surface. | 10859 // Re-initialize with a software output surface. |
| 10836 output_surface_ = FakeOutputSurface::CreateSoftware( | 10860 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10837 base::WrapUnique(new SoftwareOutputDevice)); | 10861 base::WrapUnique(new SoftwareOutputDevice)); |
| 10838 host_impl_->InitializeRenderer(output_surface_.get()); | 10862 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10839 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10863 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10840 } | 10864 } |
| 10841 | 10865 |
| 10842 } // namespace | 10866 } // namespace |
| 10843 } // namespace cc | 10867 } // namespace cc |
| OLD | NEW |