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/damage_tracker.h" | 5 #include "cc/trees/damage_tracker.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 498 |
499 gfx::Transform transform; | 499 gfx::Transform transform; |
500 transform.Translate3d(550.0, 500.0, 0.0); | 500 transform.Translate3d(550.0, 500.0, 0.0); |
501 transform.ApplyPerspectiveDepth(1.0); | 501 transform.ApplyPerspectiveDepth(1.0); |
502 transform.RotateAboutYAxis(45.0); | 502 transform.RotateAboutYAxis(45.0); |
503 transform.Translate3d(-50.0, -50.0, 0.0); | 503 transform.Translate3d(-50.0, -50.0, 0.0); |
504 | 504 |
505 // Set up the child | 505 // Set up the child |
506 child->SetPosition(gfx::PointF(0.f, 0.f)); | 506 child->SetPosition(gfx::PointF(0.f, 0.f)); |
507 child->SetBounds(gfx::Size(100, 100)); | 507 child->SetBounds(gfx::Size(100, 100)); |
508 child->SetTransform(transform); | 508 child->test_properties()->transform = transform; |
509 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 509 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
510 EmulateDrawingOneFrame(root); | 510 EmulateDrawingOneFrame(root); |
511 | 511 |
512 // Sanity check that the child layer's bounds would actually get clipped by | 512 // Sanity check that the child layer's bounds would actually get clipped by |
513 // w < 0, otherwise this test is not actually testing the intended scenario. | 513 // w < 0, otherwise this test is not actually testing the intended scenario. |
514 gfx::QuadF test_quad(gfx::RectF(gfx::PointF(), gfx::SizeF(100.f, 100.f))); | 514 gfx::QuadF test_quad(gfx::RectF(gfx::PointF(), gfx::SizeF(100.f, 100.f))); |
515 bool clipped = false; | 515 bool clipped = false; |
516 MathUtil::MapQuad(transform, test_quad, &clipped); | 516 MathUtil::MapQuad(transform, test_quad, &clipped); |
517 EXPECT_TRUE(clipped); | 517 EXPECT_TRUE(clipped); |
518 | 518 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 | 619 |
620 FilterOperations filters; | 620 FilterOperations filters; |
621 filters.Append(FilterOperation::CreateReferenceFilter( | 621 filters.Append(FilterOperation::CreateReferenceFilter( |
622 SkBlurImageFilter::Make(2, 2, nullptr))); | 622 SkBlurImageFilter::Make(2, 2, nullptr))); |
623 | 623 |
624 // Setting the filter will damage the whole surface. | 624 // Setting the filter will damage the whole surface. |
625 gfx::Transform transform; | 625 gfx::Transform transform; |
626 transform.RotateAboutYAxis(60); | 626 transform.RotateAboutYAxis(60); |
627 ClearDamageForAllSurfaces(root); | 627 ClearDamageForAllSurfaces(root); |
628 child->test_properties()->force_render_surface = true; | 628 child->test_properties()->force_render_surface = true; |
629 child->SetTransform(transform); | 629 child->test_properties()->transform = transform; |
630 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 630 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
631 EmulateDrawingOneFrame(root); | 631 EmulateDrawingOneFrame(root); |
632 child->OnFilterAnimated(filters); | 632 child->OnFilterAnimated(filters); |
633 EmulateDrawingOneFrame(root); | 633 EmulateDrawingOneFrame(root); |
634 root_damage_rect = | 634 root_damage_rect = |
635 root->render_surface()->damage_tracker()->current_damage_rect(); | 635 root->render_surface()->damage_tracker()->current_damage_rect(); |
636 child_damage_rect = | 636 child_damage_rect = |
637 child->render_surface()->damage_tracker()->current_damage_rect(); | 637 child->render_surface()->damage_tracker()->current_damage_rect(); |
638 | 638 |
639 // Blur outset is 6px for a 2px blur. | 639 // Blur outset is 6px for a 2px blur. |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 | 1222 |
1223 // CASE 1: adding a reflection about the left edge of grand_child1. | 1223 // CASE 1: adding a reflection about the left edge of grand_child1. |
1224 // | 1224 // |
1225 ClearDamageForAllSurfaces(root); | 1225 ClearDamageForAllSurfaces(root); |
1226 { | 1226 { |
1227 std::unique_ptr<LayerImpl> grand_child1_replica = | 1227 std::unique_ptr<LayerImpl> grand_child1_replica = |
1228 LayerImpl::Create(host_impl_.active_tree(), 7); | 1228 LayerImpl::Create(host_impl_.active_tree(), 7); |
1229 grand_child1_replica->SetPosition(gfx::PointF()); | 1229 grand_child1_replica->SetPosition(gfx::PointF()); |
1230 gfx::Transform reflection; | 1230 gfx::Transform reflection; |
1231 reflection.Scale3d(-1.0, 1.0, 1.0); | 1231 reflection.Scale3d(-1.0, 1.0, 1.0); |
1232 grand_child1_replica->SetTransform(reflection); | 1232 grand_child1_replica->test_properties()->transform = reflection; |
1233 grand_child1->test_properties()->SetReplicaLayer( | 1233 grand_child1->test_properties()->SetReplicaLayer( |
1234 std::move(grand_child1_replica)); | 1234 std::move(grand_child1_replica)); |
1235 grand_child1->test_properties()->force_render_surface = true; | 1235 grand_child1->test_properties()->force_render_surface = true; |
1236 grand_child1->NoteLayerPropertyChanged(); | 1236 grand_child1->NoteLayerPropertyChanged(); |
1237 } | 1237 } |
1238 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1238 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
1239 EmulateDrawingOneFrame(root); | 1239 EmulateDrawingOneFrame(root); |
1240 | 1240 |
1241 gfx::Rect grand_child_damage_rect = | 1241 gfx::Rect grand_child_damage_rect = |
1242 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); | 1242 grand_child1->render_surface()->damage_tracker()->current_damage_rect(); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 | 1410 |
1411 ClearDamageForAllSurfaces(root); | 1411 ClearDamageForAllSurfaces(root); |
1412 | 1412 |
1413 // Create a reflection about the left edge of grand_child1. | 1413 // Create a reflection about the left edge of grand_child1. |
1414 { | 1414 { |
1415 std::unique_ptr<LayerImpl> grand_child1_replica = | 1415 std::unique_ptr<LayerImpl> grand_child1_replica = |
1416 LayerImpl::Create(host_impl_.active_tree(), 6); | 1416 LayerImpl::Create(host_impl_.active_tree(), 6); |
1417 grand_child1_replica->SetPosition(gfx::PointF()); | 1417 grand_child1_replica->SetPosition(gfx::PointF()); |
1418 gfx::Transform reflection; | 1418 gfx::Transform reflection; |
1419 reflection.Scale3d(-1.0, 1.0, 1.0); | 1419 reflection.Scale3d(-1.0, 1.0, 1.0); |
1420 grand_child1_replica->SetTransform(reflection); | 1420 grand_child1_replica->test_properties()->transform = reflection; |
1421 grand_child1->test_properties()->SetReplicaLayer( | 1421 grand_child1->test_properties()->SetReplicaLayer( |
1422 std::move(grand_child1_replica)); | 1422 std::move(grand_child1_replica)); |
1423 grand_child1->test_properties()->force_render_surface = true; | 1423 grand_child1->test_properties()->force_render_surface = true; |
1424 } | 1424 } |
1425 LayerImpl* grand_child1_replica = | 1425 LayerImpl* grand_child1_replica = |
1426 grand_child1->test_properties()->replica_layer; | 1426 grand_child1->test_properties()->replica_layer; |
1427 | 1427 |
1428 // Set up the mask layer on the replica layer | 1428 // Set up the mask layer on the replica layer |
1429 { | 1429 { |
1430 std::unique_ptr<LayerImpl> replica_mask_layer = | 1430 std::unique_ptr<LayerImpl> replica_mask_layer = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 { | 1494 { |
1495 std::unique_ptr<LayerImpl> grand_child1_replica = | 1495 std::unique_ptr<LayerImpl> grand_child1_replica = |
1496 LayerImpl::Create(host_impl_.active_tree(), 6); | 1496 LayerImpl::Create(host_impl_.active_tree(), 6); |
1497 grand_child1_replica->SetPosition(gfx::PointF()); | 1497 grand_child1_replica->SetPosition(gfx::PointF()); |
1498 | 1498 |
1499 // This is the anchor being tested. | 1499 // This is the anchor being tested. |
1500 grand_child1_replica->test_properties()->transform_origin = | 1500 grand_child1_replica->test_properties()->transform_origin = |
1501 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f); | 1501 gfx::Point3F(grand_child1->bounds().width(), 0.f, 0.f); |
1502 gfx::Transform reflection; | 1502 gfx::Transform reflection; |
1503 reflection.Scale3d(-1.0, 1.0, 1.0); | 1503 reflection.Scale3d(-1.0, 1.0, 1.0); |
1504 grand_child1_replica->SetTransform(reflection); | 1504 grand_child1_replica->test_properties()->transform = reflection; |
1505 // We need to set parent on replica layer for property tree building. | 1505 // We need to set parent on replica layer for property tree building. |
1506 grand_child1_replica->test_properties()->parent = grand_child1; | 1506 grand_child1_replica->test_properties()->parent = grand_child1; |
1507 grand_child1->test_properties()->SetReplicaLayer( | 1507 grand_child1->test_properties()->SetReplicaLayer( |
1508 std::move(grand_child1_replica)); | 1508 std::move(grand_child1_replica)); |
1509 grand_child1->test_properties()->force_render_surface = true; | 1509 grand_child1->test_properties()->force_render_surface = true; |
1510 } | 1510 } |
1511 LayerImpl* grand_child1_replica = | 1511 LayerImpl* grand_child1_replica = |
1512 grand_child1->test_properties()->replica_layer; | 1512 grand_child1->test_properties()->replica_layer; |
1513 | 1513 |
1514 // Set up the mask layer on the replica layer | 1514 // Set up the mask layer on the replica layer |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 LayerImpl* root = CreateTestTreeWithOneSurface(); | 1652 LayerImpl* root = CreateTestTreeWithOneSurface(); |
1653 LayerImpl* child = root->test_properties()->children[0]; | 1653 LayerImpl* child = root->test_properties()->children[0]; |
1654 | 1654 |
1655 gfx::Transform transform; | 1655 gfx::Transform transform; |
1656 transform.Translate(-kBigNumber, -kBigNumber); | 1656 transform.Translate(-kBigNumber, -kBigNumber); |
1657 | 1657 |
1658 // The child layer covers (0, 0, i, i) of the viewport, | 1658 // The child layer covers (0, 0, i, i) of the viewport, |
1659 // but has a huge negative position. | 1659 // but has a huge negative position. |
1660 child->SetPosition(gfx::PointF()); | 1660 child->SetPosition(gfx::PointF()); |
1661 child->SetBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); | 1661 child->SetBounds(gfx::Size(kBigNumber + i, kBigNumber + i)); |
1662 child->SetTransform(transform); | 1662 child->test_properties()->transform = transform; |
1663 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 1663 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
1664 EmulateDrawingOneFrame(root); | 1664 EmulateDrawingOneFrame(root); |
1665 | 1665 |
1666 // The expected damage should cover the visible part of the child layer, | 1666 // The expected damage should cover the visible part of the child layer, |
1667 // which is (0, 0, i, i) in the viewport. | 1667 // which is (0, 0, i, i) in the viewport. |
1668 gfx::Rect root_damage_rect = | 1668 gfx::Rect root_damage_rect = |
1669 root->render_surface()->damage_tracker()->current_damage_rect(); | 1669 root->render_surface()->damage_tracker()->current_damage_rect(); |
1670 gfx::Rect damage_we_care_about = gfx::Rect(i, i); | 1670 gfx::Rect damage_we_care_about = gfx::Rect(i, i); |
1671 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); | 1671 EXPECT_LE(damage_we_care_about.right(), root_damage_rect.right()); |
1672 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); | 1672 EXPECT_LE(damage_we_care_about.bottom(), root_damage_rect.bottom()); |
1673 } | 1673 } |
1674 } | 1674 } |
1675 | 1675 |
1676 } // namespace | 1676 } // namespace |
1677 } // namespace cc | 1677 } // namespace cc |
OLD | NEW |