| 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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 EXPECT_TRUE(surface->HasActiveFrame()); | 808 EXPECT_TRUE(surface->HasActiveFrame()); |
| 809 EXPECT_FALSE(surface->HasPendingFrame()); | 809 EXPECT_FALSE(surface->HasPendingFrame()); |
| 810 | 810 |
| 811 // Verify that the new surface has both latency info elements. | 811 // Verify that the new surface has both latency info elements. |
| 812 std::vector<ui::LatencyInfo> info_list; | 812 std::vector<ui::LatencyInfo> info_list; |
| 813 surface->TakeLatencyInfo(&info_list); | 813 surface->TakeLatencyInfo(&info_list); |
| 814 EXPECT_EQ(2u, info_list.size()); | 814 EXPECT_EQ(2u, info_list.size()); |
| 815 | 815 |
| 816 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 816 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
| 817 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 817 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
| 818 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 818 |
| 819 // Two components are the original ones, and the third one is |
| 820 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 821 // submit. |
| 822 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
| 819 | 823 |
| 820 ui::LatencyInfo::LatencyComponent comp1; | 824 ui::LatencyInfo::LatencyComponent comp1; |
| 821 EXPECT_TRUE( | 825 EXPECT_TRUE( |
| 822 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 826 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 823 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 827 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 828 EXPECT_TRUE( |
| 829 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 830 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 831 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 824 } | 832 } |
| 825 | 833 |
| 826 // Checks whether the latency info are moved to the new surface from the old | 834 // Checks whether the latency info are moved to the new surface from the old |
| 827 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. | 835 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. |
| 828 TEST_F(CompositorFrameSinkSupportTest, | 836 TEST_F(CompositorFrameSinkSupportTest, |
| 829 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { | 837 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { |
| 830 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 838 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 831 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 839 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 832 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 840 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 833 | 841 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 EXPECT_FALSE(surface->HasPendingFrame()); | 884 EXPECT_FALSE(surface->HasPendingFrame()); |
| 877 | 885 |
| 878 // Verify that the new surface has latency info from both active and pending | 886 // Verify that the new surface has latency info from both active and pending |
| 879 // frame of the old surface. | 887 // frame of the old surface. |
| 880 std::vector<ui::LatencyInfo> info_list; | 888 std::vector<ui::LatencyInfo> info_list; |
| 881 surface->TakeLatencyInfo(&info_list); | 889 surface->TakeLatencyInfo(&info_list); |
| 882 EXPECT_EQ(2u, info_list.size()); | 890 EXPECT_EQ(2u, info_list.size()); |
| 883 | 891 |
| 884 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 892 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
| 885 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 893 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
| 886 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 894 |
| 895 // Two components are the original ones, and the third one is |
| 896 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 897 // submit. |
| 898 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
| 887 | 899 |
| 888 ui::LatencyInfo::LatencyComponent comp1; | 900 ui::LatencyInfo::LatencyComponent comp1; |
| 889 EXPECT_TRUE( | 901 EXPECT_TRUE( |
| 890 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 902 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 891 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 903 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 904 EXPECT_TRUE( |
| 905 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 906 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 907 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 892 } | 908 } |
| 893 | 909 |
| 894 // Checks whether the latency info are moved to the new surface from the old | 910 // Checks whether the latency info are moved to the new surface from the old |
| 895 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. | 911 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. |
| 896 TEST_F(CompositorFrameSinkSupportTest, | 912 TEST_F(CompositorFrameSinkSupportTest, |
| 897 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { | 913 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { |
| 898 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 914 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 899 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 915 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 900 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 916 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 901 | 917 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 EXPECT_TRUE(surface->HasActiveFrame()); | 963 EXPECT_TRUE(surface->HasActiveFrame()); |
| 948 | 964 |
| 949 // Both latency info elements must exist in the now-activated frame of the | 965 // Both latency info elements must exist in the now-activated frame of the |
| 950 // new surface. | 966 // new surface. |
| 951 std::vector<ui::LatencyInfo> info_list; | 967 std::vector<ui::LatencyInfo> info_list; |
| 952 surface->TakeLatencyInfo(&info_list); | 968 surface->TakeLatencyInfo(&info_list); |
| 953 EXPECT_EQ(2u, info_list.size()); | 969 EXPECT_EQ(2u, info_list.size()); |
| 954 | 970 |
| 955 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 971 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
| 956 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 972 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
| 957 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 973 |
| 974 // Two components are the original ones, and the third one is |
| 975 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 976 // submit. |
| 977 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
| 958 | 978 |
| 959 ui::LatencyInfo::LatencyComponent comp1; | 979 ui::LatencyInfo::LatencyComponent comp1; |
| 960 EXPECT_TRUE( | 980 EXPECT_TRUE( |
| 961 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 981 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 962 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 982 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 983 EXPECT_TRUE( |
| 984 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 985 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 986 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 963 } | 987 } |
| 964 | 988 |
| 965 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { | 989 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { |
| 966 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 990 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
| 967 | 991 |
| 968 // Request BeginFrames. | 992 // Request BeginFrames. |
| 969 display_support().SetNeedsBeginFrame(true); | 993 display_support().SetNeedsBeginFrame(true); |
| 970 | 994 |
| 971 // Issue a BeginFrame. | 995 // Issue a BeginFrame. |
| 972 BeginFrameArgs args = | 996 BeginFrameArgs args = |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 for (int i = 0; i < 3; ++i) { | 1213 for (int i = 0; i < 3; ++i) { |
| 1190 begin_frame_source()->TestOnBeginFrame(args); | 1214 begin_frame_source()->TestOnBeginFrame(args); |
| 1191 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1215 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1192 } | 1216 } |
| 1193 begin_frame_source()->TestOnBeginFrame(args); | 1217 begin_frame_source()->TestOnBeginFrame(args); |
| 1194 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1218 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 1195 } | 1219 } |
| 1196 | 1220 |
| 1197 } // namespace test | 1221 } // namespace test |
| 1198 } // namespace cc | 1222 } // namespace cc |
| OLD | NEW |