| 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 358 |
| 359 // Sets up a typical virtual viewport setup with one child content layer. | 359 // Sets up a typical virtual viewport setup with one child content layer. |
| 360 // Returns a pointer to the content layer. | 360 // Returns a pointer to the content layer. |
| 361 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, | 361 LayerImpl* CreateBasicVirtualViewportLayers(const gfx::Size& viewport_size, |
| 362 const gfx::Size& content_size) { | 362 const gfx::Size& content_size) { |
| 363 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and | 363 // CreateScrollAndContentsLayers makes the outer viewport unscrollable and |
| 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 = | 368 LayerImpl* content_layer = host_impl_->OuterViewportScrollLayer() |
| 369 host_impl_->OuterViewportScrollLayer()->children().back(); | 369 ->test_properties() |
| 370 ->children.back(); |
| 370 content_layer->SetBounds(content_size); | 371 content_layer->SetBounds(content_size); |
| 371 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); | 372 host_impl_->OuterViewportScrollLayer()->SetBounds(content_size); |
| 372 | 373 |
| 373 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent(); | 374 LayerImpl* outer_clip = host_impl_->OuterViewportScrollLayer()->parent(); |
| 374 outer_clip->SetBounds(viewport_size); | 375 outer_clip->SetBounds(viewport_size); |
| 375 | 376 |
| 376 LayerImpl* inner_clip_layer = | 377 LayerImpl* inner_clip_layer = |
| 377 host_impl_->InnerViewportScrollLayer()->parent()->parent(); | 378 host_impl_->InnerViewportScrollLayer()->parent()->parent(); |
| 378 inner_clip_layer->SetBounds(viewport_size); | 379 inner_clip_layer->SetBounds(viewport_size); |
| 379 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); | 380 host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 host_impl_->ProcessScrollDeltas(); | 590 host_impl_->ProcessScrollDeltas(); |
| 590 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 591 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| 591 } | 592 } |
| 592 | 593 |
| 593 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { | 594 TEST_F(LayerTreeHostImplTest, ScrollDeltaTreeButNoChanges) { |
| 594 { | 595 { |
| 595 std::unique_ptr<LayerImpl> root = | 596 std::unique_ptr<LayerImpl> root = |
| 596 LayerImpl::Create(host_impl_->active_tree(), 1); | 597 LayerImpl::Create(host_impl_->active_tree(), 1); |
| 597 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 598 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 598 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); | 599 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 3)); |
| 599 root->children()[1]->AddChild( | 600 root->test_properties()->children[1]->AddChild( |
| 600 LayerImpl::Create(host_impl_->active_tree(), 4)); | 601 LayerImpl::Create(host_impl_->active_tree(), 4)); |
| 601 root->children()[1]->AddChild( | 602 root->test_properties()->children[1]->AddChild( |
| 602 LayerImpl::Create(host_impl_->active_tree(), 5)); | 603 LayerImpl::Create(host_impl_->active_tree(), 5)); |
| 603 root->children()[1]->children()[0]->AddChild( | 604 root->test_properties() |
| 604 LayerImpl::Create(host_impl_->active_tree(), 6)); | 605 ->children[1] |
| 606 ->test_properties() |
| 607 ->children[0] |
| 608 ->AddChild(LayerImpl::Create(host_impl_->active_tree(), 6)); |
| 605 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 609 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 606 } | 610 } |
| 607 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 611 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 608 | 612 |
| 609 ExpectClearedScrollDeltasRecursive(root); | 613 ExpectClearedScrollDeltasRecursive(root); |
| 610 | 614 |
| 611 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 615 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 612 | 616 |
| 613 scroll_info = host_impl_->ProcessScrollDeltas(); | 617 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 614 ASSERT_EQ(scroll_info->scrolls.size(), 0u); | 618 ASSERT_EQ(scroll_info->scrolls.size(), 0u); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 634 root_layer->SetScrollClipLayer(root_clip->id()); | 638 root_layer->SetScrollClipLayer(root_clip->id()); |
| 635 root_layer->layer_tree_impl() | 639 root_layer->layer_tree_impl() |
| 636 ->property_trees() | 640 ->property_trees() |
| 637 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), | 641 ->scroll_tree.UpdateScrollOffsetBaseForTesting(root_layer->id(), |
| 638 scroll_offset); | 642 scroll_offset); |
| 639 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); | 643 host_impl_->active_tree()->SetRootLayer(std::move(root_clip)); |
| 640 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 644 host_impl_->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 641 root_layer->ScrollBy(scroll_delta); | 645 root_layer->ScrollBy(scroll_delta); |
| 642 } | 646 } |
| 643 | 647 |
| 644 LayerImpl* root = host_impl_->active_tree()->root_layer()->children()[0]; | 648 LayerImpl* root = |
| 649 host_impl_->active_tree()->root_layer()->test_properties()->children[0]; |
| 645 | 650 |
| 646 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 651 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 647 | 652 |
| 648 scroll_info = host_impl_->ProcessScrollDeltas(); | 653 scroll_info = host_impl_->ProcessScrollDeltas(); |
| 649 ASSERT_EQ(scroll_info->scrolls.size(), 1u); | 654 ASSERT_EQ(scroll_info->scrolls.size(), 1u); |
| 650 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); | 655 EXPECT_TRUE(ScrollInfoContains(*scroll_info, root->id(), scroll_delta)); |
| 651 | 656 |
| 652 gfx::Vector2d scroll_delta2(-5, 27); | 657 gfx::Vector2d scroll_delta2(-5, 27); |
| 653 root->ScrollBy(scroll_delta2); | 658 root->ScrollBy(scroll_delta2); |
| 654 scroll_info = host_impl_->ProcessScrollDeltas(); | 659 scroll_info = host_impl_->ProcessScrollDeltas(); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); | 1214 ScrollDelta(host_impl_->InnerViewportScrollLayer()).y()); |
| 1210 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( | 1215 EXPECT_TRUE(host_impl_->ScrollVerticallyByPage( |
| 1211 gfx::Point(), SCROLL_BACKWARD)); | 1216 gfx::Point(), SCROLL_BACKWARD)); |
| 1212 } | 1217 } |
| 1213 | 1218 |
| 1214 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { | 1219 TEST_F(LayerTreeHostImplTest, ScrollWithUserUnscrollableLayers) { |
| 1215 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); | 1220 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 1216 host_impl_->SetViewportSize(gfx::Size(100, 100)); | 1221 host_impl_->SetViewportSize(gfx::Size(100, 100)); |
| 1217 | 1222 |
| 1218 gfx::Size overflow_size(400, 400); | 1223 gfx::Size overflow_size(400, 400); |
| 1219 ASSERT_EQ(1u, scroll_layer->children().size()); | 1224 ASSERT_EQ(1u, scroll_layer->test_properties()->children.size()); |
| 1220 LayerImpl* overflow = scroll_layer->children()[0]; | 1225 LayerImpl* overflow = scroll_layer->test_properties()->children[0]; |
| 1221 overflow->SetBounds(overflow_size); | 1226 overflow->SetBounds(overflow_size); |
| 1222 overflow->SetScrollClipLayer(scroll_layer->parent()->parent()->id()); | 1227 overflow->SetScrollClipLayer(scroll_layer->parent()->parent()->id()); |
| 1223 overflow->layer_tree_impl() | 1228 overflow->layer_tree_impl() |
| 1224 ->property_trees() | 1229 ->property_trees() |
| 1225 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), | 1230 ->scroll_tree.UpdateScrollOffsetBaseForTesting(overflow->id(), |
| 1226 gfx::ScrollOffset()); | 1231 gfx::ScrollOffset()); |
| 1227 overflow->SetPosition(gfx::PointF()); | 1232 overflow->SetPosition(gfx::PointF()); |
| 1228 | 1233 |
| 1229 SetNeedsRebuildPropertyTrees(); | 1234 SetNeedsRebuildPropertyTrees(); |
| 1230 DrawFrame(); | 1235 DrawFrame(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 | 1288 |
| 1284 host_impl_->CreatePendingTree(); | 1289 host_impl_->CreatePendingTree(); |
| 1285 host_impl_->pending_tree()->SetRootLayer( | 1290 host_impl_->pending_tree()->SetRootLayer( |
| 1286 LayerImpl::Create(host_impl_->pending_tree(), 1)); | 1291 LayerImpl::Create(host_impl_->pending_tree(), 1)); |
| 1287 LayerImpl* root = host_impl_->pending_tree()->root_layer(); | 1292 LayerImpl* root = host_impl_->pending_tree()->root_layer(); |
| 1288 root->SetBounds(gfx::Size(50, 50)); | 1293 root->SetBounds(gfx::Size(50, 50)); |
| 1289 root->test_properties()->force_render_surface = true; | 1294 root->test_properties()->force_render_surface = true; |
| 1290 | 1295 |
| 1291 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); | 1296 root->AddChild(LayerImpl::Create(host_impl_->pending_tree(), 2)); |
| 1292 host_impl_->pending_tree()->BuildLayerListForTesting(); | 1297 host_impl_->pending_tree()->BuildLayerListForTesting(); |
| 1293 LayerImpl* child = root->children()[0]; | 1298 LayerImpl* child = root->test_properties()->children[0]; |
| 1294 child->SetBounds(gfx::Size(10, 10)); | 1299 child->SetBounds(gfx::Size(10, 10)); |
| 1295 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1300 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1296 child->SetDrawsContent(true); | 1301 child->SetDrawsContent(true); |
| 1297 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); | 1302 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); |
| 1298 | 1303 |
| 1299 EXPECT_FALSE(did_request_next_frame_); | 1304 EXPECT_FALSE(did_request_next_frame_); |
| 1300 EXPECT_FALSE(did_request_redraw_); | 1305 EXPECT_FALSE(did_request_redraw_); |
| 1301 EXPECT_FALSE(did_request_commit_); | 1306 EXPECT_FALSE(did_request_commit_); |
| 1302 | 1307 |
| 1303 host_impl_->AnimatePendingTreeAfterCommit(); | 1308 host_impl_->AnimatePendingTreeAfterCommit(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1333 | 1338 |
| 1334 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1339 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1335 | 1340 |
| 1336 host_impl_->active_tree()->SetRootLayer( | 1341 host_impl_->active_tree()->SetRootLayer( |
| 1337 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1342 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1338 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1343 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1339 root->SetBounds(gfx::Size(50, 50)); | 1344 root->SetBounds(gfx::Size(50, 50)); |
| 1340 root->test_properties()->force_render_surface = true; | 1345 root->test_properties()->force_render_surface = true; |
| 1341 | 1346 |
| 1342 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1347 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 1343 LayerImpl* child = root->children()[0]; | 1348 LayerImpl* child = root->test_properties()->children[0]; |
| 1344 child->SetBounds(gfx::Size(10, 10)); | 1349 child->SetBounds(gfx::Size(10, 10)); |
| 1345 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1350 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1346 child->SetDrawsContent(true); | 1351 child->SetDrawsContent(true); |
| 1347 | 1352 |
| 1348 // Add a translate from 6,7 to 8,9. | 1353 // Add a translate from 6,7 to 8,9. |
| 1349 TransformOperations start; | 1354 TransformOperations start; |
| 1350 start.AppendTranslate(6.f, 7.f, 0.f); | 1355 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1351 TransformOperations end; | 1356 TransformOperations end; |
| 1352 end.AppendTranslate(8.f, 9.f, 0.f); | 1357 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1353 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, | 1358 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 | 1402 |
| 1398 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1403 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1399 | 1404 |
| 1400 host_impl_->active_tree()->SetRootLayer( | 1405 host_impl_->active_tree()->SetRootLayer( |
| 1401 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1406 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1402 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1407 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1403 root->SetBounds(gfx::Size(50, 50)); | 1408 root->SetBounds(gfx::Size(50, 50)); |
| 1404 root->SetHasRenderSurface(true); | 1409 root->SetHasRenderSurface(true); |
| 1405 | 1410 |
| 1406 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1411 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 1407 LayerImpl* child = root->children()[0]; | 1412 LayerImpl* child = root->test_properties()->children[0]; |
| 1408 child->SetBounds(gfx::Size(10, 10)); | 1413 child->SetBounds(gfx::Size(10, 10)); |
| 1409 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1414 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1410 child->SetDrawsContent(true); | 1415 child->SetDrawsContent(true); |
| 1411 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); | 1416 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0); |
| 1412 | 1417 |
| 1413 // Set up the property trees so that UpdateDrawProperties will work in | 1418 // Set up the property trees so that UpdateDrawProperties will work in |
| 1414 // CommitComplete below. | 1419 // CommitComplete below. |
| 1415 LayerImplList list; | 1420 LayerImplList list; |
| 1416 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1421 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 1417 root, gfx::Size(50, 50), &list); | 1422 root, gfx::Size(50, 50), &list); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1435 | 1440 |
| 1436 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { | 1441 TEST_F(LayerTreeHostImplTest, AnimationSchedulingOnLayerDestruction) { |
| 1437 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 1442 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 1438 | 1443 |
| 1439 host_impl_->active_tree()->SetRootLayer( | 1444 host_impl_->active_tree()->SetRootLayer( |
| 1440 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1445 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1441 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1446 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1442 root->SetBounds(gfx::Size(50, 50)); | 1447 root->SetBounds(gfx::Size(50, 50)); |
| 1443 | 1448 |
| 1444 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); | 1449 root->AddChild(LayerImpl::Create(host_impl_->active_tree(), 2)); |
| 1445 LayerImpl* child = root->children()[0]; | 1450 LayerImpl* child = root->test_properties()->children[0]; |
| 1446 child->SetBounds(gfx::Size(10, 10)); | 1451 child->SetBounds(gfx::Size(10, 10)); |
| 1447 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1452 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1448 child->SetDrawsContent(true); | 1453 child->SetDrawsContent(true); |
| 1449 | 1454 |
| 1450 // Add a translate animation. | 1455 // Add a translate animation. |
| 1451 TransformOperations start; | 1456 TransformOperations start; |
| 1452 start.AppendTranslate(6.f, 7.f, 0.f); | 1457 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1453 TransformOperations end; | 1458 TransformOperations end; |
| 1454 end.AppendTranslate(8.f, 9.f, 0.f); | 1459 end.AppendTranslate(8.f, 9.f, 0.f); |
| 1455 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, | 1460 AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1510 | 1515 |
| 1511 host_impl_->active_tree()->SetRootLayer( | 1516 host_impl_->active_tree()->SetRootLayer( |
| 1512 LayerImpl::Create(host_impl_->active_tree(), 1)); | 1517 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 1513 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 1518 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 1514 root->SetBounds(gfx::Size(50, 50)); | 1519 root->SetBounds(gfx::Size(50, 50)); |
| 1515 root->SetHasRenderSurface(true); | 1520 root->SetHasRenderSurface(true); |
| 1516 | 1521 |
| 1517 root->AddChild(std::unique_ptr<MissingTilesLayer>( | 1522 root->AddChild(std::unique_ptr<MissingTilesLayer>( |
| 1518 new MissingTilesLayer(host_impl_->active_tree(), 2))); | 1523 new MissingTilesLayer(host_impl_->active_tree(), 2))); |
| 1519 MissingTilesLayer* child = | 1524 MissingTilesLayer* child = |
| 1520 static_cast<MissingTilesLayer*>(root->children()[0]); | 1525 static_cast<MissingTilesLayer*>(root->test_properties()->children[0]); |
| 1521 child->SetBounds(gfx::Size(10, 10)); | 1526 child->SetBounds(gfx::Size(10, 10)); |
| 1522 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); | 1527 child->draw_properties().visible_layer_rect = gfx::Rect(10, 10); |
| 1523 child->SetDrawsContent(true); | 1528 child->SetDrawsContent(true); |
| 1524 | 1529 |
| 1525 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); | 1530 EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation()); |
| 1526 | 1531 |
| 1527 // Add a translate from 6,7 to 8,9. | 1532 // Add a translate from 6,7 to 8,9. |
| 1528 TransformOperations start; | 1533 TransformOperations start; |
| 1529 start.AppendTranslate(6.f, 7.f, 0.f); | 1534 start.AppendTranslate(6.f, 7.f, 0.f); |
| 1530 TransformOperations end; | 1535 TransformOperations end; |
| (...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3377 // The root layer is always drawn, so run this test on a child layer that | 3382 // The root layer is always drawn, so run this test on a child layer that |
| 3378 // will be masked out by the root layer's bounds. | 3383 // will be masked out by the root layer's bounds. |
| 3379 host_impl_->active_tree()->SetRootLayer( | 3384 host_impl_->active_tree()->SetRootLayer( |
| 3380 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3385 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3381 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3386 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 3382 host_impl_->active_tree()->root_layer()); | 3387 host_impl_->active_tree()->root_layer()); |
| 3383 | 3388 |
| 3384 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3389 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3385 root->test_properties()->force_render_surface = true; | 3390 root->test_properties()->force_render_surface = true; |
| 3386 DidDrawCheckLayer* layer = | 3391 DidDrawCheckLayer* layer = |
| 3387 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 3392 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3388 | 3393 |
| 3389 { | 3394 { |
| 3390 LayerTreeHostImpl::FrameData frame; | 3395 LayerTreeHostImpl::FrameData frame; |
| 3391 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3396 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 3392 host_impl_->DrawLayers(&frame); | 3397 host_impl_->DrawLayers(&frame); |
| 3393 host_impl_->DidDrawAllLayers(frame); | 3398 host_impl_->DidDrawAllLayers(frame); |
| 3394 | 3399 |
| 3395 EXPECT_TRUE(layer->will_draw_called()); | 3400 EXPECT_TRUE(layer->will_draw_called()); |
| 3396 EXPECT_TRUE(layer->append_quads_called()); | 3401 EXPECT_TRUE(layer->append_quads_called()); |
| 3397 EXPECT_TRUE(layer->did_draw_called()); | 3402 EXPECT_TRUE(layer->did_draw_called()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3419 // The root layer is always drawn, so run this test on a child layer that | 3424 // The root layer is always drawn, so run this test on a child layer that |
| 3420 // will be masked out by the root layer's bounds. | 3425 // will be masked out by the root layer's bounds. |
| 3421 host_impl_->active_tree()->SetRootLayer( | 3426 host_impl_->active_tree()->SetRootLayer( |
| 3422 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3427 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3423 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( | 3428 DidDrawCheckLayer* root = static_cast<DidDrawCheckLayer*>( |
| 3424 host_impl_->active_tree()->root_layer()); | 3429 host_impl_->active_tree()->root_layer()); |
| 3425 root->SetMasksToBounds(true); | 3430 root->SetMasksToBounds(true); |
| 3426 root->test_properties()->force_render_surface = true; | 3431 root->test_properties()->force_render_surface = true; |
| 3427 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3432 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3428 DidDrawCheckLayer* layer = | 3433 DidDrawCheckLayer* layer = |
| 3429 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 3434 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3430 // Ensure visible_layer_rect for layer is empty. | 3435 // Ensure visible_layer_rect for layer is empty. |
| 3431 layer->SetPosition(gfx::PointF(100.f, 100.f)); | 3436 layer->SetPosition(gfx::PointF(100.f, 100.f)); |
| 3432 layer->SetBounds(gfx::Size(10, 10)); | 3437 layer->SetBounds(gfx::Size(10, 10)); |
| 3433 | 3438 |
| 3434 LayerTreeHostImpl::FrameData frame; | 3439 LayerTreeHostImpl::FrameData frame; |
| 3435 | 3440 |
| 3436 EXPECT_FALSE(layer->will_draw_called()); | 3441 EXPECT_FALSE(layer->will_draw_called()); |
| 3437 EXPECT_FALSE(layer->did_draw_called()); | 3442 EXPECT_FALSE(layer->did_draw_called()); |
| 3438 | 3443 |
| 3439 SetNeedsRebuildPropertyTrees(); | 3444 SetNeedsRebuildPropertyTrees(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3468 gfx::Size big_size(1000, 1000); | 3473 gfx::Size big_size(1000, 1000); |
| 3469 host_impl_->SetViewportSize(big_size); | 3474 host_impl_->SetViewportSize(big_size); |
| 3470 | 3475 |
| 3471 host_impl_->active_tree()->SetRootLayer( | 3476 host_impl_->active_tree()->SetRootLayer( |
| 3472 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3477 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3473 DidDrawCheckLayer* root = | 3478 DidDrawCheckLayer* root = |
| 3474 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3479 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 3475 | 3480 |
| 3476 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3481 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3477 DidDrawCheckLayer* occluded_layer = | 3482 DidDrawCheckLayer* occluded_layer = |
| 3478 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 3483 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3479 | 3484 |
| 3480 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3485 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 3481 root->test_properties()->force_render_surface = true; | 3486 root->test_properties()->force_render_surface = true; |
| 3482 DidDrawCheckLayer* top_layer = | 3487 DidDrawCheckLayer* top_layer = |
| 3483 static_cast<DidDrawCheckLayer*>(root->children()[1]); | 3488 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[1]); |
| 3484 // This layer covers the occluded_layer above. Make this layer large so it can | 3489 // This layer covers the occluded_layer above. Make this layer large so it can |
| 3485 // occlude. | 3490 // occlude. |
| 3486 top_layer->SetBounds(big_size); | 3491 top_layer->SetBounds(big_size); |
| 3487 top_layer->SetContentsOpaque(true); | 3492 top_layer->SetContentsOpaque(true); |
| 3488 | 3493 |
| 3489 LayerTreeHostImpl::FrameData frame; | 3494 LayerTreeHostImpl::FrameData frame; |
| 3490 | 3495 |
| 3491 EXPECT_FALSE(occluded_layer->will_draw_called()); | 3496 EXPECT_FALSE(occluded_layer->will_draw_called()); |
| 3492 EXPECT_FALSE(occluded_layer->did_draw_called()); | 3497 EXPECT_FALSE(occluded_layer->did_draw_called()); |
| 3493 EXPECT_FALSE(top_layer->will_draw_called()); | 3498 EXPECT_FALSE(top_layer->will_draw_called()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3505 | 3510 |
| 3506 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { | 3511 TEST_F(LayerTreeHostImplTest, DidDrawCalledOnAllLayers) { |
| 3507 host_impl_->active_tree()->SetRootLayer( | 3512 host_impl_->active_tree()->SetRootLayer( |
| 3508 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); | 3513 DidDrawCheckLayer::Create(host_impl_->active_tree(), 1)); |
| 3509 DidDrawCheckLayer* root = | 3514 DidDrawCheckLayer* root = |
| 3510 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3515 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 3511 | 3516 |
| 3512 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); | 3517 root->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 2)); |
| 3513 root->test_properties()->force_render_surface = true; | 3518 root->test_properties()->force_render_surface = true; |
| 3514 DidDrawCheckLayer* layer1 = | 3519 DidDrawCheckLayer* layer1 = |
| 3515 static_cast<DidDrawCheckLayer*>(root->children()[0]); | 3520 static_cast<DidDrawCheckLayer*>(root->test_properties()->children[0]); |
| 3516 | 3521 |
| 3517 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); | 3522 layer1->AddChild(DidDrawCheckLayer::Create(host_impl_->active_tree(), 3)); |
| 3518 DidDrawCheckLayer* layer2 = | 3523 DidDrawCheckLayer* layer2 = |
| 3519 static_cast<DidDrawCheckLayer*>(layer1->children()[0]); | 3524 static_cast<DidDrawCheckLayer*>(layer1->test_properties()->children[0]); |
| 3520 | 3525 |
| 3521 layer1->test_properties()->force_render_surface = true; | 3526 layer1->test_properties()->force_render_surface = true; |
| 3522 layer1->test_properties()->should_flatten_transform = true; | 3527 layer1->test_properties()->should_flatten_transform = true; |
| 3523 | 3528 |
| 3524 EXPECT_FALSE(root->did_draw_called()); | 3529 EXPECT_FALSE(root->did_draw_called()); |
| 3525 EXPECT_FALSE(layer1->did_draw_called()); | 3530 EXPECT_FALSE(layer1->did_draw_called()); |
| 3526 EXPECT_FALSE(layer2->did_draw_called()); | 3531 EXPECT_FALSE(layer2->did_draw_called()); |
| 3527 | 3532 |
| 3528 LayerTreeHostImpl::FrameData frame; | 3533 LayerTreeHostImpl::FrameData frame; |
| 3529 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( | 3534 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren( |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3681 SetNeedsRebuildPropertyTrees(); | 3686 SetNeedsRebuildPropertyTrees(); |
| 3682 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 3687 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 3683 host_impl_->DrawLayers(&frame); | 3688 host_impl_->DrawLayers(&frame); |
| 3684 host_impl_->DidDrawAllLayers(frame); | 3689 host_impl_->DidDrawAllLayers(frame); |
| 3685 host_impl_->SwapBuffers(frame); | 3690 host_impl_->SwapBuffers(frame); |
| 3686 | 3691 |
| 3687 for (size_t i = 0; i < cases.size(); ++i) { | 3692 for (size_t i = 0; i < cases.size(); ++i) { |
| 3688 // Clean up host_impl_ state. | 3693 // Clean up host_impl_ state. |
| 3689 const auto& testcase = cases[i]; | 3694 const auto& testcase = cases[i]; |
| 3690 std::vector<LayerImpl*> to_remove; | 3695 std::vector<LayerImpl*> to_remove; |
| 3691 for (const auto& child : root->children()) | 3696 for (const auto& child : root->test_properties()->children) |
| 3692 to_remove.push_back(child); | 3697 to_remove.push_back(child); |
| 3693 for (auto* child : to_remove) | 3698 for (auto* child : to_remove) |
| 3694 root->RemoveChildForTesting(child); | 3699 root->RemoveChildForTesting(child); |
| 3695 timeline()->ClearPlayers(); | 3700 timeline()->ClearPlayers(); |
| 3696 | 3701 |
| 3697 std::ostringstream scope; | 3702 std::ostringstream scope; |
| 3698 scope << "Test case: " << i; | 3703 scope << "Test case: " << i; |
| 3699 SCOPED_TRACE(scope.str()); | 3704 SCOPED_TRACE(scope.str()); |
| 3700 | 3705 |
| 3701 root->AddChild(MissingTextureAnimatingLayer::Create( | 3706 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3702 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, | 3707 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, |
| 3703 testcase.layer_before.has_incomplete_tile, | 3708 testcase.layer_before.has_incomplete_tile, |
| 3704 testcase.layer_before.is_animating, host_impl_->resource_provider(), | 3709 testcase.layer_before.is_animating, host_impl_->resource_provider(), |
| 3705 timeline())); | 3710 timeline())); |
| 3706 DidDrawCheckLayer* before = | 3711 DidDrawCheckLayer* before = static_cast<DidDrawCheckLayer*>( |
| 3707 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3712 root->test_properties()->children.back()); |
| 3708 if (testcase.layer_before.has_copy_request) | 3713 if (testcase.layer_before.has_copy_request) |
| 3709 before->AddCopyRequest(); | 3714 before->AddCopyRequest(); |
| 3710 | 3715 |
| 3711 root->AddChild(MissingTextureAnimatingLayer::Create( | 3716 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3712 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, | 3717 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, |
| 3713 testcase.layer_between.has_incomplete_tile, | 3718 testcase.layer_between.has_incomplete_tile, |
| 3714 testcase.layer_between.is_animating, host_impl_->resource_provider(), | 3719 testcase.layer_between.is_animating, host_impl_->resource_provider(), |
| 3715 timeline())); | 3720 timeline())); |
| 3716 DidDrawCheckLayer* between = | 3721 DidDrawCheckLayer* between = static_cast<DidDrawCheckLayer*>( |
| 3717 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3722 root->test_properties()->children.back()); |
| 3718 if (testcase.layer_between.has_copy_request) | 3723 if (testcase.layer_between.has_copy_request) |
| 3719 between->AddCopyRequest(); | 3724 between->AddCopyRequest(); |
| 3720 | 3725 |
| 3721 root->AddChild(MissingTextureAnimatingLayer::Create( | 3726 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3722 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, | 3727 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
| 3723 testcase.layer_after.has_incomplete_tile, | 3728 testcase.layer_after.has_incomplete_tile, |
| 3724 testcase.layer_after.is_animating, host_impl_->resource_provider(), | 3729 testcase.layer_after.is_animating, host_impl_->resource_provider(), |
| 3725 timeline())); | 3730 timeline())); |
| 3726 DidDrawCheckLayer* after = | 3731 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( |
| 3727 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3732 root->test_properties()->children.back()); |
| 3728 if (testcase.layer_after.has_copy_request) | 3733 if (testcase.layer_after.has_copy_request) |
| 3729 after->AddCopyRequest(); | 3734 after->AddCopyRequest(); |
| 3730 | 3735 |
| 3731 if (testcase.high_res_required) | 3736 if (testcase.high_res_required) |
| 3732 host_impl_->SetRequiresHighResToDraw(); | 3737 host_impl_->SetRequiresHighResToDraw(); |
| 3733 | 3738 |
| 3734 LayerTreeHostImpl::FrameData frame; | 3739 LayerTreeHostImpl::FrameData frame; |
| 3735 SetNeedsRebuildPropertyTrees(); | 3740 SetNeedsRebuildPropertyTrees(); |
| 3736 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); | 3741 EXPECT_EQ(testcase.expected_result, PrepareToDrawFrame(&frame)); |
| 3737 host_impl_->DrawLayers(&frame); | 3742 host_impl_->DrawLayers(&frame); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3776 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); | 3781 static_cast<DidDrawCheckLayer*>(host_impl_->active_tree()->root_layer()); |
| 3777 root->test_properties()->force_render_surface = true; | 3782 root->test_properties()->force_render_surface = true; |
| 3778 | 3783 |
| 3779 SetNeedsRebuildPropertyTrees(); | 3784 SetNeedsRebuildPropertyTrees(); |
| 3780 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3785 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 3781 resourceless_software_draw); | 3786 resourceless_software_draw); |
| 3782 | 3787 |
| 3783 for (size_t i = 0; i < cases.size(); ++i) { | 3788 for (size_t i = 0; i < cases.size(); ++i) { |
| 3784 const auto& testcase = cases[i]; | 3789 const auto& testcase = cases[i]; |
| 3785 std::vector<LayerImpl*> to_remove; | 3790 std::vector<LayerImpl*> to_remove; |
| 3786 for (const auto& child : root->children()) | 3791 for (const auto& child : root->test_properties()->children) |
| 3787 to_remove.push_back(child); | 3792 to_remove.push_back(child); |
| 3788 for (auto* child : to_remove) | 3793 for (auto* child : to_remove) |
| 3789 root->RemoveChildForTesting(child); | 3794 root->RemoveChildForTesting(child); |
| 3790 | 3795 |
| 3791 std::ostringstream scope; | 3796 std::ostringstream scope; |
| 3792 scope << "Test case: " << i; | 3797 scope << "Test case: " << i; |
| 3793 SCOPED_TRACE(scope.str()); | 3798 SCOPED_TRACE(scope.str()); |
| 3794 | 3799 |
| 3795 root->AddChild(MissingTextureAnimatingLayer::Create( | 3800 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3796 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, | 3801 host_impl_->active_tree(), 2, testcase.layer_before.has_missing_tile, |
| 3797 testcase.layer_before.has_incomplete_tile, | 3802 testcase.layer_before.has_incomplete_tile, |
| 3798 testcase.layer_before.is_animating, host_impl_->resource_provider(), | 3803 testcase.layer_before.is_animating, host_impl_->resource_provider(), |
| 3799 timeline())); | 3804 timeline())); |
| 3800 DidDrawCheckLayer* before = | 3805 DidDrawCheckLayer* before = static_cast<DidDrawCheckLayer*>( |
| 3801 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3806 root->test_properties()->children.back()); |
| 3802 if (testcase.layer_before.has_copy_request) | 3807 if (testcase.layer_before.has_copy_request) |
| 3803 before->AddCopyRequest(); | 3808 before->AddCopyRequest(); |
| 3804 | 3809 |
| 3805 root->AddChild(MissingTextureAnimatingLayer::Create( | 3810 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3806 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, | 3811 host_impl_->active_tree(), 3, testcase.layer_between.has_missing_tile, |
| 3807 testcase.layer_between.has_incomplete_tile, | 3812 testcase.layer_between.has_incomplete_tile, |
| 3808 testcase.layer_between.is_animating, host_impl_->resource_provider(), | 3813 testcase.layer_between.is_animating, host_impl_->resource_provider(), |
| 3809 timeline())); | 3814 timeline())); |
| 3810 DidDrawCheckLayer* between = | 3815 DidDrawCheckLayer* between = static_cast<DidDrawCheckLayer*>( |
| 3811 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3816 root->test_properties()->children.back()); |
| 3812 if (testcase.layer_between.has_copy_request) | 3817 if (testcase.layer_between.has_copy_request) |
| 3813 between->AddCopyRequest(); | 3818 between->AddCopyRequest(); |
| 3814 | 3819 |
| 3815 root->AddChild(MissingTextureAnimatingLayer::Create( | 3820 root->AddChild(MissingTextureAnimatingLayer::Create( |
| 3816 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, | 3821 host_impl_->active_tree(), 4, testcase.layer_after.has_missing_tile, |
| 3817 testcase.layer_after.has_incomplete_tile, | 3822 testcase.layer_after.has_incomplete_tile, |
| 3818 testcase.layer_after.is_animating, host_impl_->resource_provider(), | 3823 testcase.layer_after.is_animating, host_impl_->resource_provider(), |
| 3819 timeline())); | 3824 timeline())); |
| 3820 DidDrawCheckLayer* after = | 3825 DidDrawCheckLayer* after = static_cast<DidDrawCheckLayer*>( |
| 3821 static_cast<DidDrawCheckLayer*>(root->children().back()); | 3826 root->test_properties()->children.back()); |
| 3822 if (testcase.layer_after.has_copy_request) | 3827 if (testcase.layer_after.has_copy_request) |
| 3823 after->AddCopyRequest(); | 3828 after->AddCopyRequest(); |
| 3824 | 3829 |
| 3825 if (testcase.high_res_required) | 3830 if (testcase.high_res_required) |
| 3826 host_impl_->SetRequiresHighResToDraw(); | 3831 host_impl_->SetRequiresHighResToDraw(); |
| 3827 | 3832 |
| 3828 SetNeedsRebuildPropertyTrees(); | 3833 SetNeedsRebuildPropertyTrees(); |
| 3829 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 3834 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 3830 resourceless_software_draw); | 3835 resourceless_software_draw); |
| 3831 } | 3836 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3980 HidingTopControlsExpandsScrollableSize) { | 3985 HidingTopControlsExpandsScrollableSize) { |
| 3981 SetupTopControlsAndScrollLayerWithVirtualViewport( | 3986 SetupTopControlsAndScrollLayerWithVirtualViewport( |
| 3982 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); | 3987 gfx::Size(50, 50), gfx::Size(50, 50), gfx::Size(50, 50)); |
| 3983 | 3988 |
| 3984 LayerTreeImpl* active_tree = host_impl_->active_tree(); | 3989 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 3985 | 3990 |
| 3986 // Create a content layer beneath the outer viewport scroll layer. | 3991 // Create a content layer beneath the outer viewport scroll layer. |
| 3987 int id = host_impl_->OuterViewportScrollLayer()->id(); | 3992 int id = host_impl_->OuterViewportScrollLayer()->id(); |
| 3988 host_impl_->OuterViewportScrollLayer()->AddChild( | 3993 host_impl_->OuterViewportScrollLayer()->AddChild( |
| 3989 LayerImpl::Create(host_impl_->active_tree(), id + 2)); | 3994 LayerImpl::Create(host_impl_->active_tree(), id + 2)); |
| 3990 LayerImpl* content = active_tree->OuterViewportScrollLayer()->children()[0]; | 3995 LayerImpl* content = |
| 3996 active_tree->OuterViewportScrollLayer()->test_properties()->children[0]; |
| 3991 content->SetBounds(gfx::Size(50, 50)); | 3997 content->SetBounds(gfx::Size(50, 50)); |
| 3992 | 3998 |
| 3993 SetNeedsRebuildPropertyTrees(); | 3999 SetNeedsRebuildPropertyTrees(); |
| 3994 DrawFrame(); | 4000 DrawFrame(); |
| 3995 | 4001 |
| 3996 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); | 4002 LayerImpl* inner_container = active_tree->InnerViewportContainerLayer(); |
| 3997 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); | 4003 LayerImpl* outer_container = active_tree->OuterViewportContainerLayer(); |
| 3998 | 4004 |
| 3999 // The top controls should start off showing so the viewport should be shrunk. | 4005 // The top controls should start off showing so the viewport should be shrunk. |
| 4000 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); | 4006 ASSERT_EQ(gfx::Size(50, 50), inner_container->bounds()); |
| (...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4975 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); | 4981 default_page_scale_matrix.Scale(default_page_scale, default_page_scale); |
| 4976 | 4982 |
| 4977 float new_page_scale = 2.f; | 4983 float new_page_scale = 2.f; |
| 4978 gfx::Transform new_page_scale_matrix; | 4984 gfx::Transform new_page_scale_matrix; |
| 4979 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); | 4985 new_page_scale_matrix.Scale(new_page_scale, new_page_scale); |
| 4980 | 4986 |
| 4981 // Create a normal scrollable root layer and another scrollable child layer. | 4987 // Create a normal scrollable root layer and another scrollable child layer. |
| 4982 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); | 4988 LayerImpl* scroll = SetupScrollAndContentsLayers(surface_size); |
| 4983 scroll->SetDrawsContent(true); | 4989 scroll->SetDrawsContent(true); |
| 4984 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 4990 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 4985 LayerImpl* child = scroll->children()[0]; | 4991 LayerImpl* child = scroll->test_properties()->children[0]; |
| 4986 child->SetDrawsContent(true); | 4992 child->SetDrawsContent(true); |
| 4987 | 4993 |
| 4988 std::unique_ptr<LayerImpl> scrollable_child_clip = | 4994 std::unique_ptr<LayerImpl> scrollable_child_clip = |
| 4989 LayerImpl::Create(host_impl_->active_tree(), 6); | 4995 LayerImpl::Create(host_impl_->active_tree(), 6); |
| 4990 std::unique_ptr<LayerImpl> scrollable_child = | 4996 std::unique_ptr<LayerImpl> scrollable_child = |
| 4991 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); | 4997 CreateScrollableLayer(7, surface_size, scrollable_child_clip.get()); |
| 4992 scrollable_child_clip->AddChild(std::move(scrollable_child)); | 4998 scrollable_child_clip->AddChild(std::move(scrollable_child)); |
| 4993 child->AddChild(std::move(scrollable_child_clip)); | 4999 child->AddChild(std::move(scrollable_child_clip)); |
| 4994 LayerImpl* grand_child = child->children()[0]; | 5000 LayerImpl* grand_child = child->test_properties()->children[0]; |
| 4995 grand_child->SetDrawsContent(true); | 5001 grand_child->SetDrawsContent(true); |
| 4996 | 5002 |
| 4997 // Set new page scale on impl thread by pinching. | 5003 // Set new page scale on impl thread by pinching. |
| 4998 SetNeedsRebuildPropertyTrees(); | 5004 SetNeedsRebuildPropertyTrees(); |
| 4999 RebuildPropertyTrees(); | 5005 RebuildPropertyTrees(); |
| 5000 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5006 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5001 InputHandler::TOUCHSCREEN); | 5007 InputHandler::TOUCHSCREEN); |
| 5002 host_impl_->PinchGestureBegin(); | 5008 host_impl_->PinchGestureBegin(); |
| 5003 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); | 5009 host_impl_->PinchGestureUpdate(new_page_scale, gfx::Point()); |
| 5004 host_impl_->PinchGestureEnd(); | 5010 host_impl_->PinchGestureEnd(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5103 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), | 5109 host_impl_->ScrollBegin(BeginState(gfx::Point()).get(), |
| 5104 InputHandler::WHEEL) | 5110 InputHandler::WHEEL) |
| 5105 .thread); | 5111 .thread); |
| 5106 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5112 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5107 host_impl_->ScrollEnd(EndState().get()); | 5113 host_impl_->ScrollEnd(EndState().get()); |
| 5108 | 5114 |
| 5109 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5115 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5110 host_impl_->ProcessScrollDeltas(); | 5116 host_impl_->ProcessScrollDeltas(); |
| 5111 | 5117 |
| 5112 // The grand child should have scrolled up to its limit. | 5118 // The grand child should have scrolled up to its limit. |
| 5113 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 5119 LayerImpl* child = |
| 5114 LayerImpl* grand_child = child->children()[0]; | 5120 host_impl_->active_tree()->root_layer()->test_properties()->children[0]; |
| 5121 LayerImpl* grand_child = child->test_properties()->children[0]; |
| 5115 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5122 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5116 gfx::Vector2d(0, -5))); | 5123 gfx::Vector2d(0, -5))); |
| 5117 | 5124 |
| 5118 // The child should not have scrolled. | 5125 // The child should not have scrolled. |
| 5119 ExpectNone(*scroll_info.get(), child->id()); | 5126 ExpectNone(*scroll_info.get(), child->id()); |
| 5120 } | 5127 } |
| 5121 } | 5128 } |
| 5122 | 5129 |
| 5123 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { | 5130 TEST_F(LayerTreeHostImplTest, ScrollWithoutBubbling) { |
| 5124 // Scroll a child layer beyond its maximum scroll range and make sure the | 5131 // Scroll a child layer beyond its maximum scroll range and make sure the |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5173 .thread); | 5180 .thread); |
| 5174 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); | 5181 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()); |
| 5175 host_impl_->ScrollEnd(EndState().get()); | 5182 host_impl_->ScrollEnd(EndState().get()); |
| 5176 | 5183 |
| 5177 std::unique_ptr<ScrollAndScaleSet> scroll_info = | 5184 std::unique_ptr<ScrollAndScaleSet> scroll_info = |
| 5178 host_impl_->ProcessScrollDeltas(); | 5185 host_impl_->ProcessScrollDeltas(); |
| 5179 | 5186 |
| 5180 // The grand child should have scrolled up to its limit. | 5187 // The grand child should have scrolled up to its limit. |
| 5181 LayerImpl* child = host_impl_->active_tree() | 5188 LayerImpl* child = host_impl_->active_tree() |
| 5182 ->root_layer() | 5189 ->root_layer() |
| 5183 ->children()[0] | 5190 ->test_properties() |
| 5184 ->children()[0] | 5191 ->children[0] |
| 5185 ->children()[0]; | 5192 ->test_properties() |
| 5186 LayerImpl* grand_child = child->children()[0]; | 5193 ->children[0] |
| 5194 ->test_properties() |
| 5195 ->children[0]; |
| 5196 LayerImpl* grand_child = child->test_properties()->children[0]; |
| 5187 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), | 5197 EXPECT_TRUE(ScrollInfoContains(*scroll_info.get(), grand_child->id(), |
| 5188 gfx::Vector2d(0, -2))); | 5198 gfx::Vector2d(0, -2))); |
| 5189 | 5199 |
| 5190 // The child should not have scrolled. | 5200 // The child should not have scrolled. |
| 5191 ExpectNone(*scroll_info.get(), child->id()); | 5201 ExpectNone(*scroll_info.get(), child->id()); |
| 5192 | 5202 |
| 5193 // The next time we scroll we should only scroll the parent. | 5203 // The next time we scroll we should only scroll the parent. |
| 5194 scroll_delta = gfx::Vector2d(0, -3); | 5204 scroll_delta = gfx::Vector2d(0, -3); |
| 5195 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 5205 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 5196 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 5206 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6254 root->test_properties()->force_render_surface = true; | 6264 root->test_properties()->force_render_surface = true; |
| 6255 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 6265 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 6256 } | 6266 } |
| 6257 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 6267 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 6258 | 6268 |
| 6259 root->AddChild( | 6269 root->AddChild( |
| 6260 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 6270 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 6261 2, | 6271 2, |
| 6262 host_impl_->resource_provider())); | 6272 host_impl_->resource_provider())); |
| 6263 BlendStateCheckLayer* layer1 = | 6273 BlendStateCheckLayer* layer1 = |
| 6264 static_cast<BlendStateCheckLayer*>(root->children()[0]); | 6274 static_cast<BlendStateCheckLayer*>(root->test_properties()->children[0]); |
| 6265 layer1->SetPosition(gfx::PointF(2.f, 2.f)); | 6275 layer1->SetPosition(gfx::PointF(2.f, 2.f)); |
| 6266 | 6276 |
| 6267 LayerTreeHostImpl::FrameData frame; | 6277 LayerTreeHostImpl::FrameData frame; |
| 6268 | 6278 |
| 6269 // Opaque layer, drawn without blending. | 6279 // Opaque layer, drawn without blending. |
| 6270 layer1->SetContentsOpaque(true); | 6280 layer1->SetContentsOpaque(true); |
| 6271 layer1->SetExpectation(false, false); | 6281 layer1->SetExpectation(false, false); |
| 6272 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6282 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6273 SetNeedsRebuildPropertyTrees(); | 6283 SetNeedsRebuildPropertyTrees(); |
| 6274 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6284 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6307 SetNeedsRebuildPropertyTrees(); | 6317 SetNeedsRebuildPropertyTrees(); |
| 6308 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); | 6318 EXPECT_EQ(DRAW_SUCCESS, PrepareToDrawFrame(&frame)); |
| 6309 host_impl_->DrawLayers(&frame); | 6319 host_impl_->DrawLayers(&frame); |
| 6310 EXPECT_TRUE(layer1->quads_appended()); | 6320 EXPECT_TRUE(layer1->quads_appended()); |
| 6311 host_impl_->DidDrawAllLayers(frame); | 6321 host_impl_->DidDrawAllLayers(frame); |
| 6312 | 6322 |
| 6313 layer1->AddChild( | 6323 layer1->AddChild( |
| 6314 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 6324 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 6315 3, | 6325 3, |
| 6316 host_impl_->resource_provider())); | 6326 host_impl_->resource_provider())); |
| 6317 BlendStateCheckLayer* layer2 = | 6327 BlendStateCheckLayer* layer2 = static_cast<BlendStateCheckLayer*>( |
| 6318 static_cast<BlendStateCheckLayer*>(layer1->children()[0]); | 6328 layer1->test_properties()->children[0]); |
| 6319 layer2->SetPosition(gfx::PointF(4.f, 4.f)); | 6329 layer2->SetPosition(gfx::PointF(4.f, 4.f)); |
| 6320 | 6330 |
| 6321 // 2 opaque layers, drawn without blending. | 6331 // 2 opaque layers, drawn without blending. |
| 6322 layer1->SetContentsOpaque(true); | 6332 layer1->SetContentsOpaque(true); |
| 6323 layer1->test_properties()->opacity = 1.f; | 6333 layer1->test_properties()->opacity = 1.f; |
| 6324 layer1->NoteLayerPropertyChanged(); | 6334 layer1->NoteLayerPropertyChanged(); |
| 6325 layer1->SetExpectation(false, false); | 6335 layer1->SetExpectation(false, false); |
| 6326 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); | 6336 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); |
| 6327 layer2->SetContentsOpaque(true); | 6337 layer2->SetContentsOpaque(true); |
| 6328 layer2->test_properties()->opacity = 1.f; | 6338 layer2->test_properties()->opacity = 1.f; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6518 host_impl_->active_tree()->SetRootLayer( | 6528 host_impl_->active_tree()->SetRootLayer( |
| 6519 LayerImpl::Create(host_impl_->active_tree(), 1)); | 6529 LayerImpl::Create(host_impl_->active_tree(), 1)); |
| 6520 host_impl_->active_tree() | 6530 host_impl_->active_tree() |
| 6521 ->root_layer() | 6531 ->root_layer() |
| 6522 ->test_properties() | 6532 ->test_properties() |
| 6523 ->force_render_surface = true; | 6533 ->force_render_surface = true; |
| 6524 host_impl_->active_tree()->root_layer()->AddChild( | 6534 host_impl_->active_tree()->root_layer()->AddChild( |
| 6525 BlendStateCheckLayer::Create(host_impl_->active_tree(), | 6535 BlendStateCheckLayer::Create(host_impl_->active_tree(), |
| 6526 2, | 6536 2, |
| 6527 host_impl_->resource_provider())); | 6537 host_impl_->resource_provider())); |
| 6528 child_ = static_cast<BlendStateCheckLayer*>( | 6538 child_ = static_cast<BlendStateCheckLayer*>(host_impl_->active_tree() |
| 6529 host_impl_->active_tree()->root_layer()->children()[0]); | 6539 ->root_layer() |
| 6540 ->test_properties() |
| 6541 ->children[0]); |
| 6530 child_->SetExpectation(false, false); | 6542 child_->SetExpectation(false, false); |
| 6531 child_->SetContentsOpaque(true); | 6543 child_->SetContentsOpaque(true); |
| 6532 } | 6544 } |
| 6533 | 6545 |
| 6534 // Expect no gutter rects. | 6546 // Expect no gutter rects. |
| 6535 void TestLayerCoversFullViewport() { | 6547 void TestLayerCoversFullViewport() { |
| 6536 gfx::Rect layer_rect(viewport_size_); | 6548 gfx::Rect layer_rect(viewport_size_); |
| 6537 child_->SetPosition(gfx::PointF(layer_rect.origin())); | 6549 child_->SetPosition(gfx::PointF(layer_rect.origin())); |
| 6538 child_->SetBounds(layer_rect.size()); | 6550 child_->SetBounds(layer_rect.size()); |
| 6539 child_->SetQuadRect(gfx::Rect(layer_rect.size())); | 6551 child_->SetQuadRect(gfx::Rect(layer_rect.size())); |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6911 layer_tree_host_impl->DidDrawAllLayers(frame); | 6923 layer_tree_host_impl->DidDrawAllLayers(frame); |
| 6912 layer_tree_host_impl->SwapBuffers(frame); | 6924 layer_tree_host_impl->SwapBuffers(frame); |
| 6913 gfx::Rect expected_swap_rect(0, 0, 500, 500); | 6925 gfx::Rect expected_swap_rect(0, 0, 500, 500); |
| 6914 EXPECT_EQ(expected_swap_rect.ToString(), | 6926 EXPECT_EQ(expected_swap_rect.ToString(), |
| 6915 fake_output_surface->last_swap_rect().ToString()); | 6927 fake_output_surface->last_swap_rect().ToString()); |
| 6916 | 6928 |
| 6917 // Second frame, only the damaged area should get swapped. Damage should be | 6929 // Second frame, only the damaged area should get swapped. Damage should be |
| 6918 // the union of old and new child rects. | 6930 // the union of old and new child rects. |
| 6919 // expected damage rect: gfx::Rect(26, 28); | 6931 // expected damage rect: gfx::Rect(26, 28); |
| 6920 // expected swap rect: vertically flipped, with origin at bottom left corner. | 6932 // expected swap rect: vertically flipped, with origin at bottom left corner. |
| 6921 layer_tree_host_impl->active_tree()->root_layer()->children()[0]->SetPosition( | |
| 6922 gfx::PointF()); | |
| 6923 layer_tree_host_impl->active_tree() | 6933 layer_tree_host_impl->active_tree() |
| 6924 ->root_layer() | 6934 ->root_layer() |
| 6925 ->children()[0] | 6935 ->test_properties() |
| 6936 ->children[0] |
| 6937 ->SetPosition(gfx::PointF()); |
| 6938 layer_tree_host_impl->active_tree() |
| 6939 ->root_layer() |
| 6940 ->test_properties() |
| 6941 ->children[0] |
| 6926 ->NoteLayerPropertyChanged(); | 6942 ->NoteLayerPropertyChanged(); |
| 6927 layer_tree_host_impl->active_tree()->property_trees()->needs_rebuild = true; | 6943 layer_tree_host_impl->active_tree()->property_trees()->needs_rebuild = true; |
| 6928 layer_tree_host_impl->active_tree() | 6944 layer_tree_host_impl->active_tree() |
| 6929 ->BuildLayerListAndPropertyTreesForTesting(); | 6945 ->BuildLayerListAndPropertyTreesForTesting(); |
| 6930 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); | 6946 EXPECT_EQ(DRAW_SUCCESS, layer_tree_host_impl->PrepareToDraw(&frame)); |
| 6931 layer_tree_host_impl->DrawLayers(&frame); | 6947 layer_tree_host_impl->DrawLayers(&frame); |
| 6932 host_impl_->DidDrawAllLayers(frame); | 6948 host_impl_->DidDrawAllLayers(frame); |
| 6933 layer_tree_host_impl->SwapBuffers(frame); | 6949 layer_tree_host_impl->SwapBuffers(frame); |
| 6934 | 6950 |
| 6935 // Make sure that partial swap is constrained to the viewport dimensions | 6951 // Make sure that partial swap is constrained to the viewport dimensions |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7406 ASSERT_EQ(1u, frame.render_passes.size()); | 7422 ASSERT_EQ(1u, frame.render_passes.size()); |
| 7407 | 7423 |
| 7408 // Verify the damage rect for the root render pass. | 7424 // Verify the damage rect for the root render pass. |
| 7409 const RenderPass* root_render_pass = frame.render_passes.back().get(); | 7425 const RenderPass* root_render_pass = frame.render_passes.back().get(); |
| 7410 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); | 7426 EXPECT_EQ(expected_damage, root_render_pass->damage_rect); |
| 7411 | 7427 |
| 7412 // Verify the root and child layers' quads are generated and not being | 7428 // Verify the root and child layers' quads are generated and not being |
| 7413 // culled. | 7429 // culled. |
| 7414 ASSERT_EQ(2u, root_render_pass->quad_list.size()); | 7430 ASSERT_EQ(2u, root_render_pass->quad_list.size()); |
| 7415 | 7431 |
| 7416 LayerImpl* child = host_impl_->active_tree()->root_layer()->children()[0]; | 7432 LayerImpl* child = host_impl_->active_tree() |
| 7433 ->root_layer() |
| 7434 ->test_properties() |
| 7435 ->children[0]; |
| 7417 gfx::Rect expected_child_visible_rect(child->bounds()); | 7436 gfx::Rect expected_child_visible_rect(child->bounds()); |
| 7418 EXPECT_EQ(expected_child_visible_rect, | 7437 EXPECT_EQ(expected_child_visible_rect, |
| 7419 root_render_pass->quad_list.front()->visible_rect); | 7438 root_render_pass->quad_list.front()->visible_rect); |
| 7420 | 7439 |
| 7421 LayerImpl* root = host_impl_->active_tree()->root_layer(); | 7440 LayerImpl* root = host_impl_->active_tree()->root_layer(); |
| 7422 gfx::Rect expected_root_visible_rect(root->bounds()); | 7441 gfx::Rect expected_root_visible_rect(root->bounds()); |
| 7423 EXPECT_EQ(expected_root_visible_rect, | 7442 EXPECT_EQ(expected_root_visible_rect, |
| 7424 root_render_pass->quad_list.ElementAt(1)->visible_rect); | 7443 root_render_pass->quad_list.ElementAt(1)->visible_rect); |
| 7425 } | 7444 } |
| 7426 | 7445 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7937 | 7956 |
| 7938 root_scrolling->AddChild(std::move(child)); | 7957 root_scrolling->AddChild(std::move(child)); |
| 7939 root->AddChild(std::move(root_scrolling)); | 7958 root->AddChild(std::move(root_scrolling)); |
| 7940 host_impl_->active_tree()->SetRootLayer(std::move(root)); | 7959 host_impl_->active_tree()->SetRootLayer(std::move(root)); |
| 7941 host_impl_->active_tree()->DidBecomeActive(); | 7960 host_impl_->active_tree()->DidBecomeActive(); |
| 7942 host_impl_->SetViewportSize(surface_size); | 7961 host_impl_->SetViewportSize(surface_size); |
| 7943 SetNeedsRebuildPropertyTrees(); | 7962 SetNeedsRebuildPropertyTrees(); |
| 7944 DrawFrame(); | 7963 DrawFrame(); |
| 7945 { | 7964 { |
| 7946 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 7965 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 7947 LayerImpl* child = | 7966 LayerImpl* child = host_impl_->active_tree() |
| 7948 host_impl_->active_tree()->root_layer()->children()[0]->children()[0]; | 7967 ->root_layer() |
| 7949 LayerImpl* grand_child = child->children()[0]; | 7968 ->test_properties() |
| 7969 ->children[0] |
| 7970 ->test_properties() |
| 7971 ->children[0]; |
| 7972 LayerImpl* grand_child = child->test_properties()->children[0]; |
| 7950 | 7973 |
| 7951 gfx::Vector2d scroll_delta(0, -2); | 7974 gfx::Vector2d scroll_delta(0, -2); |
| 7952 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 7975 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 7953 host_impl_ | 7976 host_impl_ |
| 7954 ->ScrollBegin(BeginState(gfx::Point()).get(), | 7977 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| 7955 InputHandler::TOUCHSCREEN) | 7978 InputHandler::TOUCHSCREEN) |
| 7956 .thread); | 7979 .thread); |
| 7957 EXPECT_TRUE( | 7980 EXPECT_TRUE( |
| 7958 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) | 7981 host_impl_->ScrollBy(UpdateState(gfx::Point(), scroll_delta).get()) |
| 7959 .did_scroll); | 7982 .did_scroll); |
| (...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9174 gfx::Size inner_viewport = gfx::Size(25, 40); | 9197 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 9175 | 9198 |
| 9176 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9199 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 9177 | 9200 |
| 9178 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9201 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 9179 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9202 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9180 | 9203 |
| 9181 std::unique_ptr<LayerImpl> child = | 9204 std::unique_ptr<LayerImpl> child = |
| 9182 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 9205 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
| 9183 LayerImpl* child_scroll = child.get(); | 9206 LayerImpl* child_scroll = child.get(); |
| 9184 outer_scroll->children()[0]->AddChild(std::move(child)); | 9207 outer_scroll->test_properties()->children[0]->AddChild(std::move(child)); |
| 9185 | 9208 |
| 9186 SetNeedsRebuildPropertyTrees(); | 9209 SetNeedsRebuildPropertyTrees(); |
| 9187 DrawFrame(); | 9210 DrawFrame(); |
| 9188 { | 9211 { |
| 9189 std::unique_ptr<ScrollAndScaleSet> scroll_info; | 9212 std::unique_ptr<ScrollAndScaleSet> scroll_info; |
| 9190 | 9213 |
| 9191 gfx::Vector2d scroll_delta(0, inner_viewport.height()); | 9214 gfx::Vector2d scroll_delta(0, inner_viewport.height()); |
| 9192 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9215 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9193 host_impl_ | 9216 host_impl_ |
| 9194 ->ScrollBegin(BeginState(gfx::Point()).get(), | 9217 ->ScrollBegin(BeginState(gfx::Point()).get(), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9242 gfx::Size inner_viewport = gfx::Size(25, 40); | 9265 gfx::Size inner_viewport = gfx::Size(25, 40); |
| 9243 | 9266 |
| 9244 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); | 9267 SetupVirtualViewportLayers(content_size, outer_viewport, inner_viewport); |
| 9245 | 9268 |
| 9246 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); | 9269 LayerImpl* outer_scroll = host_impl_->OuterViewportScrollLayer(); |
| 9247 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); | 9270 LayerImpl* inner_scroll = host_impl_->InnerViewportScrollLayer(); |
| 9248 | 9271 |
| 9249 std::unique_ptr<LayerImpl> child = | 9272 std::unique_ptr<LayerImpl> child = |
| 9250 CreateScrollableLayer(10, outer_viewport, outer_scroll); | 9273 CreateScrollableLayer(10, outer_viewport, outer_scroll); |
| 9251 LayerImpl* child_scroll = child.get(); | 9274 LayerImpl* child_scroll = child.get(); |
| 9252 outer_scroll->children()[0]->AddChild(std::move(child)); | 9275 outer_scroll->test_properties()->children[0]->AddChild(std::move(child)); |
| 9253 | 9276 |
| 9254 SetNeedsRebuildPropertyTrees(); | 9277 SetNeedsRebuildPropertyTrees(); |
| 9255 DrawFrame(); | 9278 DrawFrame(); |
| 9256 | 9279 |
| 9257 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, | 9280 EXPECT_EQ(InputHandler::SCROLL_ON_IMPL_THREAD, |
| 9258 host_impl_ | 9281 host_impl_ |
| 9259 ->RootScrollBegin(BeginState(gfx::Point()).get(), | 9282 ->RootScrollBegin(BeginState(gfx::Point()).get(), |
| 9260 InputHandler::TOUCHSCREEN) | 9283 InputHandler::TOUCHSCREEN) |
| 9261 .thread); | 9284 .thread); |
| 9262 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); | 9285 EXPECT_EQ(host_impl_->CurrentlyScrollingLayer(), inner_scroll); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9518 gfx::Rect external_viewport(10, 20); | 9541 gfx::Rect external_viewport(10, 20); |
| 9519 host_impl_->SetExternalTilePriorityConstraints(external_viewport, | 9542 host_impl_->SetExternalTilePriorityConstraints(external_viewport, |
| 9520 external_transform); | 9543 external_transform); |
| 9521 EXPECT_TRUE(host_impl_->pending_tree()->needs_update_draw_properties()); | 9544 EXPECT_TRUE(host_impl_->pending_tree()->needs_update_draw_properties()); |
| 9522 EXPECT_TRUE(host_impl_->active_tree()->needs_update_draw_properties()); | 9545 EXPECT_TRUE(host_impl_->active_tree()->needs_update_draw_properties()); |
| 9523 } | 9546 } |
| 9524 | 9547 |
| 9525 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { | 9548 TEST_F(LayerTreeHostImplTest, ExternalViewportAffectsVisibleRects) { |
| 9526 const gfx::Size layer_size(100, 100); | 9549 const gfx::Size layer_size(100, 100); |
| 9527 SetupScrollAndContentsLayers(layer_size); | 9550 SetupScrollAndContentsLayers(layer_size); |
| 9528 LayerImpl* content_layer = | 9551 LayerImpl* content_layer = host_impl_->active_tree() |
| 9529 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; | 9552 ->OuterViewportScrollLayer() |
| 9553 ->test_properties() |
| 9554 ->children[0]; |
| 9530 SetNeedsRebuildPropertyTrees(); | 9555 SetNeedsRebuildPropertyTrees(); |
| 9531 RebuildPropertyTrees(); | 9556 RebuildPropertyTrees(); |
| 9532 | 9557 |
| 9533 bool update_lcd_text = false; | 9558 bool update_lcd_text = false; |
| 9534 | 9559 |
| 9535 host_impl_->SetViewportSize(gfx::Size(90, 90)); | 9560 host_impl_->SetViewportSize(gfx::Size(90, 90)); |
| 9536 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9561 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 9537 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); | 9562 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); |
| 9538 | 9563 |
| 9539 gfx::Transform external_transform; | 9564 gfx::Transform external_transform; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 9552 external_transform); | 9577 external_transform); |
| 9553 | 9578 |
| 9554 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 9579 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 9555 resourceless_software_draw); | 9580 resourceless_software_draw); |
| 9556 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); | 9581 EXPECT_EQ(gfx::Rect(90, 90), content_layer->visible_layer_rect()); |
| 9557 } | 9582 } |
| 9558 | 9583 |
| 9559 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { | 9584 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsVisibleRects) { |
| 9560 const gfx::Size layer_size(100, 100); | 9585 const gfx::Size layer_size(100, 100); |
| 9561 SetupScrollAndContentsLayers(layer_size); | 9586 SetupScrollAndContentsLayers(layer_size); |
| 9562 LayerImpl* content_layer = | 9587 LayerImpl* content_layer = host_impl_->active_tree() |
| 9563 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; | 9588 ->OuterViewportScrollLayer() |
| 9589 ->test_properties() |
| 9590 ->children[0]; |
| 9564 SetNeedsRebuildPropertyTrees(); | 9591 SetNeedsRebuildPropertyTrees(); |
| 9565 RebuildPropertyTrees(); | 9592 RebuildPropertyTrees(); |
| 9566 | 9593 |
| 9567 bool update_lcd_text = false; | 9594 bool update_lcd_text = false; |
| 9568 | 9595 |
| 9569 host_impl_->SetViewportSize(gfx::Size(50, 50)); | 9596 host_impl_->SetViewportSize(gfx::Size(50, 50)); |
| 9570 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); | 9597 host_impl_->active_tree()->UpdateDrawProperties(update_lcd_text); |
| 9571 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); | 9598 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); |
| 9572 | 9599 |
| 9573 gfx::Transform external_transform; | 9600 gfx::Transform external_transform; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 9591 external_transform); | 9618 external_transform); |
| 9592 | 9619 |
| 9593 host_impl_->OnDraw(external_transform, external_viewport, external_clip, | 9620 host_impl_->OnDraw(external_transform, external_viewport, external_clip, |
| 9594 resourceless_software_draw); | 9621 resourceless_software_draw); |
| 9595 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); | 9622 EXPECT_EQ(gfx::Rect(50, 50), content_layer->visible_layer_rect()); |
| 9596 } | 9623 } |
| 9597 | 9624 |
| 9598 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { | 9625 TEST_F(LayerTreeHostImplTest, ExternalTransformAffectsSublayerScaleFactor) { |
| 9599 const gfx::Size layer_size(100, 100); | 9626 const gfx::Size layer_size(100, 100); |
| 9600 SetupScrollAndContentsLayers(layer_size); | 9627 SetupScrollAndContentsLayers(layer_size); |
| 9601 LayerImpl* content_layer = | 9628 LayerImpl* content_layer = host_impl_->active_tree() |
| 9602 host_impl_->active_tree()->OuterViewportScrollLayer()->children()[0]; | 9629 ->OuterViewportScrollLayer() |
| 9630 ->test_properties() |
| 9631 ->children[0]; |
| 9603 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); | 9632 content_layer->AddChild(LayerImpl::Create(host_impl_->active_tree(), 100)); |
| 9604 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); | 9633 LayerImpl* test_layer = host_impl_->active_tree()->LayerById(100); |
| 9605 test_layer->test_properties()->force_render_surface = true; | 9634 test_layer->test_properties()->force_render_surface = true; |
| 9606 test_layer->SetDrawsContent(true); | 9635 test_layer->SetDrawsContent(true); |
| 9607 test_layer->SetBounds(layer_size); | 9636 test_layer->SetBounds(layer_size); |
| 9608 gfx::Transform perspective_transform; | 9637 gfx::Transform perspective_transform; |
| 9609 perspective_transform.ApplyPerspectiveDepth(2); | 9638 perspective_transform.ApplyPerspectiveDepth(2); |
| 9610 test_layer->SetTransform(perspective_transform); | 9639 test_layer->SetTransform(perspective_transform); |
| 9611 | 9640 |
| 9612 SetNeedsRebuildPropertyTrees(); | 9641 SetNeedsRebuildPropertyTrees(); |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10728 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), | 10757 host_impl_->ScrollBegin(BeginState(gfx::Point(5, 5)).get(), |
| 10729 InputHandler::TOUCHSCREEN); | 10758 InputHandler::TOUCHSCREEN); |
| 10730 host_impl_->ScrollBy( | 10759 host_impl_->ScrollBy( |
| 10731 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get()); | 10760 UpdateState(gfx::Point(), gfx::Vector2dF(0, scroll)).get()); |
| 10732 accumulated_scroll += scroll; | 10761 accumulated_scroll += scroll; |
| 10733 host_impl_->ScrollEnd(EndState().get()); | 10762 host_impl_->ScrollEnd(EndState().get()); |
| 10734 host_impl_->active_tree()->UpdateDrawProperties(false); | 10763 host_impl_->active_tree()->UpdateDrawProperties(false); |
| 10735 | 10764 |
| 10736 host_impl_->CreatePendingTree(); | 10765 host_impl_->CreatePendingTree(); |
| 10737 host_impl_->pending_tree()->set_source_frame_number(i + 1); | 10766 host_impl_->pending_tree()->set_source_frame_number(i + 1); |
| 10738 LayerImpl* content_layer = | 10767 LayerImpl* content_layer = host_impl_->pending_tree() |
| 10739 host_impl_->pending_tree()->OuterViewportScrollLayer()->children()[0]; | 10768 ->OuterViewportScrollLayer() |
| 10769 ->test_properties() |
| 10770 ->children[0]; |
| 10740 // The scroll done on the active tree is undone on the pending tree. | 10771 // The scroll done on the active tree is undone on the pending tree. |
| 10741 gfx::Transform translate; | 10772 gfx::Transform translate; |
| 10742 translate.Translate(0, accumulated_scroll); | 10773 translate.Translate(0, accumulated_scroll); |
| 10743 content_layer->SetTransform(translate); | 10774 content_layer->SetTransform(translate); |
| 10744 | 10775 |
| 10745 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 10776 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 10746 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f); | 10777 pending_tree->PushPageScaleFromMainThread(1.f, 1.f, 1.f); |
| 10747 LayerImpl* last_scrolled_layer = pending_tree->LayerById( | 10778 LayerImpl* last_scrolled_layer = pending_tree->LayerById( |
| 10748 host_impl_->active_tree()->LastScrolledLayerId()); | 10779 host_impl_->active_tree()->LastScrolledLayerId()); |
| 10749 | 10780 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10798 | 10829 |
| 10799 // Re-initialize with a software output surface. | 10830 // Re-initialize with a software output surface. |
| 10800 output_surface_ = FakeOutputSurface::CreateSoftware( | 10831 output_surface_ = FakeOutputSurface::CreateSoftware( |
| 10801 base::WrapUnique(new SoftwareOutputDevice)); | 10832 base::WrapUnique(new SoftwareOutputDevice)); |
| 10802 host_impl_->InitializeRenderer(output_surface_.get()); | 10833 host_impl_->InitializeRenderer(output_surface_.get()); |
| 10803 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 10834 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
| 10804 } | 10835 } |
| 10805 | 10836 |
| 10806 } // namespace | 10837 } // namespace |
| 10807 } // namespace cc | 10838 } // namespace cc |
| OLD | NEW |