Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: cc/surfaces/compositor_frame_sink_support_unittest.cc

Issue 2755463002: [cc] Fix CompositorFrameSinkSupport BeginFrameAck interface. (Closed)
Patch Set: sync Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 const int64_t latency_id1 = 234; 767 const int64_t latency_id1 = 234;
760 const int64_t latency_sequence_number1 = 5645432; 768 const int64_t latency_sequence_number1 = 5645432;
761 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; 769 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
762 const int64_t latency_id2 = 31434351; 770 const int64_t latency_id2 = 31434351;
763 const int64_t latency_sequence_number2 = 663788; 771 const int64_t latency_sequence_number2 = 663788;
764 772
765 // Submit a frame with latency info 773 // Submit a frame with latency info
766 ui::LatencyInfo info; 774 ui::LatencyInfo info;
767 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); 775 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1);
768 776
769 CompositorFrame frame; 777 CompositorFrame frame = MakeCompositorFrame();
770 frame.metadata.latency_info.push_back(info); 778 frame.metadata.latency_info.push_back(info);
771 779
772 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 780 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
773 std::move(frame)); 781 std::move(frame));
774 782
775 // Verify that the old surface has an active frame and no pending frame. 783 // Verify that the old surface has an active frame and no pending frame.
776 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); 784 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1);
777 ASSERT_NE(nullptr, old_surface); 785 ASSERT_NE(nullptr, old_surface);
778 EXPECT_TRUE(old_surface->HasActiveFrame()); 786 EXPECT_TRUE(old_surface->HasActiveFrame());
779 EXPECT_FALSE(old_surface->HasPendingFrame()); 787 EXPECT_FALSE(old_surface->HasPendingFrame());
780 788
781 // Submit another frame with some other latency info and a different 789 // Submit another frame with some other latency info and a different
782 // LocalSurfaceId. 790 // LocalSurfaceId.
783 ui::LatencyInfo info2; 791 ui::LatencyInfo info2;
784 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); 792 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2);
785 793
786 CompositorFrame frame2; 794 CompositorFrame frame2 = MakeCompositorFrame();
787 frame2.metadata.latency_info.push_back(info2); 795 frame2.metadata.latency_info.push_back(info2);
788 796
789 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), 797 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
790 std::move(frame2)); 798 std::move(frame2));
791 799
792 // Verify that the new surface has an active frame and no pending frames. 800 // Verify that the new surface has an active frame and no pending frames.
793 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); 801 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
794 ASSERT_NE(nullptr, surface); 802 ASSERT_NE(nullptr, surface);
795 EXPECT_TRUE(surface->HasActiveFrame()); 803 EXPECT_TRUE(surface->HasActiveFrame());
796 EXPECT_FALSE(surface->HasPendingFrame()); 804 EXPECT_FALSE(surface->HasPendingFrame());
(...skipping 26 matching lines...) Expand all
823 const int64_t latency_id1 = 234; 831 const int64_t latency_id1 = 234;
824 const int64_t latency_sequence_number1 = 5645432; 832 const int64_t latency_sequence_number1 = 5645432;
825 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; 833 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
826 const int64_t latency_id2 = 31434351; 834 const int64_t latency_id2 = 31434351;
827 const int64_t latency_sequence_number2 = 663788; 835 const int64_t latency_sequence_number2 = 663788;
828 836
829 // Submit a frame with no unresolved dependecy. 837 // Submit a frame with no unresolved dependecy.
830 ui::LatencyInfo info; 838 ui::LatencyInfo info;
831 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); 839 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1);
832 840
833 CompositorFrame frame; 841 CompositorFrame frame = MakeCompositorFrame();
834 frame.metadata.latency_info.push_back(info); 842 frame.metadata.latency_info.push_back(info);
835 843
836 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 844 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
837 std::move(frame)); 845 std::move(frame));
838 846
839 // Submit a frame with unresolved dependencies. 847 // Submit a frame with unresolved dependencies.
840 ui::LatencyInfo info2; 848 ui::LatencyInfo info2;
841 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); 849 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2);
842 850
843 CompositorFrame frame2 = MakeCompositorFrame({child_id}); 851 CompositorFrame frame2 = MakeCompositorFrame({child_id});
844 frame2.metadata.latency_info.push_back(info2); 852 frame2.metadata.latency_info.push_back(info2);
845 853
846 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 854 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
847 std::move(frame2)); 855 std::move(frame2));
848 856
849 // Verify that the old surface has both an active and a pending frame. 857 // Verify that the old surface has both an active and a pending frame.
850 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); 858 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1);
851 ASSERT_NE(nullptr, old_surface); 859 ASSERT_NE(nullptr, old_surface);
852 EXPECT_TRUE(old_surface->HasActiveFrame()); 860 EXPECT_TRUE(old_surface->HasActiveFrame());
853 EXPECT_TRUE(old_surface->HasPendingFrame()); 861 EXPECT_TRUE(old_surface->HasPendingFrame());
854 862
855 // Submit a frame with a new local surface id. 863 // Submit a frame with a new local surface id.
856 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), 864 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(),
857 CompositorFrame()); 865 MakeCompositorFrame());
858 866
859 // Verify that the new surface has an active frame only. 867 // Verify that the new surface has an active frame only.
860 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); 868 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
861 ASSERT_NE(nullptr, surface); 869 ASSERT_NE(nullptr, surface);
862 EXPECT_TRUE(surface->HasActiveFrame()); 870 EXPECT_TRUE(surface->HasActiveFrame());
863 EXPECT_FALSE(surface->HasPendingFrame()); 871 EXPECT_FALSE(surface->HasPendingFrame());
864 872
865 // Verify that the new surface has latency info from both active and pending 873 // Verify that the new surface has latency info from both active and pending
866 // frame of the old surface. 874 // frame of the old surface.
867 std::vector<ui::LatencyInfo> info_list; 875 std::vector<ui::LatencyInfo> info_list;
(...skipping 23 matching lines...) Expand all
891 const int64_t latency_id1 = 234; 899 const int64_t latency_id1 = 234;
892 const int64_t latency_sequence_number1 = 5645432; 900 const int64_t latency_sequence_number1 = 5645432;
893 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; 901 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT;
894 const int64_t latency_id2 = 31434351; 902 const int64_t latency_id2 = 31434351;
895 const int64_t latency_sequence_number2 = 663788; 903 const int64_t latency_sequence_number2 = 663788;
896 904
897 // Submit a frame with no unresolved dependencies. 905 // Submit a frame with no unresolved dependencies.
898 ui::LatencyInfo info; 906 ui::LatencyInfo info;
899 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); 907 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1);
900 908
901 CompositorFrame frame; 909 CompositorFrame frame = MakeCompositorFrame();
902 frame.metadata.latency_info.push_back(info); 910 frame.metadata.latency_info.push_back(info);
903 911
904 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), 912 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(),
905 std::move(frame)); 913 std::move(frame));
906 914
907 // Verify that the old surface has an active frame only. 915 // Verify that the old surface has an active frame only.
908 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); 916 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1);
909 ASSERT_NE(nullptr, old_surface); 917 ASSERT_NE(nullptr, old_surface);
910 EXPECT_TRUE(old_surface->HasActiveFrame()); 918 EXPECT_TRUE(old_surface->HasActiveFrame());
911 EXPECT_FALSE(old_surface->HasPendingFrame()); 919 EXPECT_FALSE(old_surface->HasPendingFrame());
(...skipping 10 matching lines...) Expand all
922 std::move(frame2)); 930 std::move(frame2));
923 931
924 // Verify that the new surface has a pending frame and no active frame. 932 // Verify that the new surface has a pending frame and no active frame.
925 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); 933 Surface* surface = surface_manager().GetSurfaceForId(parent_id2);
926 ASSERT_NE(nullptr, surface); 934 ASSERT_NE(nullptr, surface);
927 EXPECT_TRUE(surface->HasPendingFrame()); 935 EXPECT_TRUE(surface->HasPendingFrame());
928 EXPECT_FALSE(surface->HasActiveFrame()); 936 EXPECT_FALSE(surface->HasActiveFrame());
929 937
930 // Resolve the dependencies. The frame in parent's surface must become active. 938 // Resolve the dependencies. The frame in parent's surface must become active.
931 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 939 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
932 CompositorFrame()); 940 MakeCompositorFrame());
933 EXPECT_FALSE(surface->HasPendingFrame()); 941 EXPECT_FALSE(surface->HasPendingFrame());
934 EXPECT_TRUE(surface->HasActiveFrame()); 942 EXPECT_TRUE(surface->HasActiveFrame());
935 943
936 // Both latency info elements must exist in the now-activated frame of the 944 // Both latency info elements must exist in the now-activated frame of the
937 // new surface. 945 // new surface.
938 std::vector<ui::LatencyInfo> info_list; 946 std::vector<ui::LatencyInfo> info_list;
939 surface->TakeLatencyInfo(&info_list); 947 surface->TakeLatencyInfo(&info_list);
940 EXPECT_EQ(2u, info_list.size()); 948 EXPECT_EQ(2u, info_list.size());
941 949
942 ui::LatencyInfo aggregated_latency_info = info_list[0]; 950 ui::LatencyInfo aggregated_latency_info = info_list[0];
943 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); 951 aggregated_latency_info.AddNewLatencyFrom(info_list[1]);
944 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); 952 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size());
945 953
946 ui::LatencyInfo::LatencyComponent comp1; 954 ui::LatencyInfo::LatencyComponent comp1;
947 EXPECT_TRUE( 955 EXPECT_TRUE(
948 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); 956 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1));
949 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); 957 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number);
950 } 958 }
951 959
952 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { 960 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) {
953 // Request BeginFrames. 961 // Request BeginFrames.
954 display_support().SetNeedsBeginFrame(true); 962 display_support().SetNeedsBeginFrame(true);
955 963
956 // Issue a BeginFrame. 964 // Issue a BeginFrame.
957 BeginFrameArgs args = 965 BeginFrameArgs args =
958 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); 966 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1);
959 begin_frame_source()->TestOnBeginFrame(args); 967 begin_frame_source()->TestOnBeginFrame(args);
960 968
961 // Check that the support forwards our ack to the BeginFrameSource. 969 // Check that the support forwards a BeginFrameDidNotSwap ack to the
970 // BeginFrameSource.
962 BeginFrameAck ack(0, 1, 1, 0, false); 971 BeginFrameAck ack(0, 1, 1, 0, false);
963 display_support().DidFinishFrame(ack); 972 display_support().BeginFrameDidNotSwap(ack);
964 EXPECT_EQ(ack, begin_frame_source()->LastAckForObserver(&display_support())); 973 EXPECT_EQ(ack, begin_frame_source()->LastAckForObserver(&display_support()));
974
975 // TODO(eseckler): Check that the support forwards the BeginFrameAck attached
976 // to a CompositorFrame to the BeginFrameSource.
965 } 977 }
966 978
967 // Checks whether the resources are returned before we send an ack. 979 // Checks whether the resources are returned before we send an ack.
968 TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesBeforeAck) { 980 TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesBeforeAck) {
969 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 981 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
970 TransferableResource resource; 982 TransferableResource resource;
971 resource.id = 1234; 983 resource.id = 1234;
972 parent_support().SubmitCompositorFrame( 984 parent_support().SubmitCompositorFrame(
973 parent_id.local_surface_id(), 985 parent_id.local_surface_id(),
974 MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); 986 MakeCompositorFrameWithResources(empty_surface_ids(), {resource}));
975 { 987 {
976 InSequence x; 988 InSequence x;
977 EXPECT_CALL(support_client_, ReclaimResources(_)); 989 EXPECT_CALL(support_client_, ReclaimResources(_));
978 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck()); 990 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck());
979 } 991 }
980 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 992 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
981 CompositorFrame()); 993 MakeCompositorFrame());
982 } 994 }
983 995
984 // Verifies that if a surface is marked destroyed and a new frame arrives for 996 // Verifies that if a surface is marked destroyed and a new frame arrives for
985 // it, it will be recovered. 997 // it, it will be recovered.
986 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { 998 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) {
987 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 999 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
988 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); 1000 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3);
989 1001
990 // Add a reference from the parent to the child. 1002 // Add a reference from the parent to the child.
991 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 1003 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
992 MakeCompositorFrame({child_id})); 1004 MakeCompositorFrame({child_id}));
993 1005
994 // Create the child surface by submitting a frame to it. 1006 // Create the child surface by submitting a frame to it.
995 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); 1007 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id));
996 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 1008 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
997 CompositorFrame()); 1009 MakeCompositorFrame());
998 1010
999 // Verify that the child surface is created. 1011 // Verify that the child surface is created.
1000 Surface* surface = surface_manager().GetSurfaceForId(child_id); 1012 Surface* surface = surface_manager().GetSurfaceForId(child_id);
1001 EXPECT_NE(nullptr, surface); 1013 EXPECT_NE(nullptr, surface);
1002 1014
1003 // Attempt to destroy the child surface. The surface must still exist since 1015 // Attempt to destroy the child surface. The surface must still exist since
1004 // the parent needs it but it will be marked as destroyed. 1016 // the parent needs it but it will be marked as destroyed.
1005 child_support1().EvictFrame(); 1017 child_support1().EvictFrame();
1006 surface = surface_manager().GetSurfaceForId(child_id); 1018 surface = surface_manager().GetSurfaceForId(child_id);
1007 EXPECT_NE(nullptr, surface); 1019 EXPECT_NE(nullptr, surface);
1008 EXPECT_TRUE(surface->destroyed()); 1020 EXPECT_TRUE(surface->destroyed());
1009 1021
1010 // Child submits another frame to the same local surface id that is marked 1022 // Child submits another frame to the same local surface id that is marked
1011 // destroyed. 1023 // destroyed.
1012 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 1024 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1013 CompositorFrame()); 1025 MakeCompositorFrame());
1014 1026
1015 // Verify that the surface that was marked destroyed is recovered and is being 1027 // Verify that the surface that was marked destroyed is recovered and is being
1016 // used again. 1028 // used again.
1017 Surface* surface2 = surface_manager().GetSurfaceForId(child_id); 1029 Surface* surface2 = surface_manager().GetSurfaceForId(child_id);
1018 EXPECT_EQ(surface, surface2); 1030 EXPECT_EQ(surface, surface2);
1019 EXPECT_FALSE(surface2->destroyed()); 1031 EXPECT_FALSE(surface2->destroyed());
1020 } 1032 }
1021 1033
1022 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist 1034 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist
1023 // anymore, it can still be reused for new surfaces. 1035 // anymore, it can still be reused for new surfaces.
1024 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { 1036 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) {
1025 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 1037 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
1026 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); 1038 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3);
1027 1039
1028 // Add a reference from parent. 1040 // Add a reference from parent.
1029 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 1041 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1030 MakeCompositorFrame({child_id})); 1042 MakeCompositorFrame({child_id}));
1031 1043
1032 // Submit the first frame. Creates the surface. 1044 // Submit the first frame. Creates the surface.
1033 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 1045 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1034 CompositorFrame()); 1046 MakeCompositorFrame());
1035 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); 1047 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id));
1036 1048
1037 // Remove the reference from parant. This allows us to destroy the surface. 1049 // Remove the reference from parant. This allows us to destroy the surface.
1038 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 1050 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
1039 CompositorFrame()); 1051 MakeCompositorFrame());
1040 1052
1041 // Destroy the surface. 1053 // Destroy the surface.
1042 child_support1().EvictFrame(); 1054 child_support1().EvictFrame();
1043 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); 1055 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id));
1044 1056
1045 // Submit another frame with the same local surface id. This should work fine 1057 // Submit another frame with the same local surface id. This should work fine
1046 // and a new surface must be created. 1058 // and a new surface must be created.
1047 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), 1059 child_support1().SubmitCompositorFrame(child_id.local_surface_id(),
1048 CompositorFrame()); 1060 MakeCompositorFrame());
1049 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); 1061 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id));
1050 } 1062 }
1051 1063
1052 // Checks whether a LocalSurfaceId can be reused after the 1064 // Checks whether a LocalSurfaceId can be reused after the
1053 // CompositorFrameSinkSupport is destroyed and recreated with the same 1065 // CompositorFrameSinkSupport is destroyed and recreated with the same
1054 // FrameSinkId. 1066 // FrameSinkId.
1055 TEST_F(CompositorFrameSinkSupportTest, ReuseSurfaceAfterSupportDestroyed) { 1067 TEST_F(CompositorFrameSinkSupportTest, ReuseSurfaceAfterSupportDestroyed) {
1056 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 1068 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
1057 const SurfaceId child_id = MakeSurfaceId(kArbitraryFrameSink, 1); 1069 const SurfaceId child_id = MakeSurfaceId(kArbitraryFrameSink, 1);
1058 std::unique_ptr<CompositorFrameSinkSupport> child_support = 1070 std::unique_ptr<CompositorFrameSinkSupport> child_support =
(...skipping 24 matching lines...) Expand all
1083 // be used and destroyed() must return false. The surface must have a factory. 1095 // be used and destroyed() must return false. The surface must have a factory.
1084 child_support->SubmitCompositorFrame( 1096 child_support->SubmitCompositorFrame(
1085 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 1097 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids()));
1086 EXPECT_EQ(surface, surface_manager().GetSurfaceForId(child_id)); 1098 EXPECT_EQ(surface, surface_manager().GetSurfaceForId(child_id));
1087 EXPECT_TRUE(surface->factory()); 1099 EXPECT_TRUE(surface->factory());
1088 EXPECT_FALSE(surface->destroyed()); 1100 EXPECT_FALSE(surface->destroyed());
1089 } 1101 }
1090 1102
1091 } // namespace test 1103 } // namespace test
1092 } // namespace cc 1104 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.cc ('k') | cc/surfaces/direct_compositor_frame_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698