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/macros.h" | 7 #include "base/macros.h" |
8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
9 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
10 #include "cc/surfaces/frame_sink_id.h" | 10 #include "cc/surfaces/frame_sink_id.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 true /* handles_frame_sink_id_invalidation */, | 146 true /* handles_frame_sink_id_invalidation */, |
147 true /* needs_sync_points */)); | 147 true /* needs_sync_points */)); |
148 supports_.push_back(base::MakeUnique<CompositorFrameSinkSupport>( | 148 supports_.push_back(base::MakeUnique<CompositorFrameSinkSupport>( |
149 this, &surface_manager_, kChildFrameSink1, false /* is_root */, | 149 this, &surface_manager_, kChildFrameSink1, false /* is_root */, |
150 true /* handles_frame_sink_id_invalidation */, | 150 true /* handles_frame_sink_id_invalidation */, |
151 true /* needs_sync_points */)); | 151 true /* needs_sync_points */)); |
152 supports_.push_back(base::MakeUnique<CompositorFrameSinkSupport>( | 152 supports_.push_back(base::MakeUnique<CompositorFrameSinkSupport>( |
153 this, &surface_manager_, kChildFrameSink2, false /* is_root */, | 153 this, &surface_manager_, kChildFrameSink2, false /* is_root */, |
154 true /* handles_frame_sink_id_invalidation */, | 154 true /* handles_frame_sink_id_invalidation */, |
155 true /* needs_sync_points */)); | 155 true /* needs_sync_points */)); |
| 156 |
| 157 // Normally, the BeginFrameSource would be registered by the Display. We |
| 158 // register it here so that BeginFrames are received by the display support, |
| 159 // for use in the PassesOnBeginFrameAcks test. Other supports do not receive |
| 160 // BeginFrames, since the frame sink hierarchy is not set up in this test. |
| 161 surface_manager_.RegisterBeginFrameSource(begin_frame_source_.get(), |
| 162 kDisplayFrameSink); |
156 } | 163 } |
157 | 164 |
158 void TearDown() override { | 165 void TearDown() override { |
159 surface_manager_.SetDependencyTracker(nullptr); | 166 surface_manager_.SetDependencyTracker(nullptr); |
| 167 surface_manager_.UnregisterBeginFrameSource(begin_frame_source_.get()); |
160 | 168 |
161 // SurfaceDependencyTracker depends on this BeginFrameSource and so it must | 169 // SurfaceDependencyTracker depends on this BeginFrameSource and so it must |
162 // be destroyed AFTER the dependency tracker is destroyed. | 170 // be destroyed AFTER the dependency tracker is destroyed. |
163 begin_frame_source_.reset(); | 171 begin_frame_source_.reset(); |
164 | 172 |
165 supports_.clear(); | 173 supports_.clear(); |
166 } | 174 } |
167 | 175 |
168 // CompositorFrameSinkSupportClient implementation. | 176 // CompositorFrameSinkSupportClient implementation. |
169 void DidReceiveCompositorFrameAck() override {} | 177 void DidReceiveCompositorFrameAck() override {} |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 ui::LatencyInfo aggregated_latency_info = info_list[0]; | 925 ui::LatencyInfo aggregated_latency_info = info_list[0]; |
918 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); | 926 aggregated_latency_info.AddNewLatencyFrom(info_list[1]); |
919 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); | 927 EXPECT_EQ(2u, aggregated_latency_info.latency_components().size()); |
920 | 928 |
921 ui::LatencyInfo::LatencyComponent comp1; | 929 ui::LatencyInfo::LatencyComponent comp1; |
922 EXPECT_TRUE( | 930 EXPECT_TRUE( |
923 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 931 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
924 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 932 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
925 } | 933 } |
926 | 934 |
| 935 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { |
| 936 // Request BeginFrames. |
| 937 display_support().SetNeedsBeginFrame(true); |
| 938 |
| 939 // Issue a BeginFrame. |
| 940 BeginFrameArgs args = |
| 941 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 942 begin_frame_source()->TestOnBeginFrame(args); |
| 943 |
| 944 // Check that the support forwards our ack to the BeginFrameSource. |
| 945 BeginFrameAck ack(0, 1, 1, 0, false); |
| 946 display_support().DidFinishFrame(ack); |
| 947 EXPECT_EQ(ack, begin_frame_source()->LastAckForObserver(&display_support())); |
| 948 } |
| 949 |
927 } // namespace test | 950 } // namespace test |
928 } // namespace cc | 951 } // namespace cc |
OLD | NEW |