OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/trees/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1414 SetLayerPropertiesForTesting(parent, scale_matrix, gfx::Point3F(), | 1414 SetLayerPropertiesForTesting(parent, scale_matrix, gfx::Point3F(), |
1415 gfx::PointF(), gfx::Size(), true, false, true); | 1415 gfx::PointF(), gfx::Size(), true, false, true); |
1416 SetLayerPropertiesForTesting(child1, identity_matrix, gfx::Point3F(), | 1416 SetLayerPropertiesForTesting(child1, identity_matrix, gfx::Point3F(), |
1417 gfx::PointF(0, 0), gfx::Size(25, 25), true, | 1417 gfx::PointF(0, 0), gfx::Size(25, 25), true, |
1418 false, true); | 1418 false, true); |
1419 SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(), | 1419 SetLayerPropertiesForTesting(child2, identity_matrix, gfx::Point3F(), |
1420 gfx::PointF(25, 25), gfx::Size(25, 25), true, | 1420 gfx::PointF(25, 25), gfx::Size(25, 25), true, |
1421 false, true); | 1421 false, true); |
1422 FilterOperations filters; | 1422 FilterOperations filters; |
1423 filters.Append(FilterOperation::CreateBlurFilter(10.0f)); | 1423 filters.Append(FilterOperation::CreateBlurFilter(10.0f)); |
1424 parent->SetFilters(filters); | 1424 parent->test_properties()->filters = filters; |
1425 | 1425 |
1426 LayerImplList render_surface_layer_list; | 1426 LayerImplList render_surface_layer_list; |
1427 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1427 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1428 root, root->bounds(), &render_surface_layer_list); | 1428 root, root->bounds(), &render_surface_layer_list); |
1429 inputs.can_adjust_raster_scales = true; | 1429 inputs.can_adjust_raster_scales = true; |
1430 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1430 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1431 | 1431 |
1432 ASSERT_TRUE(parent->render_surface()); | 1432 ASSERT_TRUE(parent->render_surface()); |
1433 EXPECT_EQ(2U, parent->render_surface()->layer_list().size()); | 1433 EXPECT_EQ(2U, parent->render_surface()->layer_list().size()); |
1434 EXPECT_EQ(4U, render_surface_layer_list.size()); | 1434 EXPECT_EQ(4U, render_surface_layer_list.size()); |
(...skipping 13 matching lines...) Expand all Loading... |
1448 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), | 1448 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), |
1449 gfx::PointF(), gfx::Size(100, 100), true, false, | 1449 gfx::PointF(), gfx::Size(100, 100), true, false, |
1450 true); | 1450 true); |
1451 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), | 1451 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), |
1452 gfx::PointF(), gfx::Size(25, 25), true, false, | 1452 gfx::PointF(), gfx::Size(25, 25), true, false, |
1453 true); | 1453 true); |
1454 | 1454 |
1455 FilterOperations filters; | 1455 FilterOperations filters; |
1456 filters.Append(FilterOperation::CreateReferenceFilter( | 1456 filters.Append(FilterOperation::CreateReferenceFilter( |
1457 SkOffsetImageFilter::Make(50, 50, nullptr))); | 1457 SkOffsetImageFilter::Make(50, 50, nullptr))); |
1458 child->SetFilters(filters); | 1458 child->test_properties()->filters = filters; |
1459 | 1459 |
1460 ExecuteCalculateDrawProperties(root); | 1460 ExecuteCalculateDrawProperties(root); |
1461 | 1461 |
1462 // The render surface's size should be unaffected by the offset image filter; | 1462 // The render surface's size should be unaffected by the offset image filter; |
1463 // it need only have a drawable content rect large enough to contain the | 1463 // it need only have a drawable content rect large enough to contain the |
1464 // contents (at the new offset). | 1464 // contents (at the new offset). |
1465 ASSERT_TRUE(child->render_surface()); | 1465 ASSERT_TRUE(child->render_surface()); |
1466 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), | 1466 EXPECT_EQ(gfx::RectF(50, 50, 25, 25), |
1467 child->render_surface()->DrawableContentRect()); | 1467 child->render_surface()->DrawableContentRect()); |
1468 } | 1468 } |
1469 | 1469 |
1470 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) { | 1470 TEST_F(LayerTreeHostCommonTest, DrawableContentRectForReferenceFilterHighDpi) { |
1471 const float device_scale_factor = 2.0f; | 1471 const float device_scale_factor = 2.0f; |
1472 | 1472 |
1473 LayerImpl* root = root_layer_for_testing(); | 1473 LayerImpl* root = root_layer_for_testing(); |
1474 LayerImpl* child = AddChild<LayerImpl>(root); | 1474 LayerImpl* child = AddChild<LayerImpl>(root); |
1475 child->SetDrawsContent(true); | 1475 child->SetDrawsContent(true); |
1476 | 1476 |
1477 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), | 1477 SetLayerPropertiesForTesting(root, gfx::Transform(), gfx::Point3F(), |
1478 gfx::PointF(), gfx::Size(100, 100), true, false, | 1478 gfx::PointF(), gfx::Size(100, 100), true, false, |
1479 true); | 1479 true); |
1480 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), | 1480 SetLayerPropertiesForTesting(child, gfx::Transform(), gfx::Point3F(), |
1481 gfx::PointF(), gfx::Size(25, 25), true, false, | 1481 gfx::PointF(), gfx::Size(25, 25), true, false, |
1482 true); | 1482 true); |
1483 | 1483 |
1484 FilterOperations filters; | 1484 FilterOperations filters; |
1485 filters.Append(FilterOperation::CreateReferenceFilter( | 1485 filters.Append(FilterOperation::CreateReferenceFilter( |
1486 SkOffsetImageFilter::Make(50, 50, nullptr))); | 1486 SkOffsetImageFilter::Make(50, 50, nullptr))); |
1487 child->SetFilters(filters); | 1487 child->test_properties()->filters = filters; |
1488 | 1488 |
1489 ExecuteCalculateDrawProperties(root, device_scale_factor); | 1489 ExecuteCalculateDrawProperties(root, device_scale_factor); |
1490 | 1490 |
1491 // The render surface's size should be unaffected by the offset image filter; | 1491 // The render surface's size should be unaffected by the offset image filter; |
1492 // it need only have a drawable content rect large enough to contain the | 1492 // it need only have a drawable content rect large enough to contain the |
1493 // contents (at the new offset). All coordinates should be scaled by 2, | 1493 // contents (at the new offset). All coordinates should be scaled by 2, |
1494 // corresponding to the device scale factor. | 1494 // corresponding to the device scale factor. |
1495 ASSERT_TRUE(child->render_surface()); | 1495 ASSERT_TRUE(child->render_surface()); |
1496 EXPECT_EQ(gfx::RectF(100, 100, 50, 50), | 1496 EXPECT_EQ(gfx::RectF(100, 100, 50, 50), |
1497 child->render_surface()->DrawableContentRect()); | 1497 child->render_surface()->DrawableContentRect()); |
(...skipping 7001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8499 | 8499 |
8500 SetElementIdsForTesting(); | 8500 SetElementIdsForTesting(); |
8501 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), | 8501 AddAnimatedFilterToElementWithPlayer(child->element_id(), timeline_impl(), |
8502 10.0, 0.1f, 0.2f); | 8502 10.0, 0.1f, 0.2f); |
8503 ExecuteCalculateDrawProperties(root); | 8503 ExecuteCalculateDrawProperties(root); |
8504 | 8504 |
8505 EXPECT_TRUE(root->has_render_surface()); | 8505 EXPECT_TRUE(root->has_render_surface()); |
8506 EXPECT_TRUE(child->has_render_surface()); | 8506 EXPECT_TRUE(child->has_render_surface()); |
8507 EXPECT_FALSE(grandchild->has_render_surface()); | 8507 EXPECT_FALSE(grandchild->has_render_surface()); |
8508 | 8508 |
8509 EXPECT_TRUE(root->filters().IsEmpty()); | 8509 EXPECT_TRUE(root->render_surface()->Filters().IsEmpty()); |
8510 EXPECT_TRUE(child->filters().IsEmpty()); | 8510 EXPECT_TRUE(child->render_surface()->Filters().IsEmpty()); |
8511 EXPECT_TRUE(grandchild->filters().IsEmpty()); | |
8512 | 8511 |
8513 EXPECT_FALSE(root->FilterIsAnimating()); | 8512 EXPECT_FALSE(root->FilterIsAnimating()); |
8514 EXPECT_TRUE(child->FilterIsAnimating()); | 8513 EXPECT_TRUE(child->FilterIsAnimating()); |
8515 EXPECT_FALSE(grandchild->FilterIsAnimating()); | 8514 EXPECT_FALSE(grandchild->FilterIsAnimating()); |
8516 } | 8515 } |
8517 | 8516 |
8518 // Verify that having a filter animation with a delayed start time creates a | 8517 // Verify that having a filter animation with a delayed start time creates a |
8519 // render surface. | 8518 // render surface. |
8520 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { | 8519 TEST_F(LayerTreeHostCommonTest, DelayedFilterAnimationCreatesRenderSurface) { |
8521 LayerImpl* root = root_layer_for_testing(); | 8520 LayerImpl* root = root_layer_for_testing(); |
(...skipping 26 matching lines...) Expand all Loading... |
8548 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); | 8547 animation->set_time_offset(base::TimeDelta::FromMilliseconds(-1000)); |
8549 | 8548 |
8550 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(), | 8549 AddAnimationToElementWithPlayer(child->element_id(), timeline_impl(), |
8551 std::move(animation)); | 8550 std::move(animation)); |
8552 ExecuteCalculateDrawProperties(root); | 8551 ExecuteCalculateDrawProperties(root); |
8553 | 8552 |
8554 EXPECT_TRUE(root->has_render_surface()); | 8553 EXPECT_TRUE(root->has_render_surface()); |
8555 EXPECT_TRUE(child->has_render_surface()); | 8554 EXPECT_TRUE(child->has_render_surface()); |
8556 EXPECT_FALSE(grandchild->has_render_surface()); | 8555 EXPECT_FALSE(grandchild->has_render_surface()); |
8557 | 8556 |
8558 EXPECT_TRUE(root->filters().IsEmpty()); | 8557 EXPECT_TRUE(root->render_surface()->Filters().IsEmpty()); |
8559 EXPECT_TRUE(child->filters().IsEmpty()); | 8558 EXPECT_TRUE(child->render_surface()->Filters().IsEmpty()); |
8560 EXPECT_TRUE(grandchild->filters().IsEmpty()); | |
8561 | 8559 |
8562 EXPECT_FALSE(root->FilterIsAnimating()); | 8560 EXPECT_FALSE(root->FilterIsAnimating()); |
8563 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation()); | 8561 EXPECT_FALSE(root->HasPotentiallyRunningFilterAnimation()); |
8564 EXPECT_FALSE(child->FilterIsAnimating()); | 8562 EXPECT_FALSE(child->FilterIsAnimating()); |
8565 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation()); | 8563 EXPECT_TRUE(child->HasPotentiallyRunningFilterAnimation()); |
8566 EXPECT_FALSE(grandchild->FilterIsAnimating()); | 8564 EXPECT_FALSE(grandchild->FilterIsAnimating()); |
8567 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); | 8565 EXPECT_FALSE(grandchild->HasPotentiallyRunningFilterAnimation()); |
8568 } | 8566 } |
8569 | 8567 |
8570 // Ensures that the property tree code accounts for offsets between fixed | 8568 // Ensures that the property tree code accounts for offsets between fixed |
(...skipping 1950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10521 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10519 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10522 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10520 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10523 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10521 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10524 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10522 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10525 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10523 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10526 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10524 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10527 } | 10525 } |
10528 | 10526 |
10529 } // namespace | 10527 } // namespace |
10530 } // namespace cc | 10528 } // namespace cc |
OLD | NEW |