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

Side by Side Diff: cc/layer_tree_host_common_unittest.cc

Issue 11366089: cc: Remove all remaining use of WebCore Rect/Point/Size types from the compositor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove gyp entries for stubs Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | cc/layer_tree_host_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "config.h" 5 #include "config.h"
6 6
7 #include "cc/layer_tree_host_common.h" 7 #include "cc/layer_tree_host_common.h"
8 8
9 #include "cc/content_layer.h" 9 #include "cc/content_layer.h"
10 #include "cc/content_layer_client.h" 10 #include "cc/content_layer_client.h"
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 794
795 DebugScopedSetImplThread scopedImplThread; 795 DebugScopedSetImplThread scopedImplThread;
796 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 796 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
797 LayerImpl* child = root->children()[0]; 797 LayerImpl* child = root->children()[0];
798 LayerImpl* grandChild = child->children()[0]; 798 LayerImpl* grandChild = child->children()[0];
799 799
800 child->setIsContainerForFixedPositionLayers(true); 800 child->setIsContainerForFixedPositionLayers(true);
801 grandChild->setFixedToContainerLayer(true); 801 grandChild->setFixedToContainerLayer(true);
802 802
803 // Case 1: scrollDelta of 0, 0 803 // Case 1: scrollDelta of 0, 0
804 child->setScrollDelta(IntSize(0, 0)); 804 child->setScrollDelta(gfx::Vector2d(0, 0));
805 executeCalculateDrawTransformsAndVisibility(root.get()); 805 executeCalculateDrawTransformsAndVisibility(root.get());
806 806
807 WebTransformationMatrix expectedChildTransform; 807 WebTransformationMatrix expectedChildTransform;
808 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform ; 808 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform ;
809 809
810 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 810 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
811 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 811 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
812 812
813 // Case 2: scrollDelta of 10, 10 813 // Case 2: scrollDelta of 10, 10
814 child->setScrollDelta(IntSize(10, 10)); 814 child->setScrollDelta(gfx::Vector2d(10, 10));
815 executeCalculateDrawTransformsAndVisibility(root.get()); 815 executeCalculateDrawTransformsAndVisibility(root.get());
816 816
817 // Here the child is affected by scrollDelta, but the fixed position grandCh ild should not be affected. 817 // Here the child is affected by scrollDelta, but the fixed position grandCh ild should not be affected.
818 expectedChildTransform.makeIdentity(); 818 expectedChildTransform.makeIdentity();
819 expectedChildTransform.translate(-10, -10); 819 expectedChildTransform.translate(-10, -10);
820 820
821 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 821 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
822 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 822 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
823 } 823 }
824 824
(...skipping 15 matching lines...) Expand all
840 840
841 // This scale will cause child and grandChild to be effectively 200 x 800 wi th respect to the renderTarget. 841 // This scale will cause child and grandChild to be effectively 200 x 800 wi th respect to the renderTarget.
842 WebTransformationMatrix nonUniformScale; 842 WebTransformationMatrix nonUniformScale;
843 nonUniformScale.scaleNonUniform(2, 8); 843 nonUniformScale.scaleNonUniform(2, 8);
844 child->setTransform(nonUniformScale); 844 child->setTransform(nonUniformScale);
845 845
846 child->setIsContainerForFixedPositionLayers(true); 846 child->setIsContainerForFixedPositionLayers(true);
847 grandChild->setFixedToContainerLayer(true); 847 grandChild->setFixedToContainerLayer(true);
848 848
849 // Case 1: scrollDelta of 0, 0 849 // Case 1: scrollDelta of 0, 0
850 child->setScrollDelta(IntSize(0, 0)); 850 child->setScrollDelta(gfx::Vector2d(0, 0));
851 executeCalculateDrawTransformsAndVisibility(root.get()); 851 executeCalculateDrawTransformsAndVisibility(root.get());
852 852
853 WebTransformationMatrix expectedChildTransform; 853 WebTransformationMatrix expectedChildTransform;
854 expectedChildTransform.multiply(nonUniformScale); 854 expectedChildTransform.multiply(nonUniformScale);
855 855
856 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform ; 856 WebTransformationMatrix expectedGrandChildTransform = expectedChildTransform ;
857 857
858 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 858 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
859 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 859 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
860 860
861 // Case 2: scrollDelta of 10, 20 861 // Case 2: scrollDelta of 10, 20
862 child->setScrollDelta(IntSize(10, 20)); 862 child->setScrollDelta(gfx::Vector2d(10, 20));
863 executeCalculateDrawTransformsAndVisibility(root.get()); 863 executeCalculateDrawTransformsAndVisibility(root.get());
864 864
865 // The child should be affected by scrollDelta, but the fixed position grand Child should not be affected. 865 // The child should be affected by scrollDelta, but the fixed position grand Child should not be affected.
866 expectedChildTransform.makeIdentity(); 866 expectedChildTransform.makeIdentity();
867 expectedChildTransform.translate(-10, -20); // scrollDelta 867 expectedChildTransform.translate(-10, -20); // scrollDelta
868 expectedChildTransform.multiply(nonUniformScale); 868 expectedChildTransform.multiply(nonUniformScale);
869 869
870 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 870 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
871 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 871 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
872 } 872 }
873 873
874 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainer) 874 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWithD istantContainer)
875 { 875 {
876 // This test checks for correct scroll compensation when the fixed-position container 876 // This test checks for correct scroll compensation when the fixed-position container
877 // is NOT the direct parent of the fixed-position layer. 877 // is NOT the direct parent of the fixed-position layer.
878 DebugScopedSetImplThread scopedImplThread; 878 DebugScopedSetImplThread scopedImplThread;
879 879
880 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 880 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
881 LayerImpl* child = root->children()[0]; 881 LayerImpl* child = root->children()[0];
882 LayerImpl* grandChild = child->children()[0]; 882 LayerImpl* grandChild = child->children()[0];
883 LayerImpl* greatGrandChild = grandChild->children()[0]; 883 LayerImpl* greatGrandChild = grandChild->children()[0];
884 884
885 child->setIsContainerForFixedPositionLayers(true); 885 child->setIsContainerForFixedPositionLayers(true);
886 grandChild->setPosition(gfx::PointF(8, 6)); 886 grandChild->setPosition(gfx::PointF(8, 6));
887 greatGrandChild->setFixedToContainerLayer(true); 887 greatGrandChild->setFixedToContainerLayer(true);
888 888
889 // Case 1: scrollDelta of 0, 0 889 // Case 1: scrollDelta of 0, 0
890 child->setScrollDelta(IntSize(0, 0)); 890 child->setScrollDelta(gfx::Vector2d(0, 0));
891 executeCalculateDrawTransformsAndVisibility(root.get()); 891 executeCalculateDrawTransformsAndVisibility(root.get());
892 892
893 WebTransformationMatrix expectedChildTransform; 893 WebTransformationMatrix expectedChildTransform;
894 WebTransformationMatrix expectedGrandChildTransform; 894 WebTransformationMatrix expectedGrandChildTransform;
895 expectedGrandChildTransform.translate(8, 6); 895 expectedGrandChildTransform.translate(8, 6);
896 896
897 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform; 897 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform;
898 898
899 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 899 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
900 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 900 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
901 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 901 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
902 902
903 // Case 2: scrollDelta of 10, 10 903 // Case 2: scrollDelta of 10, 10
904 child->setScrollDelta(IntSize(10, 10)); 904 child->setScrollDelta(gfx::Vector2d(10, 10));
905 executeCalculateDrawTransformsAndVisibility(root.get()); 905 executeCalculateDrawTransformsAndVisibility(root.get());
906 906
907 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. 907 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
908 expectedChildTransform.makeIdentity(); 908 expectedChildTransform.makeIdentity();
909 expectedChildTransform.translate(-10, -10); 909 expectedChildTransform.translate(-10, -10);
910 expectedGrandChildTransform.makeIdentity(); 910 expectedGrandChildTransform.makeIdentity();
911 expectedGrandChildTransform.translate(-2, -4); 911 expectedGrandChildTransform.translate(-2, -4);
912 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 912 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
913 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 913 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
914 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 914 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
(...skipping 14 matching lines...) Expand all
929 WebTransformationMatrix rotationAboutZ; 929 WebTransformationMatrix rotationAboutZ;
930 rotationAboutZ.rotate3d(0, 0, 90); 930 rotationAboutZ.rotate3d(0, 0, 90);
931 931
932 child->setIsContainerForFixedPositionLayers(true); 932 child->setIsContainerForFixedPositionLayers(true);
933 child->setTransform(rotationAboutZ); 933 child->setTransform(rotationAboutZ);
934 grandChild->setPosition(gfx::PointF(8, 6)); 934 grandChild->setPosition(gfx::PointF(8, 6));
935 grandChild->setTransform(rotationAboutZ); 935 grandChild->setTransform(rotationAboutZ);
936 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit ioned upside-down with respect to the renderTarget. 936 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit ioned upside-down with respect to the renderTarget.
937 937
938 // Case 1: scrollDelta of 0, 0 938 // Case 1: scrollDelta of 0, 0
939 child->setScrollDelta(IntSize(0, 0)); 939 child->setScrollDelta(gfx::Vector2d(0, 0));
940 executeCalculateDrawTransformsAndVisibility(root.get()); 940 executeCalculateDrawTransformsAndVisibility(root.get());
941 941
942 WebTransformationMatrix expectedChildTransform; 942 WebTransformationMatrix expectedChildTransform;
943 expectedChildTransform.multiply(rotationAboutZ); 943 expectedChildTransform.multiply(rotationAboutZ);
944 944
945 WebTransformationMatrix expectedGrandChildTransform; 945 WebTransformationMatrix expectedGrandChildTransform;
946 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited 946 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited
947 expectedGrandChildTransform.translate(8, 6); // translation because of posit ion occurs before layer's local transform. 947 expectedGrandChildTransform.translate(8, 6); // translation because of posit ion occurs before layer's local transform.
948 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform 948 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
949 949
950 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform; 950 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform;
951 951
952 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 952 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
953 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 953 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
954 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 954 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
955 955
956 // Case 2: scrollDelta of 10, 20 956 // Case 2: scrollDelta of 10, 20
957 child->setScrollDelta(IntSize(10, 20)); 957 child->setScrollDelta(gfx::Vector2d(10, 20));
958 executeCalculateDrawTransformsAndVisibility(root.get()); 958 executeCalculateDrawTransformsAndVisibility(root.get());
959 959
960 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. 960 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
961 expectedChildTransform.makeIdentity(); 961 expectedChildTransform.makeIdentity();
962 expectedChildTransform.translate(-10, -20); // scrollDelta 962 expectedChildTransform.translate(-10, -20); // scrollDelta
963 expectedChildTransform.multiply(rotationAboutZ); 963 expectedChildTransform.multiply(rotationAboutZ);
964 964
965 expectedGrandChildTransform.makeIdentity(); 965 expectedGrandChildTransform.makeIdentity();
966 expectedGrandChildTransform.translate(-10, -20); // child's scrollDelta is i nherited 966 expectedGrandChildTransform.translate(-10, -20); // child's scrollDelta is i nherited
967 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited 967 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited
(...skipping 23 matching lines...) Expand all
991 WebTransformationMatrix rotationAboutZ; 991 WebTransformationMatrix rotationAboutZ;
992 rotationAboutZ.rotate3d(0, 0, 90); 992 rotationAboutZ.rotate3d(0, 0, 90);
993 993
994 child->setIsContainerForFixedPositionLayers(true); 994 child->setIsContainerForFixedPositionLayers(true);
995 child->setTransform(rotationAboutZ); 995 child->setTransform(rotationAboutZ);
996 grandChild->setPosition(gfx::PointF(8, 6)); 996 grandChild->setPosition(gfx::PointF(8, 6));
997 grandChild->setTransform(rotationAboutZ); 997 grandChild->setTransform(rotationAboutZ);
998 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit ioned upside-down with respect to the renderTarget. 998 greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is posit ioned upside-down with respect to the renderTarget.
999 999
1000 // Case 1: scrollDelta of 0, 0 1000 // Case 1: scrollDelta of 0, 0
1001 child->setScrollDelta(IntSize(0, 0)); 1001 child->setScrollDelta(gfx::Vector2d(0, 0));
1002 executeCalculateDrawTransformsAndVisibility(root.get()); 1002 executeCalculateDrawTransformsAndVisibility(root.get());
1003 1003
1004 WebTransformationMatrix expectedChildTransform; 1004 WebTransformationMatrix expectedChildTransform;
1005 expectedChildTransform.multiply(rotationAboutZ); 1005 expectedChildTransform.multiply(rotationAboutZ);
1006 1006
1007 WebTransformationMatrix expectedGrandChildTransform; 1007 WebTransformationMatrix expectedGrandChildTransform;
1008 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited 1008 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited
1009 expectedGrandChildTransform.translate(8, 6); // translation because of posit ion occurs before layer's local transform. 1009 expectedGrandChildTransform.translate(8, 6); // translation because of posit ion occurs before layer's local transform.
1010 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform 1010 expectedGrandChildTransform.multiply(rotationAboutZ); // grandChild's local transform
1011 1011
1012 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform; 1012 WebTransformationMatrix expectedGreatGrandChildTransform = expectedGrandChil dTransform;
1013 1013
1014 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 1014 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
1015 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1015 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1016 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 1016 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
1017 1017
1018 // Case 2: scrollDelta of 10, 20 1018 // Case 2: scrollDelta of 10, 20
1019 child->setScrollDelta(IntSize(10, 0)); 1019 child->setScrollDelta(gfx::Vector2d(10, 0));
1020 grandChild->setScrollDelta(IntSize(5, 0)); 1020 grandChild->setScrollDelta(gfx::Vector2d(5, 0));
1021 executeCalculateDrawTransformsAndVisibility(root.get()); 1021 executeCalculateDrawTransformsAndVisibility(root.get());
1022 1022
1023 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected. 1023 // Here the child and grandChild are affected by scrollDelta, but the fixed position greatGrandChild should not be affected.
1024 expectedChildTransform.makeIdentity(); 1024 expectedChildTransform.makeIdentity();
1025 expectedChildTransform.translate(-10, 0); // scrollDelta 1025 expectedChildTransform.translate(-10, 0); // scrollDelta
1026 expectedChildTransform.multiply(rotationAboutZ); 1026 expectedChildTransform.multiply(rotationAboutZ);
1027 1027
1028 expectedGrandChildTransform.makeIdentity(); 1028 expectedGrandChildTransform.makeIdentity();
1029 expectedGrandChildTransform.translate(-10, 0); // child's scrollDelta is inh erited 1029 expectedGrandChildTransform.translate(-10, 0); // child's scrollDelta is inh erited
1030 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited 1030 expectedGrandChildTransform.multiply(rotationAboutZ); // child's local trans form is inherited
(...skipping 23 matching lines...) Expand all
1054 grandChild->setPosition(gfx::PointF(8, 6)); 1054 grandChild->setPosition(gfx::PointF(8, 6));
1055 grandChild->setForceRenderSurface(true); 1055 grandChild->setForceRenderSurface(true);
1056 greatGrandChild->setFixedToContainerLayer(true); 1056 greatGrandChild->setFixedToContainerLayer(true);
1057 greatGrandChild->setDrawsContent(true); 1057 greatGrandChild->setDrawsContent(true);
1058 1058
1059 WebTransformationMatrix rotationAboutZ; 1059 WebTransformationMatrix rotationAboutZ;
1060 rotationAboutZ.rotate3d(0, 0, 90); 1060 rotationAboutZ.rotate3d(0, 0, 90);
1061 grandChild->setTransform(rotationAboutZ); 1061 grandChild->setTransform(rotationAboutZ);
1062 1062
1063 // Case 1: scrollDelta of 0, 0 1063 // Case 1: scrollDelta of 0, 0
1064 child->setScrollDelta(IntSize(0, 0)); 1064 child->setScrollDelta(gfx::Vector2d(0, 0));
1065 executeCalculateDrawTransformsAndVisibility(root.get()); 1065 executeCalculateDrawTransformsAndVisibility(root.get());
1066 1066
1067 WebTransformationMatrix expectedChildTransform; 1067 WebTransformationMatrix expectedChildTransform;
1068 WebTransformationMatrix expectedSurfaceDrawTransform; 1068 WebTransformationMatrix expectedSurfaceDrawTransform;
1069 expectedSurfaceDrawTransform.translate(8, 6); 1069 expectedSurfaceDrawTransform.translate(8, 6);
1070 expectedSurfaceDrawTransform.multiply(rotationAboutZ); 1070 expectedSurfaceDrawTransform.multiply(rotationAboutZ);
1071 WebTransformationMatrix expectedGrandChildTransform; 1071 WebTransformationMatrix expectedGrandChildTransform;
1072 WebTransformationMatrix expectedGreatGrandChildTransform; 1072 WebTransformationMatrix expectedGreatGrandChildTransform;
1073 ASSERT_TRUE(grandChild->renderSurface()); 1073 ASSERT_TRUE(grandChild->renderSurface());
1074 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 1074 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
1075 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re nderSurface()->drawTransform()); 1075 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, grandChild->re nderSurface()->drawTransform());
1076 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1076 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1077 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 1077 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
1078 1078
1079 // Case 2: scrollDelta of 10, 30 1079 // Case 2: scrollDelta of 10, 30
1080 child->setScrollDelta(IntSize(10, 30)); 1080 child->setScrollDelta(gfx::Vector2d(10, 30));
1081 executeCalculateDrawTransformsAndVisibility(root.get()); 1081 executeCalculateDrawTransformsAndVisibility(root.get());
1082 1082
1083 // Here the grandChild remains unchanged, because it scrolls along with the 1083 // Here the grandChild remains unchanged, because it scrolls along with the
1084 // renderSurface, and the translation is actually in the renderSurface. But, the fixed 1084 // renderSurface, and the translation is actually in the renderSurface. But, the fixed
1085 // position greatGrandChild is more awkward: its actually being drawn with r espect to 1085 // position greatGrandChild is more awkward: its actually being drawn with r espect to
1086 // the renderSurface, but it needs to remain fixed with resepct to a contain er beyond 1086 // the renderSurface, but it needs to remain fixed with resepct to a contain er beyond
1087 // that surface. So, the net result is that, unlike previous tests where the fixed 1087 // that surface. So, the net result is that, unlike previous tests where the fixed
1088 // position layer's transform remains unchanged, here the fixed position lay er's 1088 // position layer's transform remains unchanged, here the fixed position lay er's
1089 // transform explicitly contains the translation that cancels out the scroll . 1089 // transform explicitly contains the translation that cancels out the scroll .
1090 expectedChildTransform.makeIdentity(); 1090 expectedChildTransform.makeIdentity();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 // Note that rotating about the center of the layer ensures we do not accide ntally 1146 // Note that rotating about the center of the layer ensures we do not accide ntally
1147 // clip away layers that we want to test. 1147 // clip away layers that we want to test.
1148 WebTransformationMatrix rotationAboutZ; 1148 WebTransformationMatrix rotationAboutZ;
1149 rotationAboutZ.translate(50, 50); 1149 rotationAboutZ.translate(50, 50);
1150 rotationAboutZ.rotate3d(0, 0, 90); 1150 rotationAboutZ.rotate3d(0, 0, 90);
1151 rotationAboutZ.translate(-50, -50); 1151 rotationAboutZ.translate(-50, -50);
1152 grandChild->setTransform(rotationAboutZ); 1152 grandChild->setTransform(rotationAboutZ);
1153 greatGrandChild->setTransform(rotationAboutZ); 1153 greatGrandChild->setTransform(rotationAboutZ);
1154 1154
1155 // Case 1: scrollDelta of 0, 0 1155 // Case 1: scrollDelta of 0, 0
1156 child->setScrollDelta(IntSize(0, 0)); 1156 child->setScrollDelta(gfx::Vector2d(0, 0));
1157 executeCalculateDrawTransformsAndVisibility(root.get()); 1157 executeCalculateDrawTransformsAndVisibility(root.get());
1158 1158
1159 WebTransformationMatrix expectedChildTransform; 1159 WebTransformationMatrix expectedChildTransform;
1160 1160
1161 WebTransformationMatrix expectedGrandChildSurfaceDrawTransform; 1161 WebTransformationMatrix expectedGrandChildSurfaceDrawTransform;
1162 expectedGrandChildSurfaceDrawTransform.translate(8, 6); 1162 expectedGrandChildSurfaceDrawTransform.translate(8, 6);
1163 expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); 1163 expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ);
1164 1164
1165 WebTransformationMatrix expectedGrandChildTransform; 1165 WebTransformationMatrix expectedGrandChildTransform;
1166 1166
1167 WebTransformationMatrix expectedGreatGrandChildSurfaceDrawTransform; 1167 WebTransformationMatrix expectedGreatGrandChildSurfaceDrawTransform;
1168 expectedGreatGrandChildSurfaceDrawTransform.translate(40, 60); 1168 expectedGreatGrandChildSurfaceDrawTransform.translate(40, 60);
1169 expectedGreatGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); 1169 expectedGreatGrandChildSurfaceDrawTransform.multiply(rotationAboutZ);
1170 1170
1171 WebTransformationMatrix expectedGreatGrandChildTransform; 1171 WebTransformationMatrix expectedGreatGrandChildTransform;
1172 1172
1173 WebTransformationMatrix expectedFixedPositionChildTransform; 1173 WebTransformationMatrix expectedFixedPositionChildTransform;
1174 1174
1175 ASSERT_TRUE(grandChild->renderSurface()); 1175 ASSERT_TRUE(grandChild->renderSurface());
1176 ASSERT_TRUE(greatGrandChild->renderSurface()); 1176 ASSERT_TRUE(greatGrandChild->renderSurface());
1177 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 1177 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
1178 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran dChild->renderSurface()->drawTransform()); 1178 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildSurfaceDrawTransform, gran dChild->renderSurface()->drawTransform());
1179 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1179 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1180 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform, greatGrandChild->renderSurface()->drawTransform()); 1180 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildSurfaceDrawTransform, greatGrandChild->renderSurface()->drawTransform());
1181 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform()); 1181 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGreatGrandChildTransform, greatGrand Child->drawTransform());
1182 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo sitionChild->drawTransform()); 1182 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedFixedPositionChildTransform, fixedPo sitionChild->drawTransform());
1183 1183
1184 // Case 2: scrollDelta of 10, 30 1184 // Case 2: scrollDelta of 10, 30
1185 child->setScrollDelta(IntSize(10, 30)); 1185 child->setScrollDelta(gfx::Vector2d(10, 30));
1186 executeCalculateDrawTransformsAndVisibility(root.get()); 1186 executeCalculateDrawTransformsAndVisibility(root.get());
1187 1187
1188 expectedChildTransform.makeIdentity(); 1188 expectedChildTransform.makeIdentity();
1189 expectedChildTransform.translate(-10, -30); // scrollDelta 1189 expectedChildTransform.translate(-10, -30); // scrollDelta
1190 1190
1191 expectedGrandChildSurfaceDrawTransform.makeIdentity(); 1191 expectedGrandChildSurfaceDrawTransform.makeIdentity();
1192 expectedGrandChildSurfaceDrawTransform.translate(-10, -30); // scrollDelta 1192 expectedGrandChildSurfaceDrawTransform.translate(-10, -30); // scrollDelta
1193 expectedGrandChildSurfaceDrawTransform.translate(8, 6); 1193 expectedGrandChildSurfaceDrawTransform.translate(8, 6);
1194 expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ); 1194 expectedGrandChildSurfaceDrawTransform.multiply(rotationAboutZ);
1195 1195
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 1232 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
1233 LayerImpl* child = root->children()[0]; 1233 LayerImpl* child = root->children()[0];
1234 LayerImpl* grandChild = child->children()[0]; 1234 LayerImpl* grandChild = child->children()[0];
1235 1235
1236 child->setIsContainerForFixedPositionLayers(true); 1236 child->setIsContainerForFixedPositionLayers(true);
1237 child->setForceRenderSurface(true); 1237 child->setForceRenderSurface(true);
1238 grandChild->setFixedToContainerLayer(true); 1238 grandChild->setFixedToContainerLayer(true);
1239 grandChild->setDrawsContent(true); 1239 grandChild->setDrawsContent(true);
1240 1240
1241 // Case 1: scrollDelta of 0, 0 1241 // Case 1: scrollDelta of 0, 0
1242 child->setScrollDelta(IntSize(0, 0)); 1242 child->setScrollDelta(gfx::Vector2d(0, 0));
1243 executeCalculateDrawTransformsAndVisibility(root.get()); 1243 executeCalculateDrawTransformsAndVisibility(root.get());
1244 1244
1245 WebTransformationMatrix expectedSurfaceDrawTransform; 1245 WebTransformationMatrix expectedSurfaceDrawTransform;
1246 expectedSurfaceDrawTransform.translate(0, 0); 1246 expectedSurfaceDrawTransform.translate(0, 0);
1247 WebTransformationMatrix expectedChildTransform; 1247 WebTransformationMatrix expectedChildTransform;
1248 WebTransformationMatrix expectedGrandChildTransform; 1248 WebTransformationMatrix expectedGrandChildTransform;
1249 ASSERT_TRUE(child->renderSurface()); 1249 ASSERT_TRUE(child->renderSurface());
1250 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform()); 1250 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedSurfaceDrawTransform, child->renderS urface()->drawTransform());
1251 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 1251 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
1252 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1252 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1253 1253
1254 // Case 2: scrollDelta of 10, 10 1254 // Case 2: scrollDelta of 10, 10
1255 child->setScrollDelta(IntSize(10, 10)); 1255 child->setScrollDelta(gfx::Vector2d(10, 10));
1256 executeCalculateDrawTransformsAndVisibility(root.get()); 1256 executeCalculateDrawTransformsAndVisibility(root.get());
1257 1257
1258 // The surface is translated by scrollDelta, the child transform doesn't cha nge 1258 // The surface is translated by scrollDelta, the child transform doesn't cha nge
1259 // because it scrolls along with the surface, but the fixed position grandCh ild 1259 // because it scrolls along with the surface, but the fixed position grandCh ild
1260 // needs to compensate for the scroll translation. 1260 // needs to compensate for the scroll translation.
1261 expectedSurfaceDrawTransform.makeIdentity(); 1261 expectedSurfaceDrawTransform.makeIdentity();
1262 expectedSurfaceDrawTransform.translate(-10, -10); 1262 expectedSurfaceDrawTransform.translate(-10, -10);
1263 expectedGrandChildTransform.makeIdentity(); 1263 expectedGrandChildTransform.makeIdentity();
1264 expectedGrandChildTransform.translate(10, 10); 1264 expectedGrandChildTransform.translate(10, 10);
1265 1265
(...skipping 14 matching lines...) Expand all
1280 LayerImpl* child = root->children()[0]; 1280 LayerImpl* child = root->children()[0];
1281 LayerImpl* grandChild = child->children()[0]; 1281 LayerImpl* grandChild = child->children()[0];
1282 1282
1283 child->setIsContainerForFixedPositionLayers(true); 1283 child->setIsContainerForFixedPositionLayers(true);
1284 grandChild->setFixedToContainerLayer(true); 1284 grandChild->setFixedToContainerLayer(true);
1285 1285
1286 // This should not confuse the grandChild. If correct, the grandChild would still be considered fixed to its container (i.e. "child"). 1286 // This should not confuse the grandChild. If correct, the grandChild would still be considered fixed to its container (i.e. "child").
1287 grandChild->setIsContainerForFixedPositionLayers(true); 1287 grandChild->setIsContainerForFixedPositionLayers(true);
1288 1288
1289 // Case 1: scrollDelta of 0, 0 1289 // Case 1: scrollDelta of 0, 0
1290 child->setScrollDelta(IntSize(0, 0)); 1290 child->setScrollDelta(gfx::Vector2d(0, 0));
1291 executeCalculateDrawTransformsAndVisibility(root.get()); 1291 executeCalculateDrawTransformsAndVisibility(root.get());
1292 1292
1293 WebTransformationMatrix expectedChildTransform; 1293 WebTransformationMatrix expectedChildTransform;
1294 WebTransformationMatrix expectedGrandChildTransform; 1294 WebTransformationMatrix expectedGrandChildTransform;
1295 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 1295 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
1296 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1296 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1297 1297
1298 // Case 2: scrollDelta of 10, 10 1298 // Case 2: scrollDelta of 10, 10
1299 child->setScrollDelta(IntSize(10, 10)); 1299 child->setScrollDelta(gfx::Vector2d(10, 10));
1300 executeCalculateDrawTransformsAndVisibility(root.get()); 1300 executeCalculateDrawTransformsAndVisibility(root.get());
1301 1301
1302 // Here the child is affected by scrollDelta, but the fixed position grandCh ild should not be affected. 1302 // Here the child is affected by scrollDelta, but the fixed position grandCh ild should not be affected.
1303 expectedChildTransform.makeIdentity(); 1303 expectedChildTransform.makeIdentity();
1304 expectedChildTransform.translate(-10, -10); 1304 expectedChildTransform.translate(-10, -10);
1305 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ()); 1305 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedChildTransform, child->drawTransform ());
1306 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform()); 1306 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedGrandChildTransform, grandChild->dra wTransform());
1307 } 1307 }
1308 1308
1309 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH asNoContainer) 1309 TEST(LayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerThatH asNoContainer)
1310 { 1310 {
1311 // This test checks scroll compensation when a fixed-position layer does not find any 1311 // This test checks scroll compensation when a fixed-position layer does not find any
1312 // ancestor that is a "containerForFixedPositionLayers". In this situation, the layer should 1312 // ancestor that is a "containerForFixedPositionLayers". In this situation, the layer should
1313 // be fixed to the viewport -- not the rootLayer, which may have transforms of its own. 1313 // be fixed to the viewport -- not the rootLayer, which may have transforms of its own.
1314 DebugScopedSetImplThread scopedImplThread; 1314 DebugScopedSetImplThread scopedImplThread;
1315 1315
1316 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests(); 1316 scoped_ptr<LayerImpl> root = createTreeForFixedPositionTests();
1317 LayerImpl* child = root->children()[0]; 1317 LayerImpl* child = root->children()[0];
1318 LayerImpl* grandChild = child->children()[0]; 1318 LayerImpl* grandChild = child->children()[0];
1319 1319
1320 WebTransformationMatrix rotationByZ; 1320 WebTransformationMatrix rotationByZ;
1321 rotationByZ.rotate3d(0, 0, 90); 1321 rotationByZ.rotate3d(0, 0, 90);
1322 1322
1323 root->setTransform(rotationByZ); 1323 root->setTransform(rotationByZ);
1324 grandChild->setFixedToContainerLayer(true); 1324 grandChild->setFixedToContainerLayer(true);
1325 1325
1326 // Case 1: root scrollDelta of 0, 0 1326 // Case 1: root scrollDelta of 0, 0
1327 root->setScrollDelta(IntSize(0, 0)); 1327 root->setScrollDelta(gfx::Vector2d(0, 0));
1328 executeCalculateDrawTransformsAndVisibility(root.get()); 1328 executeCalculateDrawTransformsAndVisibility(root.get());
1329 1329
1330 WebTransformationMatrix identityMatrix; 1330 WebTransformationMatrix identityMatrix;
1331 1331
1332 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform()); 1332 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, child->drawTransform());
1333 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ; 1333 EXPECT_TRANSFORMATION_MATRIX_EQ(identityMatrix, grandChild->drawTransform()) ;
1334 1334
1335 // Case 2: root scrollDelta of 10, 10 1335 // Case 2: root scrollDelta of 10, 10
1336 root->setScrollDelta(IntSize(10, 20)); 1336 root->setScrollDelta(gfx::Vector2d(10, 20));
1337 executeCalculateDrawTransformsAndVisibility(root.get()); 1337 executeCalculateDrawTransformsAndVisibility(root.get());
1338 1338
1339 // The child is affected by scrollDelta, but it is already implcitly account ed for by 1339 // The child is affected by scrollDelta, but it is already implcitly account ed for by
1340 // the child's target surface (i.e. the root renderSurface). The grandChild is not 1340 // the child's target surface (i.e. the root renderSurface). The grandChild is not
1341 // affected by the scrollDelta, so its drawTransform needs to explicitly 1341 // affected by the scrollDelta, so its drawTransform needs to explicitly
1342 // inverse-compensate for the scroll that's embedded in the target surface. 1342 // inverse-compensate for the scroll that's embedded in the target surface.
1343 WebTransformationMatrix expectedGrandChildTransform; 1343 WebTransformationMatrix expectedGrandChildTransform;
1344 expectedGrandChildTransform.multiply(rotationByZ.inverse()); 1344 expectedGrandChildTransform.multiply(rotationByZ.inverse());
1345 expectedGrandChildTransform.translate(10, 20); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface. 1345 expectedGrandChildTransform.translate(10, 20); // explicit canceling out the scrollDelta that gets embedded in the fixed position layer's surface.
1346 expectedGrandChildTransform.multiply(rotationByZ); 1346 expectedGrandChildTransform.multiply(rotationByZ);
(...skipping 2692 matching lines...) Expand 10 before | Expand all | Expand 10 after
4039 int nonexistentId = -1; 4039 int nonexistentId = -1;
4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ())); 4040 EXPECT_EQ(root, LayerTreeHostCommon::findLayerInSubtree(root.get(), root->id ()));
4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id())); 4041 EXPECT_EQ(child, LayerTreeHostCommon::findLayerInSubtree(root.get(), child-> id()));
4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id())); 4042 EXPECT_EQ(grandChild, LayerTreeHostCommon::findLayerInSubtree(root.get(), gr andChild->id()));
4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id())); 4043 EXPECT_EQ(maskLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), mas kLayer->id()));
4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id())); 4044 EXPECT_EQ(replicaLayer, LayerTreeHostCommon::findLayerInSubtree(root.get(), replicaLayer->id()));
4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id)); 4045 EXPECT_EQ(0, LayerTreeHostCommon::findLayerInSubtree(root.get(), nonexistent Id));
4046 } 4046 }
4047 4047
4048 } // namespace 4048 } // namespace
OLDNEW
« no previous file with comments | « cc/layer_tree_host_common.cc ('k') | cc/layer_tree_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698