OLD | NEW |
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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 #include "cc/layers/content_layer.h" | |
7 #include "cc/layers/solid_color_layer.h" | 6 #include "cc/layers/solid_color_layer.h" |
8 #include "cc/layers/texture_layer.h" | 7 #include "cc/layers/texture_layer.h" |
9 #include "cc/output/copy_output_request.h" | 8 #include "cc/output/copy_output_request.h" |
10 #include "cc/output/copy_output_result.h" | 9 #include "cc/output/copy_output_result.h" |
| 10 #include "cc/test/fake_picture_layer.h" |
| 11 #include "cc/test/fake_picture_layer_impl.h" |
11 #include "cc/test/layer_tree_pixel_test.h" | 12 #include "cc/test/layer_tree_pixel_test.h" |
12 #include "cc/test/paths.h" | 13 #include "cc/test/paths.h" |
13 #include "cc/test/solid_color_content_layer_client.h" | 14 #include "cc/test/solid_color_content_layer_client.h" |
14 #include "cc/trees/layer_tree_impl.h" | 15 #include "cc/trees/layer_tree_impl.h" |
15 | 16 |
16 #if !defined(OS_ANDROID) | 17 #if !defined(OS_ANDROID) |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 namespace { | 20 namespace { |
20 | 21 |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 } | 926 } |
926 | 927 |
927 virtual void SetupTree() OVERRIDE { | 928 virtual void SetupTree() OVERRIDE { |
928 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); | 929 layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_); |
929 LayerTreePixelTest::SetupTree(); | 930 LayerTreePixelTest::SetupTree(); |
930 } | 931 } |
931 | 932 |
932 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { | 933 virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
933 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); | 934 LayerImpl* root_impl = host_impl->active_tree()->root_layer(); |
934 | 935 |
935 LayerImpl* background_impl = root_impl->children()[0]; | 936 FakePictureLayerImpl* background_impl = |
936 EXPECT_EQ(device_scale_factor_, background_impl->contents_scale_x()); | 937 static_cast<FakePictureLayerImpl*>(root_impl->children()[0]); |
937 EXPECT_EQ(device_scale_factor_, background_impl->contents_scale_y()); | 938 EXPECT_EQ(device_scale_factor_, |
| 939 background_impl->HighResTiling()->contents_scale()); |
938 | 940 |
939 LayerImpl* green_impl = background_impl->children()[0]; | 941 FakePictureLayerImpl* green_impl = |
940 EXPECT_EQ(device_scale_factor_, green_impl->contents_scale_x()); | 942 static_cast<FakePictureLayerImpl*>(background_impl->children()[0]); |
941 EXPECT_EQ(device_scale_factor_, green_impl->contents_scale_y()); | 943 EXPECT_EQ(device_scale_factor_, |
| 944 green_impl->HighResTiling()->contents_scale()); |
942 | 945 |
943 LayerImpl* blue_impl = green_impl->children()[0]; | 946 FakePictureLayerImpl* blue_impl = |
944 EXPECT_EQ(device_scale_factor_, blue_impl->contents_scale_x()); | 947 static_cast<FakePictureLayerImpl*>(green_impl->children()[0]); |
945 EXPECT_EQ(device_scale_factor_, blue_impl->contents_scale_y()); | 948 EXPECT_EQ(device_scale_factor_, |
| 949 blue_impl->HighResTiling()->contents_scale()); |
946 } | 950 } |
947 | 951 |
948 float device_scale_factor_; | 952 float device_scale_factor_; |
949 SolidColorContentLayerClient white_client_; | 953 SolidColorContentLayerClient white_client_; |
950 SolidColorContentLayerClient green_client_; | 954 SolidColorContentLayerClient green_client_; |
951 SolidColorContentLayerClient blue_client_; | 955 SolidColorContentLayerClient blue_client_; |
952 }; | 956 }; |
953 | 957 |
954 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 958 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, |
955 ReadbackSubrect_Software) { | 959 ReadbackSubrect_Software) { |
956 scoped_refptr<ContentLayer> background = ContentLayer::Create(&white_client_); | 960 scoped_refptr<FakePictureLayer> background = |
| 961 FakePictureLayer::Create(&white_client_); |
957 background->SetBounds(gfx::Size(100, 100)); | 962 background->SetBounds(gfx::Size(100, 100)); |
958 background->SetIsDrawable(true); | 963 background->SetIsDrawable(true); |
959 | 964 |
960 scoped_refptr<ContentLayer> green = ContentLayer::Create(&green_client_); | 965 scoped_refptr<FakePictureLayer> green = |
| 966 FakePictureLayer::Create(&green_client_); |
961 green->SetBounds(gfx::Size(100, 100)); | 967 green->SetBounds(gfx::Size(100, 100)); |
962 green->SetIsDrawable(true); | 968 green->SetIsDrawable(true); |
963 background->AddChild(green); | 969 background->AddChild(green); |
964 | 970 |
965 scoped_refptr<ContentLayer> blue = ContentLayer::Create(&blue_client_); | 971 scoped_refptr<FakePictureLayer> blue = |
| 972 FakePictureLayer::Create(&blue_client_); |
966 blue->SetPosition(gfx::Point(50, 50)); | 973 blue->SetPosition(gfx::Point(50, 50)); |
967 blue->SetBounds(gfx::Size(25, 25)); | 974 blue->SetBounds(gfx::Size(25, 25)); |
968 blue->SetIsDrawable(true); | 975 blue->SetIsDrawable(true); |
969 green->AddChild(blue); | 976 green->AddChild(blue); |
970 | 977 |
971 // Grab the middle of the root layer. | 978 // Grab the middle of the root layer. |
972 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 979 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
973 device_scale_factor_ = 2.f; | 980 device_scale_factor_ = 2.f; |
974 | |
975 this->impl_side_painting_ = false; | |
976 RunPixelTest(SOFTWARE_WITH_DEFAULT, | 981 RunPixelTest(SOFTWARE_WITH_DEFAULT, |
977 background, | 982 background, |
978 base::FilePath(FILE_PATH_LITERAL( | 983 base::FilePath(FILE_PATH_LITERAL( |
979 "green_small_with_blue_corner.png"))); | 984 "green_small_with_blue_corner.png"))); |
980 } | 985 } |
981 | 986 |
982 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 987 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, |
983 ReadbackSubrect_GL) { | 988 ReadbackSubrect_GL) { |
984 scoped_refptr<ContentLayer> background = ContentLayer::Create(&white_client_); | 989 scoped_refptr<FakePictureLayer> background = |
| 990 FakePictureLayer::Create(&white_client_); |
985 background->SetBounds(gfx::Size(100, 100)); | 991 background->SetBounds(gfx::Size(100, 100)); |
986 background->SetIsDrawable(true); | 992 background->SetIsDrawable(true); |
987 | 993 |
988 scoped_refptr<ContentLayer> green = ContentLayer::Create(&green_client_); | 994 scoped_refptr<FakePictureLayer> green = |
| 995 FakePictureLayer::Create(&green_client_); |
989 green->SetBounds(gfx::Size(100, 100)); | 996 green->SetBounds(gfx::Size(100, 100)); |
990 green->SetIsDrawable(true); | 997 green->SetIsDrawable(true); |
991 background->AddChild(green); | 998 background->AddChild(green); |
992 | 999 |
993 scoped_refptr<ContentLayer> blue = ContentLayer::Create(&blue_client_); | 1000 scoped_refptr<FakePictureLayer> blue = |
| 1001 FakePictureLayer::Create(&blue_client_); |
994 blue->SetPosition(gfx::Point(50, 50)); | 1002 blue->SetPosition(gfx::Point(50, 50)); |
995 blue->SetBounds(gfx::Size(25, 25)); | 1003 blue->SetBounds(gfx::Size(25, 25)); |
996 blue->SetIsDrawable(true); | 1004 blue->SetIsDrawable(true); |
997 green->AddChild(blue); | 1005 green->AddChild(blue); |
998 | 1006 |
999 // Grab the middle of the root layer. | 1007 // Grab the middle of the root layer. |
1000 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 1008 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
1001 device_scale_factor_ = 2.f; | 1009 device_scale_factor_ = 2.f; |
1002 | |
1003 this->impl_side_painting_ = false; | |
1004 RunPixelTest(GL_WITH_DEFAULT, | 1010 RunPixelTest(GL_WITH_DEFAULT, |
1005 background, | 1011 background, |
1006 base::FilePath(FILE_PATH_LITERAL( | 1012 base::FilePath(FILE_PATH_LITERAL( |
1007 "green_small_with_blue_corner.png"))); | 1013 "green_small_with_blue_corner.png"))); |
1008 } | 1014 } |
1009 | 1015 |
1010 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 1016 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, |
1011 ReadbackNonRootLayerSubrect_Software) { | 1017 ReadbackNonRootLayerSubrect_Software) { |
1012 scoped_refptr<ContentLayer> background = ContentLayer::Create(&white_client_); | 1018 scoped_refptr<FakePictureLayer> background = |
| 1019 FakePictureLayer::Create(&white_client_); |
1013 background->SetBounds(gfx::Size(100, 100)); | 1020 background->SetBounds(gfx::Size(100, 100)); |
1014 background->SetIsDrawable(true); | 1021 background->SetIsDrawable(true); |
1015 | 1022 |
1016 scoped_refptr<ContentLayer> green = ContentLayer::Create(&green_client_); | 1023 scoped_refptr<FakePictureLayer> green = |
| 1024 FakePictureLayer::Create(&green_client_); |
1017 green->SetPosition(gfx::Point(10, 20)); | 1025 green->SetPosition(gfx::Point(10, 20)); |
1018 green->SetBounds(gfx::Size(90, 80)); | 1026 green->SetBounds(gfx::Size(90, 80)); |
1019 green->SetIsDrawable(true); | 1027 green->SetIsDrawable(true); |
1020 background->AddChild(green); | 1028 background->AddChild(green); |
1021 | 1029 |
1022 scoped_refptr<ContentLayer> blue = ContentLayer::Create(&blue_client_); | 1030 scoped_refptr<FakePictureLayer> blue = |
| 1031 FakePictureLayer::Create(&blue_client_); |
1023 blue->SetPosition(gfx::Point(50, 50)); | 1032 blue->SetPosition(gfx::Point(50, 50)); |
1024 blue->SetBounds(gfx::Size(25, 25)); | 1033 blue->SetBounds(gfx::Size(25, 25)); |
1025 blue->SetIsDrawable(true); | 1034 blue->SetIsDrawable(true); |
1026 green->AddChild(blue); | 1035 green->AddChild(blue); |
1027 | 1036 |
1028 // Grab the green layer's content with blue in the bottom right. | 1037 // Grab the green layer's content with blue in the bottom right. |
1029 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 1038 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
1030 device_scale_factor_ = 2.f; | 1039 device_scale_factor_ = 2.f; |
1031 | |
1032 this->impl_side_painting_ = false; | |
1033 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, | 1040 RunPixelTestWithReadbackTarget(SOFTWARE_WITH_DEFAULT, |
1034 background, | 1041 background, |
1035 green.get(), | 1042 green.get(), |
1036 base::FilePath(FILE_PATH_LITERAL( | 1043 base::FilePath(FILE_PATH_LITERAL( |
1037 "green_small_with_blue_corner.png"))); | 1044 "green_small_with_blue_corner.png"))); |
1038 } | 1045 } |
1039 | 1046 |
1040 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, | 1047 TEST_F(LayerTreeHostReadbackDeviceScalePixelTest, |
1041 ReadbackNonRootLayerSubrect_GL) { | 1048 ReadbackNonRootLayerSubrect_GL) { |
1042 scoped_refptr<ContentLayer> background = ContentLayer::Create(&white_client_); | 1049 scoped_refptr<FakePictureLayer> background = |
| 1050 FakePictureLayer::Create(&white_client_); |
1043 background->SetBounds(gfx::Size(100, 100)); | 1051 background->SetBounds(gfx::Size(100, 100)); |
1044 background->SetIsDrawable(true); | 1052 background->SetIsDrawable(true); |
1045 | 1053 |
1046 scoped_refptr<ContentLayer> green = ContentLayer::Create(&green_client_); | 1054 scoped_refptr<FakePictureLayer> green = |
| 1055 FakePictureLayer::Create(&green_client_); |
1047 green->SetPosition(gfx::Point(10, 20)); | 1056 green->SetPosition(gfx::Point(10, 20)); |
1048 green->SetBounds(gfx::Size(90, 80)); | 1057 green->SetBounds(gfx::Size(90, 80)); |
1049 green->SetIsDrawable(true); | 1058 green->SetIsDrawable(true); |
1050 background->AddChild(green); | 1059 background->AddChild(green); |
1051 | 1060 |
1052 scoped_refptr<ContentLayer> blue = ContentLayer::Create(&blue_client_); | 1061 scoped_refptr<FakePictureLayer> blue = |
| 1062 FakePictureLayer::Create(&blue_client_); |
1053 blue->SetPosition(gfx::Point(50, 50)); | 1063 blue->SetPosition(gfx::Point(50, 50)); |
1054 blue->SetBounds(gfx::Size(25, 25)); | 1064 blue->SetBounds(gfx::Size(25, 25)); |
1055 blue->SetIsDrawable(true); | 1065 blue->SetIsDrawable(true); |
1056 green->AddChild(blue); | 1066 green->AddChild(blue); |
1057 | 1067 |
1058 // Grab the green layer's content with blue in the bottom right. | 1068 // Grab the green layer's content with blue in the bottom right. |
1059 copy_subrect_ = gfx::Rect(25, 25, 50, 50); | 1069 copy_subrect_ = gfx::Rect(25, 25, 50, 50); |
1060 device_scale_factor_ = 2.f; | 1070 device_scale_factor_ = 2.f; |
1061 | |
1062 this->impl_side_painting_ = false; | |
1063 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, | 1071 RunPixelTestWithReadbackTarget(GL_WITH_DEFAULT, |
1064 background, | 1072 background, |
1065 green.get(), | 1073 green.get(), |
1066 base::FilePath(FILE_PATH_LITERAL( | 1074 base::FilePath(FILE_PATH_LITERAL( |
1067 "green_small_with_blue_corner.png"))); | 1075 "green_small_with_blue_corner.png"))); |
1068 } | 1076 } |
1069 | 1077 |
1070 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { | 1078 TEST_F(LayerTreeHostReadbackPixelTest, ReadbackNonRootLayerOutsideViewport) { |
1071 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( | 1079 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( |
1072 gfx::Rect(200, 200), SK_ColorWHITE); | 1080 gfx::Rect(200, 200), SK_ColorWHITE); |
(...skipping 13 matching lines...) Expand all Loading... |
1086 background, | 1094 background, |
1087 green.get(), | 1095 green.get(), |
1088 base::FilePath(FILE_PATH_LITERAL( | 1096 base::FilePath(FILE_PATH_LITERAL( |
1089 "green_with_blue_corner.png"))); | 1097 "green_with_blue_corner.png"))); |
1090 } | 1098 } |
1091 | 1099 |
1092 } // namespace | 1100 } // namespace |
1093 } // namespace cc | 1101 } // namespace cc |
1094 | 1102 |
1095 #endif // OS_ANDROID | 1103 #endif // OS_ANDROID |
OLD | NEW |