| 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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 EXPECT_TRUE(surface->HasActiveFrame()); | 791 EXPECT_TRUE(surface->HasActiveFrame()); |
| 792 EXPECT_FALSE(surface->HasPendingFrame()); | 792 EXPECT_FALSE(surface->HasPendingFrame()); |
| 793 | 793 |
| 794 // Verify that the new surface has both latency info elements. | 794 // Verify that the new surface has both latency info elements. |
| 795 std::vector<ui::LatencyInfo> info_list; | 795 std::vector<ui::LatencyInfo> info_list; |
| 796 surface->TakeLatencyInfo(&info_list); | 796 surface->TakeLatencyInfo(&info_list); |
| 797 EXPECT_EQ(2u, info_list.size()); | 797 EXPECT_EQ(2u, info_list.size()); |
| 798 | 798 |
| 799 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 799 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
| 800 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 800 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
| 801 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 801 |
| 802 // Two components are the original ones, and the third one is |
| 803 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 804 // submit. |
| 805 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
| 802 | 806 |
| 803 ui::LatencyInfo::LatencyComponent comp1; | 807 ui::LatencyInfo::LatencyComponent comp1; |
| 804 EXPECT_TRUE( | 808 EXPECT_TRUE( |
| 805 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 809 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 806 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 810 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 811 EXPECT_TRUE( |
| 812 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 813 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 814 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 807 } | 815 } |
| 808 | 816 |
| 809 // Checks whether the latency info are moved to the new surface from the old | 817 // Checks whether the latency info are moved to the new surface from the old |
| 810 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. | 818 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. |
| 811 TEST_F(CompositorFrameSinkSupportTest, | 819 TEST_F(CompositorFrameSinkSupportTest, |
| 812 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { | 820 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { |
| 813 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 821 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 814 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 822 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 815 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 823 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 816 | 824 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 EXPECT_FALSE(surface->HasPendingFrame()); | 867 EXPECT_FALSE(surface->HasPendingFrame()); |
| 860 | 868 |
| 861 // Verify that the new surface has latency info from both active and pending | 869 // Verify that the new surface has latency info from both active and pending |
| 862 // frame of the old surface. | 870 // frame of the old surface. |
| 863 std::vector<ui::LatencyInfo> info_list; | 871 std::vector<ui::LatencyInfo> info_list; |
| 864 surface->TakeLatencyInfo(&info_list); | 872 surface->TakeLatencyInfo(&info_list); |
| 865 EXPECT_EQ(2u, info_list.size()); | 873 EXPECT_EQ(2u, info_list.size()); |
| 866 | 874 |
| 867 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 875 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
| 868 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 876 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
| 869 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 877 |
| 878 // Two components are the original ones, and the third one is |
| 879 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 880 // submit. |
| 881 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
| 870 | 882 |
| 871 ui::LatencyInfo::LatencyComponent comp1; | 883 ui::LatencyInfo::LatencyComponent comp1; |
| 872 EXPECT_TRUE( | 884 EXPECT_TRUE( |
| 873 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 885 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 874 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 886 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 887 EXPECT_TRUE( |
| 888 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 889 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 890 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 875 } | 891 } |
| 876 | 892 |
| 877 // Checks whether the latency info are moved to the new surface from the old | 893 // Checks whether the latency info are moved to the new surface from the old |
| 878 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. | 894 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. |
| 879 TEST_F(CompositorFrameSinkSupportTest, | 895 TEST_F(CompositorFrameSinkSupportTest, |
| 880 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { | 896 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { |
| 881 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 897 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 882 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 898 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 883 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 899 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 884 | 900 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 EXPECT_TRUE(surface->HasActiveFrame()); | 946 EXPECT_TRUE(surface->HasActiveFrame()); |
| 931 | 947 |
| 932 // Both latency info elements must exist in the now-activated frame of the | 948 // Both latency info elements must exist in the now-activated frame of the |
| 933 // new surface. | 949 // new surface. |
| 934 std::vector<ui::LatencyInfo> info_list; | 950 std::vector<ui::LatencyInfo> info_list; |
| 935 surface->TakeLatencyInfo(&info_list); | 951 surface->TakeLatencyInfo(&info_list); |
| 936 EXPECT_EQ(2u, info_list.size()); | 952 EXPECT_EQ(2u, info_list.size()); |
| 937 | 953 |
| 938 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 954 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
| 939 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 955 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
| 940 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 956 |
| 957 // Two components are the original ones, and the third one is |
| 958 // DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, logged on compositor frame |
| 959 // submit. |
| 960 EXPECT_EQ(3u, aggregated_latency_info.latency_components().size()); |
| 941 | 961 |
| 942 ui::LatencyInfo::LatencyComponent comp1; | 962 ui::LatencyInfo::LatencyComponent comp1; |
| 943 EXPECT_TRUE( | 963 EXPECT_TRUE( |
| 944 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 964 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 945 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 965 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 966 EXPECT_TRUE( |
| 967 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 968 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 969 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 946 } | 970 } |
| 947 | 971 |
| 948 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { | 972 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { |
| 949 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 973 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
| 950 | 974 |
| 951 // Request BeginFrames. | 975 // Request BeginFrames. |
| 952 display_support().SetNeedsBeginFrame(true); | 976 display_support().SetNeedsBeginFrame(true); |
| 953 | 977 |
| 954 // Issue a BeginFrame. | 978 // Issue a BeginFrame. |
| 955 BeginFrameArgs args = | 979 BeginFrameArgs args = |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 // scheduling a deadline and without waiting for dependencies to resolve. | 1270 // scheduling a deadline and without waiting for dependencies to resolve. |
| 1247 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 1271 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), |
| 1248 MakeCompositorFrame({child_id1})); | 1272 MakeCompositorFrame({child_id1})); |
| 1249 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1273 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 1250 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1274 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 1251 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 1275 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 1252 } | 1276 } |
| 1253 | 1277 |
| 1254 } // namespace test | 1278 } // namespace test |
| 1255 } // namespace cc | 1279 } // namespace cc |
| OLD | NEW |