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

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

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Created 3 years, 7 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 } 426 }
427 427
428 TEST_F(LayerPositionConstraintTest, 428 TEST_F(LayerPositionConstraintTest,
429 ScrollCompensationForFixedPositionWithIntermediateSurfaceAndTransforms) { 429 ScrollCompensationForFixedPositionWithIntermediateSurfaceAndTransforms) {
430 // This test checks for correct scroll compensation when the fixed-position 430 // This test checks for correct scroll compensation when the fixed-position
431 // container contributes to a different render surface than the fixed-position 431 // container contributes to a different render surface than the fixed-position
432 // layer. In this case, the surface draw transforms also have to be accounted 432 // layer. In this case, the surface draw transforms also have to be accounted
433 // for when checking the scroll delta. 433 // for when checking the scroll delta.
434 child_->SetIsContainerForFixedPositionLayers(true); 434 child_->SetIsContainerForFixedPositionLayers(true);
435 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); 435 grand_child_->SetPosition(gfx::PointF(8.f, 6.f));
436 grand_child_->SetForceRenderSurfaceForTesting(true); 436 grand_child_->SetForceRenderSurface(true);
437 great_grand_child_->SetPositionConstraint(fixed_to_top_left_); 437 great_grand_child_->SetPositionConstraint(fixed_to_top_left_);
438 438
439 gfx::Transform rotation_about_z; 439 gfx::Transform rotation_about_z;
440 rotation_about_z.RotateAboutZAxis(90.0); 440 rotation_about_z.RotateAboutZAxis(90.0);
441 great_grand_child_->SetTransform(rotation_about_z); 441 great_grand_child_->SetTransform(rotation_about_z);
442 442
443 CommitAndUpdateImplPointers(); 443 CommitAndUpdateImplPointers();
444 444
445 // Case 1: scroll delta of 0, 0 445 // Case 1: scroll delta of 0, 0
446 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); 446 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0));
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 scoped_refptr<Layer> fixed_position_child = 552 scoped_refptr<Layer> fixed_position_child =
553 make_scoped_refptr(new LayerWithForcedDrawsContent()); 553 make_scoped_refptr(new LayerWithForcedDrawsContent());
554 SetLayerPropertiesForTesting(fixed_position_child.get(), gfx::Transform(), 554 SetLayerPropertiesForTesting(fixed_position_child.get(), gfx::Transform(),
555 gfx::Point3F(), gfx::PointF(), 555 gfx::Point3F(), gfx::PointF(),
556 gfx::Size(100, 100), true); 556 gfx::Size(100, 100), true);
557 great_grand_child_->AddChild(fixed_position_child); 557 great_grand_child_->AddChild(fixed_position_child);
558 558
559 // Actually set up the scenario here. 559 // Actually set up the scenario here.
560 child_->SetIsContainerForFixedPositionLayers(true); 560 child_->SetIsContainerForFixedPositionLayers(true);
561 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); 561 grand_child_->SetPosition(gfx::PointF(8.f, 6.f));
562 grand_child_->SetForceRenderSurfaceForTesting(true); 562 grand_child_->SetForceRenderSurface(true);
563 great_grand_child_->SetPosition(gfx::PointF(40.f, 60.f)); 563 great_grand_child_->SetPosition(gfx::PointF(40.f, 60.f));
564 great_grand_child_->SetForceRenderSurfaceForTesting(true); 564 great_grand_child_->SetForceRenderSurface(true);
565 fixed_position_child->SetPositionConstraint(fixed_to_top_left_); 565 fixed_position_child->SetPositionConstraint(fixed_to_top_left_);
566 566
567 // The additional rotation, which is non-commutative with translations, helps 567 // The additional rotation, which is non-commutative with translations, helps
568 // to verify that we have correct order-of-operations in the final scroll 568 // to verify that we have correct order-of-operations in the final scroll
569 // compensation. Note that rotating about the center of the layer ensures we 569 // compensation. Note that rotating about the center of the layer ensures we
570 // do not accidentally clip away layers that we want to test. 570 // do not accidentally clip away layers that we want to test.
571 gfx::Transform rotation_about_z; 571 gfx::Transform rotation_about_z;
572 rotation_about_z.Translate(50.0, 50.0); 572 rotation_about_z.Translate(50.0, 50.0);
573 rotation_about_z.RotateAboutZAxis(90.0); 573 rotation_about_z.RotateAboutZAxis(90.0);
574 rotation_about_z.Translate(-50.0, -50.0); 574 rotation_about_z.Translate(-50.0, -50.0);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 scoped_refptr<Layer> fixed_position_child = 712 scoped_refptr<Layer> fixed_position_child =
713 make_scoped_refptr(new LayerWithForcedDrawsContent()); 713 make_scoped_refptr(new LayerWithForcedDrawsContent());
714 SetLayerPropertiesForTesting(fixed_position_child.get(), gfx::Transform(), 714 SetLayerPropertiesForTesting(fixed_position_child.get(), gfx::Transform(),
715 gfx::Point3F(), gfx::PointF(), 715 gfx::Point3F(), gfx::PointF(),
716 gfx::Size(100, 100), true); 716 gfx::Size(100, 100), true);
717 great_grand_child_->AddChild(fixed_position_child); 717 great_grand_child_->AddChild(fixed_position_child);
718 718
719 // Actually set up the scenario here. 719 // Actually set up the scenario here.
720 child_transform_layer_->SetIsContainerForFixedPositionLayers(true); 720 child_transform_layer_->SetIsContainerForFixedPositionLayers(true);
721 grand_child_->SetPosition(gfx::PointF(8.f, 6.f)); 721 grand_child_->SetPosition(gfx::PointF(8.f, 6.f));
722 grand_child_->SetForceRenderSurfaceForTesting(true); 722 grand_child_->SetForceRenderSurface(true);
723 great_grand_child_->SetPosition(gfx::PointF(40.f, 60.f)); 723 great_grand_child_->SetPosition(gfx::PointF(40.f, 60.f));
724 great_grand_child_->SetForceRenderSurfaceForTesting(true); 724 great_grand_child_->SetForceRenderSurface(true);
725 fixed_position_child->SetPositionConstraint(fixed_to_top_left_); 725 fixed_position_child->SetPositionConstraint(fixed_to_top_left_);
726 726
727 // The additional rotations, which are non-commutative with translations, help 727 // The additional rotations, which are non-commutative with translations, help
728 // to verify that we have correct order-of-operations in the final scroll 728 // to verify that we have correct order-of-operations in the final scroll
729 // compensation. Note that rotating about the center of the layer ensures we 729 // compensation. Note that rotating about the center of the layer ensures we
730 // do not accidentally clip away layers that we want to test. 730 // do not accidentally clip away layers that we want to test.
731 gfx::Transform rotation_about_z; 731 gfx::Transform rotation_about_z;
732 rotation_about_z.Translate(50.0, 50.0); 732 rotation_about_z.Translate(50.0, 50.0);
733 rotation_about_z.RotateAboutZAxis(30.0); 733 rotation_about_z.RotateAboutZAxis(30.0);
734 rotation_about_z.Translate(-50.0, -50.0); 734 rotation_about_z.Translate(-50.0, -50.0);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 } 826 }
827 827
828 TEST_F(LayerPositionConstraintTest, 828 TEST_F(LayerPositionConstraintTest,
829 ScrollCompensationForFixedPositionLayerWithContainerLayerThatHasSurface) { 829 ScrollCompensationForFixedPositionLayerWithContainerLayerThatHasSurface) {
830 // This test checks for correct scroll compensation when the fixed-position 830 // This test checks for correct scroll compensation when the fixed-position
831 // container itself has a render surface. In this case, the container layer 831 // container itself has a render surface. In this case, the container layer
832 // should be treated like a layer that contributes to a render target, and 832 // should be treated like a layer that contributes to a render target, and
833 // that render target is completely irrelevant; it should not affect the 833 // that render target is completely irrelevant; it should not affect the
834 // scroll compensation. 834 // scroll compensation.
835 child_->SetIsContainerForFixedPositionLayers(true); 835 child_->SetIsContainerForFixedPositionLayers(true);
836 child_->SetForceRenderSurfaceForTesting(true); 836 child_->SetForceRenderSurface(true);
837 grand_child_->SetPositionConstraint(fixed_to_top_left_); 837 grand_child_->SetPositionConstraint(fixed_to_top_left_);
838 838
839 CommitAndUpdateImplPointers(); 839 CommitAndUpdateImplPointers();
840 840
841 // Case 1: scroll delta of 0, 0 841 // Case 1: scroll delta of 0, 0
842 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0)); 842 SetScrollOffsetDelta(child_impl_, gfx::Vector2d(0, 0));
843 ExecuteCalculateDrawProperties(root_impl_); 843 ExecuteCalculateDrawProperties(root_impl_);
844 844
845 gfx::Transform expected_surface_draw_transform; 845 gfx::Transform expected_surface_draw_transform;
846 gfx::Transform expected_child_transform; 846 gfx::Transform expected_child_transform;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 expected_fixed_child_transform.Translate(20.0, 20.0); 1145 expected_fixed_child_transform.Translate(20.0, 20.0);
1146 1146
1147 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform, 1147 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_scroll_layer_transform,
1148 scroll_layer_impl_->DrawTransform()); 1148 scroll_layer_impl_->DrawTransform());
1149 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform, 1149 EXPECT_TRANSFORMATION_MATRIX_EQ(expected_fixed_child_transform,
1150 fixed_child_impl->DrawTransform()); 1150 fixed_child_impl->DrawTransform());
1151 } 1151 }
1152 1152
1153 } // namespace 1153 } // namespace
1154 } // namespace cc 1154 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | cc/layers/layer_unittest.cc » ('j') | cc/output/direct_renderer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698