OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
6 | 6 |
7 #include "base/debug/stack_trace.h" | 7 #include "base/debug/stack_trace.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "cc/output/compositor_frame.h" | 9 #include "cc/output/compositor_frame.h" |
10 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 10 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
819 EXPECT_TRUE(surface->HasActiveFrame()); | 819 EXPECT_TRUE(surface->HasActiveFrame()); |
820 EXPECT_FALSE(surface->HasPendingFrame()); | 820 EXPECT_FALSE(surface->HasPendingFrame()); |
821 | 821 |
822 // Verify that the new surface has both latency info elements. | 822 // Verify that the new surface has both latency info elements. |
823 std::vector<ui::LatencyInfo> info_list; | 823 std::vector<ui::LatencyInfo> info_list; |
824 surface->TakeLatencyInfo(&info_list); | 824 surface->TakeLatencyInfo(&info_list); |
825 EXPECT_EQ(2u, info_list.size()); | 825 EXPECT_EQ(2u, info_list.size()); |
826 | 826 |
827 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 827 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
828 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 828 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
829 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 829 |
| 830 // Two components are the original ones, and the third one is |
| 831 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 832 // submit. |
| 833 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
830 | 834 |
831 ui::LatencyInfo::LatencyComponent comp1; | 835 ui::LatencyInfo::LatencyComponent comp1; |
832 EXPECT_TRUE( | 836 EXPECT_TRUE( |
833 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 837 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
834 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 838 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 839 EXPECT_TRUE( |
| 840 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 841 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 842 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
835 } | 843 } |
836 | 844 |
837 // Checks whether the latency info are moved to the new surface from the old | 845 // Checks whether the latency info are moved to the new surface from the old |
838 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. | 846 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. |
839 TEST_F(CompositorFrameSinkSupportTest, | 847 TEST_F(CompositorFrameSinkSupportTest, |
840 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { | 848 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { |
841 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 849 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
842 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 850 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
843 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 851 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
844 | 852 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 EXPECT_FALSE(surface->HasPendingFrame()); | 895 EXPECT_FALSE(surface->HasPendingFrame()); |
888 | 896 |
889 // Verify that the new surface has latency info from both active and pending | 897 // Verify that the new surface has latency info from both active and pending |
890 // frame of the old surface. | 898 // frame of the old surface. |
891 std::vector<ui::LatencyInfo> info_list; | 899 std::vector<ui::LatencyInfo> info_list; |
892 surface->TakeLatencyInfo(&info_list); | 900 surface->TakeLatencyInfo(&info_list); |
893 EXPECT_EQ(2u, info_list.size()); | 901 EXPECT_EQ(2u, info_list.size()); |
894 | 902 |
895 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 903 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
896 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 904 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
897 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 905 |
| 906 // Two components are the original ones, and the third one is |
| 907 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 908 // submit. |
| 909 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
898 | 910 |
899 ui::LatencyInfo::LatencyComponent comp1; | 911 ui::LatencyInfo::LatencyComponent comp1; |
900 EXPECT_TRUE( | 912 EXPECT_TRUE( |
901 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 913 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
902 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 914 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 915 EXPECT_TRUE( |
| 916 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 917 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 918 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
903 } | 919 } |
904 | 920 |
905 // Checks whether the latency info are moved to the new surface from the old | 921 // Checks whether the latency info are moved to the new surface from the old |
906 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. | 922 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. |
907 TEST_F(CompositorFrameSinkSupportTest, | 923 TEST_F(CompositorFrameSinkSupportTest, |
908 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { | 924 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { |
909 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 925 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
910 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 926 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
911 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 927 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
912 | 928 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 EXPECT_TRUE(surface->HasActiveFrame()); | 974 EXPECT_TRUE(surface->HasActiveFrame()); |
959 | 975 |
960 // Both latency info elements must exist in the now-activated frame of the | 976 // Both latency info elements must exist in the now-activated frame of the |
961 // new surface. | 977 // new surface. |
962 std::vector<ui::LatencyInfo> info_list; | 978 std::vector<ui::LatencyInfo> info_list; |
963 surface->TakeLatencyInfo(&info_list); | 979 surface->TakeLatencyInfo(&info_list); |
964 EXPECT_EQ(2u, info_list.size()); | 980 EXPECT_EQ(2u, info_list.size()); |
965 | 981 |
966 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 982 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
967 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 983 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
968 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 984 |
| 985 // Two components are the original ones, and the third one is |
| 986 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 987 // submit. |
| 988 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
969 | 989 |
970 ui::LatencyInfo::LatencyComponent comp1; | 990 ui::LatencyInfo::LatencyComponent comp1; |
971 EXPECT_TRUE( | 991 EXPECT_TRUE( |
972 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 992 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
973 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 993 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 994 EXPECT_TRUE( |
| 995 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 996 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 997 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
974 } | 998 } |
975 | 999 |
976 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { | 1000 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { |
977 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 1001 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
978 | 1002 |
979 // Request BeginFrames. | 1003 // Request BeginFrames. |
980 display_support().SetNeedsBeginFrame(true); | 1004 display_support().SetNeedsBeginFrame(true); |
981 | 1005 |
982 // Issue a BeginFrame. | 1006 // Issue a BeginFrame. |
983 BeginFrameArgs args = | 1007 BeginFrameArgs args = |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1261 EXPECT_FALSE(dependency_tracker().has_deadline()); |
1238 EXPECT_FALSE(display_surface()->HasPendingFrame()); | 1262 EXPECT_FALSE(display_surface()->HasPendingFrame()); |
1239 EXPECT_TRUE(display_surface()->HasActiveFrame()); | 1263 EXPECT_TRUE(display_surface()->HasActiveFrame()); |
1240 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty()); | 1264 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty()); |
1241 EXPECT_THAT(GetChildReferences(display_id), | 1265 EXPECT_THAT(GetChildReferences(display_id), |
1242 UnorderedElementsAre(parent_id1, parent_id2)); | 1266 UnorderedElementsAre(parent_id1, parent_id2)); |
1243 } | 1267 } |
1244 | 1268 |
1245 } // namespace test | 1269 } // namespace test |
1246 } // namespace cc | 1270 } // namespace cc |
OLD | NEW |