| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 std::vector<SurfaceId> empty_surface_ids() { | 64 std::vector<SurfaceId> empty_surface_ids() { |
| 65 return std::vector<SurfaceId>(); | 65 return std::vector<SurfaceId>(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { | 68 SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { |
| 69 return SurfaceId( | 69 return SurfaceId( |
| 70 frame_sink_id, | 70 frame_sink_id, |
| 71 LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); | 71 LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); |
| 72 } | 72 } |
| 73 | 73 |
| 74 CompositorFrame MakeCompositorFrame() { |
| 75 CompositorFrame compositor_frame; |
| 76 compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, 0, true); |
| 77 return compositor_frame; |
| 78 } |
| 79 |
| 74 CompositorFrame MakeCompositorFrame( | 80 CompositorFrame MakeCompositorFrame( |
| 75 std::vector<SurfaceId> referenced_surfaces) { | 81 std::vector<SurfaceId> referenced_surfaces) { |
| 76 CompositorFrame compositor_frame; | 82 CompositorFrame compositor_frame; |
| 83 compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, 0, true); |
| 77 compositor_frame.metadata.referenced_surfaces = | 84 compositor_frame.metadata.referenced_surfaces = |
| 78 std::move(referenced_surfaces); | 85 std::move(referenced_surfaces); |
| 79 return compositor_frame; | 86 return compositor_frame; |
| 80 } | 87 } |
| 81 | 88 |
| 82 CompositorFrame MakeCompositorFrameWithResources( | 89 CompositorFrame MakeCompositorFrameWithResources( |
| 83 std::vector<SurfaceId> referenced_surfaces, | 90 std::vector<SurfaceId> referenced_surfaces, |
| 84 TransferableResourceArray resource_list) { | 91 TransferableResourceArray resource_list) { |
| 85 CompositorFrame compositor_frame; | 92 CompositorFrame compositor_frame; |
| 93 compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, 0, true); |
| 86 compositor_frame.metadata.referenced_surfaces = | 94 compositor_frame.metadata.referenced_surfaces = |
| 87 std::move(referenced_surfaces); | 95 std::move(referenced_surfaces); |
| 88 compositor_frame.resource_list = std::move(resource_list); | 96 compositor_frame.resource_list = std::move(resource_list); |
| 89 return compositor_frame; | 97 return compositor_frame; |
| 90 } | 98 } |
| 91 | 99 |
| 92 TransferableResource MakeResource(ResourceId id, | 100 TransferableResource MakeResource(ResourceId id, |
| 93 ResourceFormat format, | 101 ResourceFormat format, |
| 94 uint32_t filter, | 102 uint32_t filter, |
| 95 const gfx::Size& size) { | 103 const gfx::Size& size) { |
| (...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 const int64_t latency_id1 = 234; | 770 const int64_t latency_id1 = 234; |
| 763 const int64_t latency_sequence_number1 = 5645432; | 771 const int64_t latency_sequence_number1 = 5645432; |
| 764 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 772 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; |
| 765 const int64_t latency_id2 = 31434351; | 773 const int64_t latency_id2 = 31434351; |
| 766 const int64_t latency_sequence_number2 = 663788; | 774 const int64_t latency_sequence_number2 = 663788; |
| 767 | 775 |
| 768 // Submit a frame with latency info | 776 // Submit a frame with latency info |
| 769 ui::LatencyInfo info; | 777 ui::LatencyInfo info; |
| 770 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); | 778 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); |
| 771 | 779 |
| 772 CompositorFrame frame; | 780 CompositorFrame frame = MakeCompositorFrame(); |
| 773 frame.metadata.latency_info.push_back(info); | 781 frame.metadata.latency_info.push_back(info); |
| 774 | 782 |
| 775 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 783 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), |
| 776 std::move(frame)); | 784 std::move(frame)); |
| 777 | 785 |
| 778 // Verify that the old surface has an active frame and no pending frame. | 786 // Verify that the old surface has an active frame and no pending frame. |
| 779 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); | 787 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); |
| 780 ASSERT_NE(nullptr, old_surface); | 788 ASSERT_NE(nullptr, old_surface); |
| 781 EXPECT_TRUE(old_surface->HasActiveFrame()); | 789 EXPECT_TRUE(old_surface->HasActiveFrame()); |
| 782 EXPECT_FALSE(old_surface->HasPendingFrame()); | 790 EXPECT_FALSE(old_surface->HasPendingFrame()); |
| 783 | 791 |
| 784 // Submit another frame with some other latency info and a different | 792 // Submit another frame with some other latency info and a different |
| 785 // LocalSurfaceId. | 793 // LocalSurfaceId. |
| 786 ui::LatencyInfo info2; | 794 ui::LatencyInfo info2; |
| 787 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); | 795 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); |
| 788 | 796 |
| 789 CompositorFrame frame2; | 797 CompositorFrame frame2 = MakeCompositorFrame(); |
| 790 frame2.metadata.latency_info.push_back(info2); | 798 frame2.metadata.latency_info.push_back(info2); |
| 791 | 799 |
| 792 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), | 800 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), |
| 793 std::move(frame2)); | 801 std::move(frame2)); |
| 794 | 802 |
| 795 // Verify that the new surface has an active frame and no pending frames. | 803 // Verify that the new surface has an active frame and no pending frames. |
| 796 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); | 804 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); |
| 797 ASSERT_NE(nullptr, surface); | 805 ASSERT_NE(nullptr, surface); |
| 798 EXPECT_TRUE(surface->HasActiveFrame()); | 806 EXPECT_TRUE(surface->HasActiveFrame()); |
| 799 EXPECT_FALSE(surface->HasPendingFrame()); | 807 EXPECT_FALSE(surface->HasPendingFrame()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 826 const int64_t latency_id1 = 234; | 834 const int64_t latency_id1 = 234; |
| 827 const int64_t latency_sequence_number1 = 5645432; | 835 const int64_t latency_sequence_number1 = 5645432; |
| 828 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 836 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; |
| 829 const int64_t latency_id2 = 31434351; | 837 const int64_t latency_id2 = 31434351; |
| 830 const int64_t latency_sequence_number2 = 663788; | 838 const int64_t latency_sequence_number2 = 663788; |
| 831 | 839 |
| 832 // Submit a frame with no unresolved dependecy. | 840 // Submit a frame with no unresolved dependecy. |
| 833 ui::LatencyInfo info; | 841 ui::LatencyInfo info; |
| 834 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); | 842 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); |
| 835 | 843 |
| 836 CompositorFrame frame; | 844 CompositorFrame frame = MakeCompositorFrame(); |
| 837 frame.metadata.latency_info.push_back(info); | 845 frame.metadata.latency_info.push_back(info); |
| 838 | 846 |
| 839 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 847 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), |
| 840 std::move(frame)); | 848 std::move(frame)); |
| 841 | 849 |
| 842 // Submit a frame with unresolved dependencies. | 850 // Submit a frame with unresolved dependencies. |
| 843 ui::LatencyInfo info2; | 851 ui::LatencyInfo info2; |
| 844 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); | 852 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); |
| 845 | 853 |
| 846 CompositorFrame frame2 = MakeCompositorFrame({child_id}); | 854 CompositorFrame frame2 = MakeCompositorFrame({child_id}); |
| 847 frame2.metadata.latency_info.push_back(info2); | 855 frame2.metadata.latency_info.push_back(info2); |
| 848 | 856 |
| 849 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 857 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), |
| 850 std::move(frame2)); | 858 std::move(frame2)); |
| 851 | 859 |
| 852 // Verify that the old surface has both an active and a pending frame. | 860 // Verify that the old surface has both an active and a pending frame. |
| 853 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); | 861 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); |
| 854 ASSERT_NE(nullptr, old_surface); | 862 ASSERT_NE(nullptr, old_surface); |
| 855 EXPECT_TRUE(old_surface->HasActiveFrame()); | 863 EXPECT_TRUE(old_surface->HasActiveFrame()); |
| 856 EXPECT_TRUE(old_surface->HasPendingFrame()); | 864 EXPECT_TRUE(old_surface->HasPendingFrame()); |
| 857 | 865 |
| 858 // Submit a frame with a new local surface id. | 866 // Submit a frame with a new local surface id. |
| 859 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), | 867 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), |
| 860 CompositorFrame()); | 868 MakeCompositorFrame()); |
| 861 | 869 |
| 862 // Verify that the new surface has an active frame only. | 870 // Verify that the new surface has an active frame only. |
| 863 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); | 871 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); |
| 864 ASSERT_NE(nullptr, surface); | 872 ASSERT_NE(nullptr, surface); |
| 865 EXPECT_TRUE(surface->HasActiveFrame()); | 873 EXPECT_TRUE(surface->HasActiveFrame()); |
| 866 EXPECT_FALSE(surface->HasPendingFrame()); | 874 EXPECT_FALSE(surface->HasPendingFrame()); |
| 867 | 875 |
| 868 // Verify that the new surface has latency info from both active and pending | 876 // Verify that the new surface has latency info from both active and pending |
| 869 // frame of the old surface. | 877 // frame of the old surface. |
| 870 std::vector<ui::LatencyInfo> info_list; | 878 std::vector<ui::LatencyInfo> info_list; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 894 const int64_t latency_id1 = 234; | 902 const int64_t latency_id1 = 234; |
| 895 const int64_t latency_sequence_number1 = 5645432; | 903 const int64_t latency_sequence_number1 = 5645432; |
| 896 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 904 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; |
| 897 const int64_t latency_id2 = 31434351; | 905 const int64_t latency_id2 = 31434351; |
| 898 const int64_t latency_sequence_number2 = 663788; | 906 const int64_t latency_sequence_number2 = 663788; |
| 899 | 907 |
| 900 // Submit a frame with no unresolved dependencies. | 908 // Submit a frame with no unresolved dependencies. |
| 901 ui::LatencyInfo info; | 909 ui::LatencyInfo info; |
| 902 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); | 910 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); |
| 903 | 911 |
| 904 CompositorFrame frame; | 912 CompositorFrame frame = MakeCompositorFrame(); |
| 905 frame.metadata.latency_info.push_back(info); | 913 frame.metadata.latency_info.push_back(info); |
| 906 | 914 |
| 907 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 915 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), |
| 908 std::move(frame)); | 916 std::move(frame)); |
| 909 | 917 |
| 910 // Verify that the old surface has an active frame only. | 918 // Verify that the old surface has an active frame only. |
| 911 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); | 919 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); |
| 912 ASSERT_NE(nullptr, old_surface); | 920 ASSERT_NE(nullptr, old_surface); |
| 913 EXPECT_TRUE(old_surface->HasActiveFrame()); | 921 EXPECT_TRUE(old_surface->HasActiveFrame()); |
| 914 EXPECT_FALSE(old_surface->HasPendingFrame()); | 922 EXPECT_FALSE(old_surface->HasPendingFrame()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 925 std::move(frame2)); | 933 std::move(frame2)); |
| 926 | 934 |
| 927 // Verify that the new surface has a pending frame and no active frame. | 935 // Verify that the new surface has a pending frame and no active frame. |
| 928 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); | 936 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); |
| 929 ASSERT_NE(nullptr, surface); | 937 ASSERT_NE(nullptr, surface); |
| 930 EXPECT_TRUE(surface->HasPendingFrame()); | 938 EXPECT_TRUE(surface->HasPendingFrame()); |
| 931 EXPECT_FALSE(surface->HasActiveFrame()); | 939 EXPECT_FALSE(surface->HasActiveFrame()); |
| 932 | 940 |
| 933 // Resolve the dependencies. The frame in parent's surface must become active. | 941 // Resolve the dependencies. The frame in parent's surface must become active. |
| 934 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 942 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 935 CompositorFrame()); | 943 MakeCompositorFrame()); |
| 936 EXPECT_FALSE(surface->HasPendingFrame()); | 944 EXPECT_FALSE(surface->HasPendingFrame()); |
| 937 EXPECT_TRUE(surface->HasActiveFrame()); | 945 EXPECT_TRUE(surface->HasActiveFrame()); |
| 938 | 946 |
| 939 // Both latency info elements must exist in the now-activated frame of the | 947 // Both latency info elements must exist in the now-activated frame of the |
| 940 // new surface. | 948 // new surface. |
| 941 std::vector<ui::LatencyInfo> info_list; | 949 std::vector<ui::LatencyInfo> info_list; |
| 942 surface->TakeLatencyInfo(&info_list); | 950 surface->TakeLatencyInfo(&info_list); |
| 943 EXPECT_EQ(2u, info_list.size()); | 951 EXPECT_EQ(2u, info_list.size()); |
| 944 | 952 |
| 945 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 953 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
| 946 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 954 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
| 947 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 955 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); |
| 948 | 956 |
| 949 ui::LatencyInfo::LatencyComponent comp1; | 957 ui::LatencyInfo::LatencyComponent comp1; |
| 950 EXPECT_TRUE( | 958 EXPECT_TRUE( |
| 951 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 959 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 952 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 960 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 953 } | 961 } |
| 954 | 962 |
| 955 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { | 963 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { |
| 956 // Request BeginFrames. | 964 // Request BeginFrames. |
| 957 display_support().SetNeedsBeginFrame(true); | 965 display_support().SetNeedsBeginFrame(true); |
| 958 | 966 |
| 959 // Issue a BeginFrame. | 967 // Issue a BeginFrame. |
| 960 BeginFrameArgs args = | 968 BeginFrameArgs args = |
| 961 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 969 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 962 begin_frame_source()->TestOnBeginFrame(args); | 970 begin_frame_source()->TestOnBeginFrame(args); |
| 963 | 971 |
| 964 // Check that the support forwards our ack to the BeginFrameSource. | 972 // Check that the support forwards a BeginFrameDidNotSwap ack to the |
| 973 // BeginFrameSource. |
| 965 BeginFrameAck ack(0, 1, 1, 0, false); | 974 BeginFrameAck ack(0, 1, 1, 0, false); |
| 966 display_support().DidFinishFrame(ack); | 975 display_support().BeginFrameDidNotSwap(ack); |
| 967 EXPECT_EQ(ack, begin_frame_source()->LastAckForObserver(&display_support())); | 976 EXPECT_EQ(ack, begin_frame_source()->LastAckForObserver(&display_support())); |
| 977 |
| 978 // TODO(eseckler): Check that the support forwards the BeginFrameAck attached |
| 979 // to a CompositorFrame to the BeginFrameSource. |
| 968 } | 980 } |
| 969 | 981 |
| 970 // Checks whether the resources are returned before we send an ack. | 982 // Checks whether the resources are returned before we send an ack. |
| 971 TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesBeforeAck) { | 983 TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesBeforeAck) { |
| 972 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 984 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 973 TransferableResource resource; | 985 TransferableResource resource; |
| 974 resource.id = 1234; | 986 resource.id = 1234; |
| 975 parent_support().SubmitCompositorFrame( | 987 parent_support().SubmitCompositorFrame( |
| 976 parent_id.local_surface_id(), | 988 parent_id.local_surface_id(), |
| 977 MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); | 989 MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); |
| 978 { | 990 { |
| 979 InSequence x; | 991 InSequence x; |
| 980 EXPECT_CALL(support_client_, ReclaimResources(_)); | 992 EXPECT_CALL(support_client_, ReclaimResources(_)); |
| 981 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck()); | 993 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck()); |
| 982 } | 994 } |
| 983 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 995 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
| 984 CompositorFrame()); | 996 MakeCompositorFrame()); |
| 985 } | 997 } |
| 986 | 998 |
| 987 // Verifies that if a surface is marked destroyed and a new frame arrives for | 999 // Verifies that if a surface is marked destroyed and a new frame arrives for |
| 988 // it, it will be recovered. | 1000 // it, it will be recovered. |
| 989 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { | 1001 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { |
| 990 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1002 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 991 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); | 1003 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); |
| 992 | 1004 |
| 993 // Add a reference from the parent to the child. | 1005 // Add a reference from the parent to the child. |
| 994 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1006 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
| 995 MakeCompositorFrame({child_id})); | 1007 MakeCompositorFrame({child_id})); |
| 996 | 1008 |
| 997 // Create the child surface by submitting a frame to it. | 1009 // Create the child surface by submitting a frame to it. |
| 998 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1010 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 999 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1011 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1000 CompositorFrame()); | 1012 MakeCompositorFrame()); |
| 1001 | 1013 |
| 1002 // Verify that the child surface is created. | 1014 // Verify that the child surface is created. |
| 1003 Surface* surface = surface_manager().GetSurfaceForId(child_id); | 1015 Surface* surface = surface_manager().GetSurfaceForId(child_id); |
| 1004 EXPECT_NE(nullptr, surface); | 1016 EXPECT_NE(nullptr, surface); |
| 1005 | 1017 |
| 1006 // Attempt to destroy the child surface. The surface must still exist since | 1018 // Attempt to destroy the child surface. The surface must still exist since |
| 1007 // the parent needs it but it will be marked as destroyed. | 1019 // the parent needs it but it will be marked as destroyed. |
| 1008 child_support1().EvictFrame(); | 1020 child_support1().EvictFrame(); |
| 1009 surface = surface_manager().GetSurfaceForId(child_id); | 1021 surface = surface_manager().GetSurfaceForId(child_id); |
| 1010 EXPECT_NE(nullptr, surface); | 1022 EXPECT_NE(nullptr, surface); |
| 1011 EXPECT_TRUE(surface->destroyed()); | 1023 EXPECT_TRUE(surface->destroyed()); |
| 1012 | 1024 |
| 1013 // Child submits another frame to the same local surface id that is marked | 1025 // Child submits another frame to the same local surface id that is marked |
| 1014 // destroyed. | 1026 // destroyed. |
| 1015 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1027 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1016 CompositorFrame()); | 1028 MakeCompositorFrame()); |
| 1017 | 1029 |
| 1018 // Verify that the surface that was marked destroyed is recovered and is being | 1030 // Verify that the surface that was marked destroyed is recovered and is being |
| 1019 // used again. | 1031 // used again. |
| 1020 Surface* surface2 = surface_manager().GetSurfaceForId(child_id); | 1032 Surface* surface2 = surface_manager().GetSurfaceForId(child_id); |
| 1021 EXPECT_EQ(surface, surface2); | 1033 EXPECT_EQ(surface, surface2); |
| 1022 EXPECT_FALSE(surface2->destroyed()); | 1034 EXPECT_FALSE(surface2->destroyed()); |
| 1023 } | 1035 } |
| 1024 | 1036 |
| 1025 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist | 1037 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist |
| 1026 // anymore, it can still be reused for new surfaces. | 1038 // anymore, it can still be reused for new surfaces. |
| 1027 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { | 1039 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { |
| 1028 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1040 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 1029 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); | 1041 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); |
| 1030 | 1042 |
| 1031 // Add a reference from parent. | 1043 // Add a reference from parent. |
| 1032 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1044 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
| 1033 MakeCompositorFrame({child_id})); | 1045 MakeCompositorFrame({child_id})); |
| 1034 | 1046 |
| 1035 // Submit the first frame. Creates the surface. | 1047 // Submit the first frame. Creates the surface. |
| 1036 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1048 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1037 CompositorFrame()); | 1049 MakeCompositorFrame()); |
| 1038 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1050 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1039 | 1051 |
| 1040 // Remove the reference from parant. This allows us to destroy the surface. | 1052 // Remove the reference from parant. This allows us to destroy the surface. |
| 1041 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1053 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
| 1042 CompositorFrame()); | 1054 MakeCompositorFrame()); |
| 1043 | 1055 |
| 1044 // Destroy the surface. | 1056 // Destroy the surface. |
| 1045 child_support1().EvictFrame(); | 1057 child_support1().EvictFrame(); |
| 1046 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1058 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1047 | 1059 |
| 1048 // Submit another frame with the same local surface id. This should work fine | 1060 // Submit another frame with the same local surface id. This should work fine |
| 1049 // and a new surface must be created. | 1061 // and a new surface must be created. |
| 1050 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1062 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1051 CompositorFrame()); | 1063 MakeCompositorFrame()); |
| 1052 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1064 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1053 } | 1065 } |
| 1054 | 1066 |
| 1055 } // namespace test | 1067 } // namespace test |
| 1056 } // namespace cc | 1068 } // namespace cc |
| OLD | NEW |