Chromium Code Reviews| 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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2013 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( | 2017 host_impl_->QueueSwapPromiseForMainThreadScrollUpdate( |
| 2014 std::move(swap_promise)); | 2018 std::move(swap_promise)); |
| 2015 host_impl_->ScrollEnd(EndState().get()); | 2019 host_impl_->ScrollEnd(EndState().get()); |
| 2016 | 2020 |
| 2017 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 2021 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 2018 host_impl_->ProcessScrollDeltas(); | 2022 host_impl_->ProcessScrollDeltas(); |
| 2019 EXPECT_EQ(1u, scroll_info->swap_promises.size()); | 2023 EXPECT_EQ(1u, scroll_info->swap_promises.size()); |
| 2020 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); | 2024 EXPECT_EQ(latency_info.trace_id(), scroll_info->swap_promises[0]->TraceId()); |
| 2021 } | 2025 } |
| 2022 | 2026 |
| 2023 // Test that scrolls targeting a layer with a non-null scroll_parent() don't | 2027 // Test that scrolls targeting a layer with a non-null |
| 2028 // scroll_test_properties()->parent don't | |
|
ajuma
2016/06/10 22:32:58
This should still say 'scroll_parent'
jaydasika
2016/06/15 09:18:39
Done.
| |
| 2024 // bubble up. | 2029 // bubble up. |
| 2025 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { | 2030 TEST_F(LayerTreeHostImplTest, ScrollDoesntBubble) { |
| 2026 LayerImpl* viewport_scroll = | 2031 LayerImpl* viewport_scroll = |
| 2027 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 2032 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 2028 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 2033 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 2029 | 2034 |
| 2030 // Set up two scrolling children of the root, one of which is a scroll parent | 2035 // Set up two scrolling children of the root, one of which is a scroll parent |
| 2031 // to the other. Scrolls shouldn't bubbling from the child. | 2036 // to the other. Scrolls shouldn't bubbling from the child. |
| 2032 LayerImpl *parent; | 2037 LayerImpl *parent; |
| 2033 LayerImpl *child; | 2038 LayerImpl *child; |
| (...skipping 2273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4307 host_impl_->top_controls_manager()->ControlsTopOffset()); | 4312 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 4308 | 4313 |
| 4309 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4314 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 4310 EXPECT_FLOAT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4315 EXPECT_FLOAT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4311 EXPECT_FLOAT_EQ(-50.f, | 4316 EXPECT_FLOAT_EQ(-50.f, |
| 4312 host_impl_->top_controls_manager()->ControlsTopOffset()); | 4317 host_impl_->top_controls_manager()->ControlsTopOffset()); |
| 4313 | 4318 |
| 4314 host_impl_->DidChangeTopControlsPosition(); | 4319 host_impl_->DidChangeTopControlsPosition(); |
| 4315 | 4320 |
| 4316 // Now that top controls have moved, expect the clip to resize. | 4321 // Now that top controls have moved, expect the clip to resize. |
| 4317 LayerImpl* inner_clip_ptr = | 4322 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4318 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4323 ->test_properties() |
| 4324 ->parent->test_properties() | |
| 4325 ->parent; | |
| 4319 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4326 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4320 } | 4327 } |
| 4321 | 4328 |
| 4322 // Test that the top_controls delta and sent delta are appropriately | 4329 // Test that the top_controls delta and sent delta are appropriately |
| 4323 // applied on sync tree activation. The total top controls offset shouldn't | 4330 // applied on sync tree activation. The total top controls offset shouldn't |
| 4324 // change after the activation. | 4331 // change after the activation. |
| 4325 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { | 4332 TEST_F(LayerTreeHostImplTopControlsTest, ApplyDeltaOnTreeActivation) { |
| 4326 settings_ = DefaultSettings(); | 4333 settings_ = DefaultSettings(); |
| 4327 CreateHostImpl(settings_, CreateOutputSurface()); | 4334 CreateHostImpl(settings_, CreateOutputSurface()); |
| 4328 SetupTopControlsAndScrollLayerWithVirtualViewport( | 4335 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 4329 layer_size_, layer_size_, layer_size_); | 4336 layer_size_, layer_size_, layer_size_); |
| 4330 DrawFrame(); | 4337 DrawFrame(); |
| 4331 | 4338 |
| 4332 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4339 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4333 20.f / top_controls_height_); | 4340 20.f / top_controls_height_); |
| 4334 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4341 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4335 host_impl_->active_tree()->SetCurrentTopControlsShownRatio( | 4342 host_impl_->active_tree()->SetCurrentTopControlsShownRatio( |
| 4336 15.f / top_controls_height_); | 4343 15.f / top_controls_height_); |
| 4337 host_impl_->active_tree() | 4344 host_impl_->active_tree() |
| 4338 ->top_controls_shown_ratio() | 4345 ->top_controls_shown_ratio() |
| 4339 ->PullDeltaForMainThread(); | 4346 ->PullDeltaForMainThread(); |
| 4340 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4347 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 4341 host_impl_->sync_tree()->PushTopControlsFromMainThread(15.f / | 4348 host_impl_->sync_tree()->PushTopControlsFromMainThread(15.f / |
| 4342 top_controls_height_); | 4349 top_controls_height_); |
| 4343 | 4350 |
| 4344 host_impl_->DidChangeTopControlsPosition(); | 4351 host_impl_->DidChangeTopControlsPosition(); |
| 4345 LayerImpl* inner_clip_ptr = | 4352 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4346 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4353 ->test_properties() |
| 4354 ->parent->test_properties() | |
| 4355 ->parent; | |
| 4347 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4356 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4348 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4357 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4349 | 4358 |
| 4350 host_impl_->ActivateSyncTree(); | 4359 host_impl_->ActivateSyncTree(); |
| 4351 | 4360 |
| 4352 inner_clip_ptr = host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4361 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4362 ->test_properties() | |
| 4363 ->parent->test_properties() | |
| 4364 ->parent; | |
| 4353 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4365 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4354 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4366 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4355 | 4367 |
| 4356 EXPECT_FLOAT_EQ( | 4368 EXPECT_FLOAT_EQ( |
| 4357 -15.f, host_impl_->active_tree()->top_controls_shown_ratio()->Delta() * | 4369 -15.f, host_impl_->active_tree()->top_controls_shown_ratio()->Delta() * |
| 4358 top_controls_height_); | 4370 top_controls_height_); |
| 4359 EXPECT_FLOAT_EQ( | 4371 EXPECT_FLOAT_EQ( |
| 4360 15.f, | 4372 15.f, |
| 4361 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * | 4373 host_impl_->active_tree()->top_controls_shown_ratio()->ActiveBase() * |
| 4362 top_controls_height_); | 4374 top_controls_height_); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 4375 | 4387 |
| 4376 host_impl_->sync_tree()->PushTopControlsFromMainThread(1.f); | 4388 host_impl_->sync_tree()->PushTopControlsFromMainThread(1.f); |
| 4377 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); | 4389 host_impl_->sync_tree()->set_top_controls_shrink_blink_size(true); |
| 4378 | 4390 |
| 4379 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( | 4391 host_impl_->active_tree()->top_controls_shown_ratio()->PushFromMainThread( |
| 4380 1.f); | 4392 1.f); |
| 4381 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); | 4393 host_impl_->active_tree()->top_controls_shown_ratio()->PushPendingToActive(); |
| 4382 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); | 4394 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(0.f); |
| 4383 | 4395 |
| 4384 host_impl_->DidChangeTopControlsPosition(); | 4396 host_impl_->DidChangeTopControlsPosition(); |
| 4385 LayerImpl* inner_clip_ptr = | 4397 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4386 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4398 ->test_properties() |
| 4399 ->parent->test_properties() | |
| 4400 ->parent; | |
| 4387 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4401 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4388 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4402 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4389 | 4403 |
| 4390 host_impl_->sync_tree()->root_layer()->SetBounds( | 4404 host_impl_->sync_tree()->root_layer()->SetBounds( |
| 4391 gfx::Size(inner_clip_ptr->bounds().width(), | 4405 gfx::Size(inner_clip_ptr->bounds().width(), |
| 4392 inner_clip_ptr->bounds().height() - 50.f)); | 4406 inner_clip_ptr->bounds().height() - 50.f)); |
| 4393 | 4407 |
| 4394 host_impl_->ActivateSyncTree(); | 4408 host_impl_->ActivateSyncTree(); |
| 4395 | 4409 |
| 4396 inner_clip_ptr = | 4410 inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4397 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4411 ->test_properties() |
| 4412 ->parent->test_properties() | |
| 4413 ->parent; | |
| 4398 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4414 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4399 | 4415 |
| 4400 // The total bounds should remain unchanged since the bounds delta should | 4416 // The total bounds should remain unchanged since the bounds delta should |
| 4401 // account for the difference between the layout height and the current | 4417 // account for the difference between the layout height and the current |
| 4402 // top controls offset. | 4418 // top controls offset. |
| 4403 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4419 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4404 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), inner_clip_ptr->bounds_delta()); | 4420 EXPECT_VECTOR_EQ(gfx::Vector2dF(0.f, 50.f), inner_clip_ptr->bounds_delta()); |
| 4405 | 4421 |
| 4406 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); | 4422 host_impl_->active_tree()->SetCurrentTopControlsShownRatio(1.f); |
| 4407 host_impl_->DidChangeTopControlsPosition(); | 4423 host_impl_->DidChangeTopControlsPosition(); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4605 host_impl_ | 4621 host_impl_ |
| 4606 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4622 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4607 InputHandler::TOUCHSCREEN) | 4623 InputHandler::TOUCHSCREEN) |
| 4608 .thread); | 4624 .thread); |
| 4609 | 4625 |
| 4610 host_impl_->top_controls_manager()->ScrollBegin(); | 4626 host_impl_->top_controls_manager()->ScrollBegin(); |
| 4611 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); | 4627 host_impl_->top_controls_manager()->ScrollBy(gfx::Vector2dF(0.f, 50.f)); |
| 4612 host_impl_->top_controls_manager()->ScrollEnd(); | 4628 host_impl_->top_controls_manager()->ScrollEnd(); |
| 4613 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); | 4629 EXPECT_EQ(0.f, host_impl_->top_controls_manager()->ContentTopOffset()); |
| 4614 // Now that top controls have moved, expect the clip to resize. | 4630 // Now that top controls have moved, expect the clip to resize. |
| 4615 LayerImpl* inner_clip_ptr = | 4631 LayerImpl* inner_clip_ptr = host_impl_->InnerViewportScrollLayer() |
| 4616 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 4632 ->test_properties() |
| 4633 ->parent->test_properties() | |
| 4634 ->parent; | |
| 4617 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); | 4635 EXPECT_EQ(viewport_size_, inner_clip_ptr->bounds()); |
| 4618 | 4636 |
| 4619 host_impl_->ScrollEnd(EndState().get()); | 4637 host_impl_->ScrollEnd(EndState().get()); |
| 4620 | 4638 |
| 4621 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 4639 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 4622 host_impl_ | 4640 host_impl_ |
| 4623 ->ScrollBegin(BeginState(gfx::Point()).get(), | 4641 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 4624 InputHandler::TOUCHSCREEN) | 4642 InputHandler::TOUCHSCREEN) |
| 4625 .thread); | 4643 .thread); |
| 4626 | 4644 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4875 status.main_thread_scrolling_reasons); | 4893 status.main_thread_scrolling_reasons); |
| 4876 } | 4894 } |
| 4877 | 4895 |
| 4878 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { | 4896 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnMainThread) { |
| 4879 gfx::Size viewport_size(20, 20); | 4897 gfx::Size viewport_size(20, 20); |
| 4880 float page_scale = 2.f; | 4898 float page_scale = 2.f; |
| 4881 | 4899 |
| 4882 SetupScrollAndContentsLayers(viewport_size); | 4900 SetupScrollAndContentsLayers(viewport_size); |
| 4883 | 4901 |
| 4884 // Setup the layers so that the outer viewport is scrollable. | 4902 // Setup the layers so that the outer viewport is scrollable. |
| 4885 host_impl_->active_tree()->InnerViewportScrollLayer()->parent()->SetBounds( | 4903 host_impl_->active_tree() |
| 4886 viewport_size); | 4904 ->InnerViewportScrollLayer() |
| 4905 ->test_properties() | |
| 4906 ->parent->SetBounds(viewport_size); | |
| 4887 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( | 4907 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( |
| 4888 gfx::Size(40, 40)); | 4908 gfx::Size(40, 40)); |
| 4889 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 4909 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 4890 DrawFrame(); | 4910 DrawFrame(); |
| 4891 | 4911 |
| 4892 LayerImpl* root_scroll = | 4912 LayerImpl* root_scroll = |
| 4893 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4913 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4894 LayerImpl* inner_scroll = | 4914 LayerImpl* inner_scroll = |
| 4895 host_impl_->active_tree()->InnerViewportScrollLayer(); | 4915 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 4896 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 4916 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()); | 4941 EXPECT_EQ(1.f, host_impl_->active_tree()->page_scale_delta()); |
| 4922 } | 4942 } |
| 4923 | 4943 |
| 4924 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) { | 4944 TEST_F(LayerTreeHostImplTest, ScrollRootAndChangePageScaleOnImplThread) { |
| 4925 gfx::Size viewport_size(20, 20); | 4945 gfx::Size viewport_size(20, 20); |
| 4926 float page_scale = 2.f; | 4946 float page_scale = 2.f; |
| 4927 | 4947 |
| 4928 SetupScrollAndContentsLayers(viewport_size); | 4948 SetupScrollAndContentsLayers(viewport_size); |
| 4929 | 4949 |
| 4930 // Setup the layers so that the outer viewport is scrollable. | 4950 // Setup the layers so that the outer viewport is scrollable. |
| 4931 host_impl_->active_tree()->InnerViewportScrollLayer()->parent()->SetBounds( | 4951 host_impl_->active_tree() |
| 4932 viewport_size); | 4952 ->InnerViewportScrollLayer() |
| 4953 ->test_properties() | |
| 4954 ->parent->SetBounds(viewport_size); | |
| 4933 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( | 4955 host_impl_->active_tree()->OuterViewportScrollLayer()->SetBounds( |
| 4934 gfx::Size(40, 40)); | 4956 gfx::Size(40, 40)); |
| 4935 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); | 4957 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 2.f); |
| 4936 DrawFrame(); | 4958 DrawFrame(); |
| 4937 | 4959 |
| 4938 LayerImpl* root_scroll = | 4960 LayerImpl* root_scroll = |
| 4939 host_impl_->active_tree()->OuterViewportScrollLayer(); | 4961 host_impl_->active_tree()->OuterViewportScrollLayer(); |
| 4940 LayerImpl* inner_scroll = | 4962 LayerImpl* inner_scroll = |
| 4941 host_impl_->active_tree()->InnerViewportScrollLayer(); | 4963 host_impl_->active_tree()->InnerViewportScrollLayer(); |
| 4942 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); | 4964 EXPECT_EQ(viewport_size, root_scroll->scroll_clip_layer()->bounds()); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5572 } | 5594 } |
| 5573 | 5595 |
| 5574 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { | 5596 TEST_F(LayerTreeHostImplTest, ScrollScaledLayer) { |
| 5575 LayerImpl* scroll_layer = | 5597 LayerImpl* scroll_layer = |
| 5576 SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5598 SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5577 | 5599 |
| 5578 // Scale the layer to twice its normal size. | 5600 // Scale the layer to twice its normal size. |
| 5579 int scale = 2; | 5601 int scale = 2; |
| 5580 gfx::Transform scale_transform; | 5602 gfx::Transform scale_transform; |
| 5581 scale_transform.Scale(scale, scale); | 5603 scale_transform.Scale(scale, scale); |
| 5582 scroll_layer->parent()->SetTransform(scale_transform); | 5604 scroll_layer->test_properties()->parent->SetTransform(scale_transform); |
| 5583 | 5605 |
| 5584 gfx::Size surface_size(50, 50); | 5606 gfx::Size surface_size(50, 50); |
| 5585 host_impl_->SetViewportSize(surface_size); | 5607 host_impl_->SetViewportSize(surface_size); |
| 5586 SetNeedsRebuildPropertyTrees(); | 5608 SetNeedsRebuildPropertyTrees(); |
| 5587 DrawFrame(); | 5609 DrawFrame(); |
| 5588 | 5610 |
| 5589 // Scroll down in screen coordinates with a gesture. | 5611 // Scroll down in screen coordinates with a gesture. |
| 5590 gfx::Vector2d scroll_delta(0, 10); | 5612 gfx::Vector2d scroll_delta(0, 10); |
| 5591 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5613 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5592 host_impl_ | 5614 host_impl_ |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5697 gfx::SizeF scrollable_size_; | 5719 gfx::SizeF scrollable_size_; |
| 5698 float page_scale_factor_; | 5720 float page_scale_factor_; |
| 5699 float min_page_scale_factor_; | 5721 float min_page_scale_factor_; |
| 5700 float max_page_scale_factor_; | 5722 float max_page_scale_factor_; |
| 5701 }; | 5723 }; |
| 5702 | 5724 |
| 5703 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { | 5725 TEST_F(LayerTreeHostImplTest, RootLayerScrollOffsetDelegation) { |
| 5704 TestInputHandlerClient scroll_watcher; | 5726 TestInputHandlerClient scroll_watcher; |
| 5705 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 5727 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
| 5706 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5728 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5707 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 5729 LayerImpl* clip_layer = |
| 5730 scroll_layer->test_properties()->parent->test_properties()->parent; | |
| 5708 SetNeedsRebuildPropertyTrees(); | 5731 SetNeedsRebuildPropertyTrees(); |
| 5709 clip_layer->SetBounds(gfx::Size(10, 20)); | 5732 clip_layer->SetBounds(gfx::Size(10, 20)); |
| 5710 RebuildPropertyTrees(); | 5733 RebuildPropertyTrees(); |
| 5711 | 5734 |
| 5712 host_impl_->BindToClient(&scroll_watcher); | 5735 host_impl_->BindToClient(&scroll_watcher); |
| 5713 | 5736 |
| 5714 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); | 5737 gfx::Vector2dF initial_scroll_delta(10.f, 10.f); |
| 5715 scroll_layer->layer_tree_impl() | 5738 scroll_layer->layer_tree_impl() |
| 5716 ->property_trees() | 5739 ->property_trees() |
| 5717 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), | 5740 ->scroll_tree.UpdateScrollOffsetBaseForTesting(scroll_layer->id(), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5808 gfx::Point translated_point; | 5831 gfx::Point translated_point; |
| 5809 target_space_transform.TransformPoint(&translated_point); | 5832 target_space_transform.TransformPoint(&translated_point); |
| 5810 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); | 5833 gfx::Point expected_point = gfx::Point() - ToRoundedVector2d(scroll_delta); |
| 5811 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); | 5834 EXPECT_EQ(expected_point.ToString(), translated_point.ToString()); |
| 5812 } | 5835 } |
| 5813 | 5836 |
| 5814 TEST_F(LayerTreeHostImplTest, | 5837 TEST_F(LayerTreeHostImplTest, |
| 5815 ExternalRootLayerScrollOffsetDelegationReflectedInNextDraw) { | 5838 ExternalRootLayerScrollOffsetDelegationReflectedInNextDraw) { |
| 5816 host_impl_->SetViewportSize(gfx::Size(10, 20)); | 5839 host_impl_->SetViewportSize(gfx::Size(10, 20)); |
| 5817 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); | 5840 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 5818 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 5841 LayerImpl* clip_layer = |
| 5842 scroll_layer->test_properties()->parent->test_properties()->parent; | |
| 5819 clip_layer->SetBounds(gfx::Size(10, 20)); | 5843 clip_layer->SetBounds(gfx::Size(10, 20)); |
| 5820 scroll_layer->SetDrawsContent(true); | 5844 scroll_layer->SetDrawsContent(true); |
| 5821 | 5845 |
| 5822 // Draw first frame to clear any pending draws and check scroll. | 5846 // Draw first frame to clear any pending draws and check scroll. |
| 5823 DrawFrame(); | 5847 DrawFrame(); |
| 5824 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); | 5848 CheckLayerScrollDelta(scroll_layer, gfx::Vector2dF(0.f, 0.f)); |
| 5825 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); | 5849 EXPECT_FALSE(host_impl_->active_tree()->needs_update_draw_properties()); |
| 5826 | 5850 |
| 5827 // Set external scroll delta on delegate and notify LayerTreeHost. | 5851 // Set external scroll delta on delegate and notify LayerTreeHost. |
| 5828 gfx::ScrollOffset scroll_offset(10.f, 10.f); | 5852 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()); | 6104 host_impl_->ScrollEnd(EndState().get()); |
| 6081 } | 6105 } |
| 6082 } | 6106 } |
| 6083 | 6107 |
| 6084 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { | 6108 TEST_F(LayerTreeHostImplTest, OverscrollAlways) { |
| 6085 InputHandlerScrollResult scroll_result; | 6109 InputHandlerScrollResult scroll_result; |
| 6086 LayerTreeSettings settings = DefaultSettings(); | 6110 LayerTreeSettings settings = DefaultSettings(); |
| 6087 CreateHostImpl(settings, CreateOutputSurface()); | 6111 CreateHostImpl(settings, CreateOutputSurface()); |
| 6088 | 6112 |
| 6089 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); | 6113 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(50, 50)); |
| 6090 LayerImpl* clip_layer = scroll_layer->parent()->parent(); | 6114 LayerImpl* clip_layer = |
| 6115 scroll_layer->test_properties()->parent->test_properties()->parent; | |
| 6091 clip_layer->SetBounds(gfx::Size(50, 50)); | 6116 clip_layer->SetBounds(gfx::Size(50, 50)); |
| 6092 SetNeedsRebuildPropertyTrees(); | 6117 SetNeedsRebuildPropertyTrees(); |
| 6093 RebuildPropertyTrees(); | 6118 RebuildPropertyTrees(); |
| 6094 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 6119 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 6095 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); | 6120 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); |
| 6096 DrawFrame(); | 6121 DrawFrame(); |
| 6097 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); | 6122 EXPECT_EQ(gfx::Vector2dF(), host_impl_->accumulated_root_overscroll()); |
| 6098 | 6123 |
| 6099 // Even though the layer can't scroll the overscroll still happens. | 6124 // Even though the layer can't scroll the overscroll still happens. |
| 6100 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 6125 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| (...skipping 4728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10829 | 10854 |
| 10830 // Re-initialize with a software output surface. | 10855 // Re-initialize with a software output surface. |
| 10831 output_surface_ = FakeOutputSurface::CreateSoftware( | 10856 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10832 base::WrapUnique(new SoftwareOutputDevice)); | 10857 base::WrapUnique(new SoftwareOutputDevice)); |
| 10833 host_impl_->InitializeRenderer(output_surface_.get()); | 10858 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10834 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10859 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10835 } | 10860 } |
| 10836 | 10861 |
| 10837 } // namespace | 10862 } // namespace |
| 10838 } // namespace cc | 10863 } // namespace cc |
| OLD | NEW |