Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: cc/layers/layer_position_constraint_unittest.cc

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Calculate damage of |force_render_surface|. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/layers/layer_position_constraint.h" 5 #include "cc/layers/layer_position_constraint.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "cc/animation/animation_host.h" 9 #include "cc/animation/animation_host.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 431 }
432 432
433 TEST_F(LayerPositionConstraintTest, 433 TEST_F(LayerPositionConstraintTest,
434 ScrollCompensationForFixedPositionWithIntermediateSurfaceAndTransforms) { 434 ScrollCompensationForFixedPositionWithIntermediateSurfaceAndTransforms) {
435 // This test checks for correct scroll compensation when the fixed-position 435 // This test checks for correct scroll compensation when the fixed-position
436 // container contributes to a different render surface than the fixed-position 436 // container contributes to a different render surface than the fixed-position
437 // layer. In this case, the surface draw transforms also have to be accounted 437 // layer. In this case, the surface draw transforms also have to be accounted
438 // for when checking the scroll delta. 438 // for when checking the scroll delta.
439 child_->SetIsContainerForFixedPositionLayers(true); 439 child_->SetIsContainerForFixedPositionLayers(true);
440 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); 440 grand_child_->SetPosition(gfx::PointF(8.f, 6.f));
441 grand_child_->SetForceRenderSurfaceForTesting(true); 441 grand_child_->SetForceRenderSurface(true);
442 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); 442 great_grand_child_->SetPositionConstraint(fixed_to_top_left_);
443 443
444 gfx::Transform rotation_about_z; 444 gfx::Transform rotation_about_z;
445 rotation_about_z.RotateAboutZAxis(90.0); 445 rotation_about_z.RotateAboutZAxis(90.0);
446 great_grand_child_->SetTransform(rotation_about_z); 446 great_grand_child_->SetTransform(rotation_about_z);
447 447
448 CommitAndUpdateImplPointers(); 448 CommitAndUpdateImplPointers();
449 449
450 // Case 1: scroll delta of 0, 0 450 // Case 1: scroll delta of 0, 0
451 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); 451 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 scoped_refptr<Layer> fixed_position_child = 557 scoped_refptr<Layer> fixed_position_child =
558 make_scoped_refptr(new LayerWithForcedDrawsContent()); 558 make_scoped_refptr(new LayerWithForcedDrawsContent());
559 SetLayerPropertiesForTesting(fixed_position_child.get(), gfx::Transform(), 559 SetLayerPropertiesForTesting(fixed_position_child.get(), gfx::Transform(),
560 gfx::Point3F(), gfx::PointF(), 560 gfx::Point3F(), gfx::PointF(),
561 gfx::Size(100, 100), true); 561 gfx::Size(100, 100), true);
562 great_grand_child_->AddChild(fixed_position_child); 562 great_grand_child_->AddChild(fixed_position_child);
563 563
564 // Actually set up the scenario here. 564 // Actually set up the scenario here.
565 child_->SetIsContainerForFixedPositionLayers(true); 565 child_->SetIsContainerForFixedPositionLayers(true);
566 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); 566 grand_child_->SetPosition(gfx::PointF(8.f, 6.f));
567 grand_child_->SetForceRenderSurfaceForTesting(true); 567 grand_child_->SetForceRenderSurface(true);
568 great_grand_child_->SetPosition(gfx::PointF(40.f, 60.f)); 568 great_grand_child_->SetPosition(gfx::PointF(40.f, 60.f));
569 great_grand_child_->SetForceRenderSurfaceForTesting(true); 569 great_grand_child_->SetForceRenderSurface(true);
570 fixed_position_child->SetPositionConstraint(fixed_to_top_left_); 570 fixed_position_child->SetPositionConstraint(fixed_to_top_left_);
571 571
572 // The additional rotation, which is non-commutative with translations, helps 572 // The additional rotation, which is non-commutative with translations, helps
573 // to verify that we have correct order-of-operations in the final scroll 573 // to verify that we have correct order-of-operations in the final scroll
574 // compensation. Note that rotating about the center of the layer ensures we 574 // compensation. Note that rotating about the center of the layer ensures we
575 // do not accidentally clip away layers that we want to test. 575 // do not accidentally clip away layers that we want to test.
576 gfx::Transform rotation_about_z; 576 gfx::Transform rotation_about_z;
577 rotation_about_z.Translate(50.0, 50.0); 577 rotation_about_z.Translate(50.0, 50.0);
578 rotation_about_z.RotateAboutZAxis(90.0); 578 rotation_about_z.RotateAboutZAxis(90.0);
579 rotation_about_z.Translate(-50.0, -50.0); 579 rotation_about_z.Translate(-50.0, -50.0);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 scoped_refptr<Layer> fixed_position_child = 717 scoped_refptr<Layer> fixed_position_child =
718 make_scoped_refptr(new LayerWithForcedDrawsContent()); 718 make_scoped_refptr(new LayerWithForcedDrawsContent());
719 SetLayerPropertiesForTesting(fixed_position_child.get(), gfx::Transform(), 719 SetLayerPropertiesForTesting(fixed_position_child.get(), gfx::Transform(),
720 gfx::Point3F(), gfx::PointF(), 720 gfx::Point3F(), gfx::PointF(),
721 gfx::Size(100, 100), true); 721 gfx::Size(100, 100), true);
722 great_grand_child_->AddChild(fixed_position_child); 722 great_grand_child_->AddChild(fixed_position_child);
723 723
724 // Actually set up the scenario here. 724 // Actually set up the scenario here.
725 child_transform_layer_->SetIsContainerForFixedPositionLayers(true); 725 child_transform_layer_->SetIsContainerForFixedPositionLayers(true);
726 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); 726 grand_child_->SetPosition(gfx::PointF(8.f, 6.f));
727 grand_child_->SetForceRenderSurfaceForTesting(true); 727 grand_child_->SetForceRenderSurface(true);
728 great_grand_child_->SetPosition(gfx::PointF(40.f, 60.f)); 728 great_grand_child_->SetPosition(gfx::PointF(40.f, 60.f));
729 great_grand_child_->SetForceRenderSurfaceForTesting(true); 729 great_grand_child_->SetForceRenderSurface(true);
730 fixed_position_child->SetPositionConstraint(fixed_to_top_left_); 730 fixed_position_child->SetPositionConstraint(fixed_to_top_left_);
731 731
732 // The additional rotations, which are non-commutative with translations, help 732 // The additional rotations, which are non-commutative with translations, help
733 // to verify that we have correct order-of-operations in the final scroll 733 // to verify that we have correct order-of-operations in the final scroll
734 // compensation. Note that rotating about the center of the layer ensures we 734 // compensation. Note that rotating about the center of the layer ensures we
735 // do not accidentally clip away layers that we want to test. 735 // do not accidentally clip away layers that we want to test.
736 gfx::Transform rotation_about_z; 736 gfx::Transform rotation_about_z;
737 rotation_about_z.Translate(50.0, 50.0); 737 rotation_about_z.Translate(50.0, 50.0);
738 rotation_about_z.RotateAboutZAxis(30.0); 738 rotation_about_z.RotateAboutZAxis(30.0);
739 rotation_about_z.Translate(-50.0, -50.0); 739 rotation_about_z.Translate(-50.0, -50.0);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 } 831 }
832 832
833 TEST_F(LayerPositionConstraintTest, 833 TEST_F(LayerPositionConstraintTest,
834 ScrollCompensationForFixedPositionLayerWithContainerLayerThatHasSurface) { 834 ScrollCompensationForFixedPositionLayerWithContainerLayerThatHasSurface) {
835 // This test checks for correct scroll compensation when the fixed-position 835 // This test checks for correct scroll compensation when the fixed-position
836 // container itself has a render surface. In this case, the container layer 836 // container itself has a render surface. In this case, the container layer
837 // should be treated like a layer that contributes to a render target, and 837 // should be treated like a layer that contributes to a render target, and
838 // that render target is completely irrelevant; it should not affect the 838 // that render target is completely irrelevant; it should not affect the
839 // scroll compensation. 839 // scroll compensation.
840 child_->SetIsContainerForFixedPositionLayers(true); 840 child_->SetIsContainerForFixedPositionLayers(true);
841 child_->SetForceRenderSurfaceForTesting(true); 841 child_->SetForceRenderSurface(true);
842 grand_child_->SetPositionConstraint(fixed_to_top_left_); 842 grand_child_->SetPositionConstraint(fixed_to_top_left_);
843 843
844 CommitAndUpdateImplPointers(); 844 CommitAndUpdateImplPointers();
845 845
846 // Case 1: scroll delta of 0, 0 846 // Case 1: scroll delta of 0, 0
847 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); 847 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0));
848 ExecuteCalculateDrawProperties(root_impl_); 848 ExecuteCalculateDrawProperties(root_impl_);
849 849
850 gfx::Transform expected_surface_draw_transform; 850 gfx::Transform expected_surface_draw_transform;
851 gfx::Transform expected_child_transform; 851 gfx::Transform expected_child_transform;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 expected_fixed_child_transform.Translate(20.0, 20.0); 1150 expected_fixed_child_transform.Translate(20.0, 20.0);
1151 1151
1152 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, 1152 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform,
1153 scroll_layer_impl_->DrawTransform()); 1153 scroll_layer_impl_->DrawTransform());
1154 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, 1154 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform,
1155 fixed_child_impl->DrawTransform()); 1155 fixed_child_impl->DrawTransform());
1156 } 1156 }
1157 1157
1158 } // namespace 1158 } // namespace
1159 } // namespace cc 1159 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698