| 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 | |
| 7 #include "base/macros.h" | |
| 8 #include "cc/output/compositor_frame.h" | |
| 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" | |
| 10 #include "cc/surfaces/frame_sink_id.h" | |
| 11 #include "cc/surfaces/surface_id.h" | 6 #include "cc/surfaces/surface_id.h" |
| 12 #include "cc/surfaces/surface_manager.h" | 7 #include "cc/surfaces/surface_manager.h" |
| 8 #include "cc/surfaces/surface_observer.h" |
| 13 #include "cc/test/begin_frame_args_test.h" | 9 #include "cc/test/begin_frame_args_test.h" |
| 14 #include "cc/test/fake_external_begin_frame_source.h" | 10 #include "cc/test/fake_external_begin_frame_source.h" |
| 11 #include "cc/test/mock_compositor_frame_sink_support_client.h" |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 14 |
| 18 using testing::UnorderedElementsAre; | |
| 19 using testing::IsEmpty; | |
| 20 using testing::SizeIs; | |
| 21 using testing::Invoke; | |
| 22 using testing::_; | 15 using testing::_; |
| 23 using testing::Eq; | 16 using testing::Eq; |
| 17 using testing::IsEmpty; |
| 18 using testing::UnorderedElementsAre; |
| 24 | 19 |
| 25 namespace cc { | 20 namespace cc { |
| 26 namespace test { | 21 namespace test { |
| 27 namespace { | 22 namespace { |
| 28 | 23 |
| 24 constexpr bool kIsRoot = true; |
| 25 constexpr bool kIsChildRoot = false; |
| 26 constexpr bool kHandlesFrameSinkIdInvalidation = true; |
| 27 constexpr bool kNeedsSyncPoints = true; |
| 29 constexpr FrameSinkId kDisplayFrameSink(2, 0); | 28 constexpr FrameSinkId kDisplayFrameSink(2, 0); |
| 30 constexpr FrameSinkId kParentFrameSink(3, 0); | 29 constexpr FrameSinkId kParentFrameSink(3, 0); |
| 31 constexpr FrameSinkId kChildFrameSink1(65563, 0); | 30 constexpr FrameSinkId kChildFrameSink1(65563, 0); |
| 32 constexpr FrameSinkId kChildFrameSink2(65564, 0); | 31 constexpr FrameSinkId kChildFrameSink2(65564, 0); |
| 33 constexpr FrameSinkId kArbitraryFrameSink(1337, 7331); | 32 constexpr FrameSinkId kArbitraryFrameSink(1337, 7331); |
| 34 | 33 |
| 35 class MockCompositorFrameSinkSupportClient | |
| 36 : public CompositorFrameSinkSupportClient { | |
| 37 public: | |
| 38 MockCompositorFrameSinkSupportClient() { | |
| 39 ON_CALL(*this, ReclaimResources(_)) | |
| 40 .WillByDefault(Invoke( | |
| 41 this, | |
| 42 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); | |
| 43 ON_CALL(*this, DidReceiveCompositorFrameAck(_)) | |
| 44 .WillByDefault(Invoke( | |
| 45 this, | |
| 46 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); | |
| 47 } | |
| 48 | |
| 49 ReturnedResourceArray& last_returned_resources() { | |
| 50 return last_returned_resources_; | |
| 51 } | |
| 52 | |
| 53 // CompositorFrameSinkSupportClient implementation. | |
| 54 MOCK_METHOD1(DidReceiveCompositorFrameAck, | |
| 55 void(const ReturnedResourceArray&)); | |
| 56 MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&)); | |
| 57 MOCK_METHOD1(ReclaimResources, void(const ReturnedResourceArray&)); | |
| 58 MOCK_METHOD2(WillDrawSurface, void(const LocalSurfaceId&, const gfx::Rect&)); | |
| 59 | |
| 60 private: | |
| 61 void ReclaimResourcesInternal(const ReturnedResourceArray& resources) { | |
| 62 last_returned_resources_ = resources; | |
| 63 } | |
| 64 | |
| 65 ReturnedResourceArray last_returned_resources_; | |
| 66 }; | |
| 67 | |
| 68 std::vector<SurfaceId> empty_surface_ids() { | 34 std::vector<SurfaceId> empty_surface_ids() { |
| 69 return std::vector<SurfaceId>(); | 35 return std::vector<SurfaceId>(); |
| 70 } | 36 } |
| 71 | 37 |
| 72 SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { | 38 SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { |
| 73 return SurfaceId( | 39 return SurfaceId( |
| 74 frame_sink_id, | 40 frame_sink_id, |
| 75 LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); | 41 LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); |
| 76 } | 42 } |
| 77 | 43 |
| 78 CompositorFrame MakeCompositorFrame(std::vector<SurfaceId> embedded_surfaces, | |
| 79 std::vector<SurfaceId> referenced_surfaces, | |
| 80 TransferableResourceArray resource_list) { | |
| 81 CompositorFrame compositor_frame; | |
| 82 compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, true); | |
| 83 compositor_frame.metadata.embedded_surfaces = std::move(embedded_surfaces); | |
| 84 compositor_frame.metadata.referenced_surfaces = | |
| 85 std::move(referenced_surfaces); | |
| 86 compositor_frame.resource_list = std::move(resource_list); | |
| 87 return compositor_frame; | |
| 88 } | |
| 89 | |
| 90 CompositorFrame MakeCompositorFrame() { | |
| 91 return MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), | |
| 92 TransferableResourceArray()); | |
| 93 } | |
| 94 | |
| 95 CompositorFrame MakeCompositorFrame(std::vector<SurfaceId> embedded_surfaces) { | |
| 96 return MakeCompositorFrame(embedded_surfaces, embedded_surfaces, | |
| 97 TransferableResourceArray()); | |
| 98 } | |
| 99 | |
| 100 CompositorFrame MakeCompositorFrame( | |
| 101 std::vector<SurfaceId> embedded_surfaces, | |
| 102 std::vector<SurfaceId> referenced_surfaces) { | |
| 103 return MakeCompositorFrame(std::move(embedded_surfaces), | |
| 104 std::move(referenced_surfaces), | |
| 105 TransferableResourceArray()); | |
| 106 } | |
| 107 | |
| 108 CompositorFrame MakeCompositorFrameWithResources( | |
| 109 std::vector<SurfaceId> embedded_surfaces, | |
| 110 TransferableResourceArray resource_list) { | |
| 111 return MakeCompositorFrame(embedded_surfaces, embedded_surfaces, | |
| 112 std::move(resource_list)); | |
| 113 } | |
| 114 | |
| 115 TransferableResource MakeResource(ResourceId id, | |
| 116 ResourceFormat format, | |
| 117 uint32_t filter, | |
| 118 const gfx::Size& size) { | |
| 119 TransferableResource resource; | |
| 120 resource.id = id; | |
| 121 resource.format = format; | |
| 122 resource.filter = filter; | |
| 123 resource.size = size; | |
| 124 return resource; | |
| 125 } | |
| 126 | |
| 127 } // namespace | 44 } // namespace |
| 128 | 45 |
| 129 class CompositorFrameSinkSupportTest : public testing::Test, | 46 class SurfaceSynchronizationTest : public testing::Test, |
| 130 public SurfaceObserver { | 47 public SurfaceObserver { |
| 131 public: | 48 public: |
| 132 CompositorFrameSinkSupportTest() | 49 SurfaceSynchronizationTest() |
| 133 : surface_manager_(SurfaceManager::LifetimeType::REFERENCES) {} | 50 : support_client_(false /* create_surface_during_eviction */), |
| 134 ~CompositorFrameSinkSupportTest() override {} | 51 surface_manager_(SurfaceManager::LifetimeType::REFERENCES) {} |
| 52 ~SurfaceSynchronizationTest() override {} |
| 135 | 53 |
| 136 CompositorFrameSinkSupport& display_support() { return *supports_[0]; } | 54 CompositorFrameSinkSupport& display_support() { return *supports_[0]; } |
| 137 Surface* display_surface() { | 55 Surface* display_surface() { |
| 138 return display_support().current_surface_for_testing(); | 56 return display_support().current_surface_for_testing(); |
| 139 } | 57 } |
| 140 | 58 |
| 141 CompositorFrameSinkSupport& parent_support() { return *supports_[1]; } | 59 CompositorFrameSinkSupport& parent_support() { return *supports_[1]; } |
| 142 Surface* parent_surface() { | 60 Surface* parent_surface() { |
| 143 return parent_support().current_surface_for_testing(); | 61 return parent_support().current_surface_for_testing(); |
| 144 } | 62 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return *surface_manager_.dependency_tracker(); | 96 return *surface_manager_.dependency_tracker(); |
| 179 } | 97 } |
| 180 | 98 |
| 181 FakeExternalBeginFrameSource* begin_frame_source() { | 99 FakeExternalBeginFrameSource* begin_frame_source() { |
| 182 return begin_frame_source_.get(); | 100 return begin_frame_source_.get(); |
| 183 } | 101 } |
| 184 | 102 |
| 185 // testing::Test: | 103 // testing::Test: |
| 186 void SetUp() override { | 104 void SetUp() override { |
| 187 testing::Test::SetUp(); | 105 testing::Test::SetUp(); |
| 188 constexpr bool is_root = true; | 106 |
| 189 constexpr bool is_child_root = false; | |
| 190 constexpr bool handles_frame_sink_id_invalidation = true; | |
| 191 constexpr bool needs_sync_points = true; | |
| 192 begin_frame_source_ = | 107 begin_frame_source_ = |
| 193 base::MakeUnique<FakeExternalBeginFrameSource>(0.f, false); | 108 base::MakeUnique<FakeExternalBeginFrameSource>(0.f, false); |
| 194 surface_manager_.SetDependencyTracker( | 109 surface_manager_.SetDependencyTracker( |
| 195 base::MakeUnique<SurfaceDependencyTracker>(&surface_manager_, | 110 base::MakeUnique<SurfaceDependencyTracker>(&surface_manager_, |
| 196 begin_frame_source_.get())); | 111 begin_frame_source_.get())); |
| 197 surface_manager_.AddObserver(this); | 112 surface_manager_.AddObserver(this); |
| 198 supports_.push_back(CompositorFrameSinkSupport::Create( | 113 supports_.push_back(CompositorFrameSinkSupport::Create( |
| 199 &support_client_, &surface_manager_, kDisplayFrameSink, is_root, | 114 &support_client_, &surface_manager_, kDisplayFrameSink, kIsRoot, |
| 200 handles_frame_sink_id_invalidation, needs_sync_points)); | 115 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
| 201 supports_.push_back(CompositorFrameSinkSupport::Create( | 116 supports_.push_back(CompositorFrameSinkSupport::Create( |
| 202 &support_client_, &surface_manager_, kParentFrameSink, is_child_root, | 117 &support_client_, &surface_manager_, kParentFrameSink, kIsChildRoot, |
| 203 handles_frame_sink_id_invalidation, needs_sync_points)); | 118 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
| 204 supports_.push_back(CompositorFrameSinkSupport::Create( | 119 supports_.push_back(CompositorFrameSinkSupport::Create( |
| 205 &support_client_, &surface_manager_, kChildFrameSink1, is_child_root, | 120 &support_client_, &surface_manager_, kChildFrameSink1, kIsChildRoot, |
| 206 handles_frame_sink_id_invalidation, needs_sync_points)); | 121 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
| 207 supports_.push_back(CompositorFrameSinkSupport::Create( | 122 supports_.push_back(CompositorFrameSinkSupport::Create( |
| 208 &support_client_, &surface_manager_, kChildFrameSink2, is_child_root, | 123 &support_client_, &surface_manager_, kChildFrameSink2, kIsChildRoot, |
| 209 handles_frame_sink_id_invalidation, needs_sync_points)); | 124 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
| 210 | 125 |
| 211 // Normally, the BeginFrameSource would be registered by the Display. We | 126 // Normally, the BeginFrameSource would be registered by the Display. We |
| 212 // register it here so that BeginFrames are received by the display support, | 127 // register it here so that BeginFrames are received by the display support, |
| 213 // for use in the PassesOnBeginFrameAcks test. Other supports do not receive | 128 // for use in the PassesOnBeginFrameAcks test. Other supports do not receive |
| 214 // BeginFrames, since the frame sink hierarchy is not set up in this test. | 129 // BeginFrames, since the frame sink hierarchy is not set up in this test. |
| 215 surface_manager_.RegisterBeginFrameSource(begin_frame_source_.get(), | 130 surface_manager_.RegisterBeginFrameSource(begin_frame_source_.get(), |
| 216 kDisplayFrameSink); | 131 kDisplayFrameSink); |
| 217 } | 132 } |
| 218 | 133 |
| 219 void TearDown() override { | 134 void TearDown() override { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 242 | 157 |
| 243 protected: | 158 protected: |
| 244 testing::NiceMock<MockCompositorFrameSinkSupportClient> support_client_; | 159 testing::NiceMock<MockCompositorFrameSinkSupportClient> support_client_; |
| 245 | 160 |
| 246 private: | 161 private: |
| 247 base::flat_set<SurfaceId> damaged_surfaces_; | 162 base::flat_set<SurfaceId> damaged_surfaces_; |
| 248 SurfaceManager surface_manager_; | 163 SurfaceManager surface_manager_; |
| 249 std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; | 164 std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; |
| 250 std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; | 165 std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; |
| 251 | 166 |
| 252 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupportTest); | 167 DISALLOW_COPY_AND_ASSIGN(SurfaceSynchronizationTest); |
| 253 }; | 168 }; |
| 254 | 169 |
| 255 // The display root surface should have a surface reference from the top-level | 170 // The display root surface should have a surface reference from the top-level |
| 256 // root added/removed when a CompositorFrame is submitted with a new SurfaceId. | 171 // root added/removed when a CompositorFrame is submitted with a new SurfaceId. |
| 257 TEST_F(CompositorFrameSinkSupportTest, RootSurfaceReceivesReferences) { | 172 TEST_F(SurfaceSynchronizationTest, RootSurfaceReceivesReferences) { |
| 258 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); | 173 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); |
| 259 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); | 174 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); |
| 260 | 175 |
| 261 // Submit a CompositorFrame for the first display root surface. | 176 // Submit a CompositorFrame for the first display root surface. |
| 262 display_support().SubmitCompositorFrame(display_id_first.local_surface_id(), | 177 display_support().SubmitCompositorFrame(display_id_first.local_surface_id(), |
| 263 MakeCompositorFrame()); | 178 MakeCompositorFrame()); |
| 264 | 179 |
| 265 // A surface reference from the top-level root is added and there shouldn't be | 180 // A surface reference from the top-level root is added and there shouldn't be |
| 266 // a temporary reference. | 181 // a temporary reference. |
| 267 EXPECT_FALSE(HasTemporaryReference(display_id_first)); | 182 EXPECT_FALSE(HasTemporaryReference(display_id_first)); |
| 268 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), | 183 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), |
| 269 UnorderedElementsAre(display_id_first)); | 184 UnorderedElementsAre(display_id_first)); |
| 270 | 185 |
| 271 // Submit a CompositorFrame for the second display root surface. | 186 // Submit a CompositorFrame for the second display root surface. |
| 272 display_support().SubmitCompositorFrame(display_id_second.local_surface_id(), | 187 display_support().SubmitCompositorFrame(display_id_second.local_surface_id(), |
| 273 MakeCompositorFrame()); | 188 MakeCompositorFrame()); |
| 274 | 189 |
| 275 // A surface reference from the top-level root to |display_id_second| should | 190 // A surface reference from the top-level root to |display_id_second| should |
| 276 // be added and the reference to |display_root_first| removed. | 191 // be added and the reference to |display_root_first| removed. |
| 277 EXPECT_FALSE(HasTemporaryReference(display_id_second)); | 192 EXPECT_FALSE(HasTemporaryReference(display_id_second)); |
| 278 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), | 193 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), |
| 279 UnorderedElementsAre(display_id_second)); | 194 UnorderedElementsAre(display_id_second)); |
| 280 | 195 |
| 281 // Surface |display_id_first| is unreachable and should get deleted. | 196 // Surface |display_id_first| is unreachable and should get deleted. |
| 282 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(display_id_first)); | 197 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(display_id_first)); |
| 283 } | 198 } |
| 284 | 199 |
| 285 // The parent Surface is blocked on |child_id1| and |child_id2|. | 200 // The parent Surface is blocked on |child_id1| and |child_id2|. |
| 286 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedOnTwo) { | 201 TEST_F(SurfaceSynchronizationTest, BlockedOnTwo) { |
| 287 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 202 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 288 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 203 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
| 289 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 204 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
| 290 | 205 |
| 291 parent_support().SubmitCompositorFrame( | 206 parent_support().SubmitCompositorFrame( |
| 292 parent_id.local_surface_id(), | 207 parent_id.local_surface_id(), |
| 293 MakeCompositorFrame({child_id1, child_id2})); | 208 MakeCompositorFrame({child_id1, child_id2}, {child_id1, child_id2}, |
| 209 TransferableResourceArray())); |
| 294 | 210 |
| 295 // parent_support is blocked on |child_id1| and |child_id2|. | 211 // parent_support is blocked on |child_id1| and |child_id2|. |
| 296 EXPECT_TRUE(dependency_tracker().has_deadline()); | 212 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 297 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 213 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 298 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 214 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 299 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 215 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 300 UnorderedElementsAre(child_id1, child_id2)); | 216 UnorderedElementsAre(child_id1, child_id2)); |
| 301 | 217 |
| 302 // Submit a CompositorFrame without any dependencies to |child_id1|. | 218 // Submit a CompositorFrame without any dependencies to |child_id1|. |
| 303 // parent_support should now only be blocked on |child_id2|. | 219 // parent_support should now only be blocked on |child_id2|. |
| 304 child_support1().SubmitCompositorFrame( | 220 child_support1().SubmitCompositorFrame( |
| 305 child_id1.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 221 child_id1.local_surface_id(), |
| 222 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 223 TransferableResourceArray())); |
| 306 | 224 |
| 307 EXPECT_TRUE(dependency_tracker().has_deadline()); | 225 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 308 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 226 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 309 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 227 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 310 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 228 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 311 UnorderedElementsAre(child_id2)); | 229 UnorderedElementsAre(child_id2)); |
| 312 | 230 |
| 313 // Submit a CompositorFrame without any dependencies to |child_id2|. | 231 // Submit a CompositorFrame without any dependencies to |child_id2|. |
| 314 // parent_support should be activated. | 232 // parent_support should be activated. |
| 315 child_support2().SubmitCompositorFrame( | 233 child_support2().SubmitCompositorFrame( |
| 316 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 234 child_id2.local_surface_id(), |
| 235 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 236 TransferableResourceArray())); |
| 317 | 237 |
| 318 EXPECT_FALSE(dependency_tracker().has_deadline()); | 238 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 319 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 239 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 320 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 240 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 321 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 241 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 322 } | 242 } |
| 323 | 243 |
| 324 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. | 244 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. |
| 325 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedChain) { | 245 TEST_F(SurfaceSynchronizationTest, BlockedChain) { |
| 326 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 246 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 327 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 247 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
| 328 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 248 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
| 329 | 249 |
| 330 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 250 parent_support().SubmitCompositorFrame( |
| 331 MakeCompositorFrame({child_id1})); | 251 parent_id.local_surface_id(), |
| 252 MakeCompositorFrame({child_id1}, {child_id1}, |
| 253 TransferableResourceArray())); |
| 332 | 254 |
| 333 // parent_support is blocked on |child_id1|. | 255 // parent_support is blocked on |child_id1|. |
| 334 EXPECT_TRUE(dependency_tracker().has_deadline()); | 256 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 335 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 257 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 336 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 258 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 337 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 259 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 338 UnorderedElementsAre(child_id1)); | 260 UnorderedElementsAre(child_id1)); |
| 339 // The parent should not report damage until it activates. | 261 // The parent should not report damage until it activates. |
| 340 EXPECT_FALSE(IsSurfaceDamaged(parent_id)); | 262 EXPECT_FALSE(IsSurfaceDamaged(parent_id)); |
| 341 | 263 |
| 342 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), | 264 child_support1().SubmitCompositorFrame( |
| 343 MakeCompositorFrame({child_id2})); | 265 child_id1.local_surface_id(), |
| 266 MakeCompositorFrame({child_id2}, {child_id2}, |
| 267 TransferableResourceArray())); |
| 344 | 268 |
| 345 // child_support1 should now be blocked on |child_id2|. | 269 // child_support1 should now be blocked on |child_id2|. |
| 346 EXPECT_TRUE(dependency_tracker().has_deadline()); | 270 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 347 EXPECT_FALSE(child_surface1()->HasActiveFrame()); | 271 EXPECT_FALSE(child_surface1()->HasActiveFrame()); |
| 348 EXPECT_TRUE(child_surface1()->HasPendingFrame()); | 272 EXPECT_TRUE(child_surface1()->HasPendingFrame()); |
| 349 EXPECT_THAT(child_surface1()->blocking_surfaces(), | 273 EXPECT_THAT(child_surface1()->blocking_surfaces(), |
| 350 UnorderedElementsAre(child_id2)); | 274 UnorderedElementsAre(child_id2)); |
| 351 // The parent and child should not report damage until they activate. | 275 // The parent and child should not report damage until they activate. |
| 352 EXPECT_FALSE(IsSurfaceDamaged(parent_id)); | 276 EXPECT_FALSE(IsSurfaceDamaged(parent_id)); |
| 353 EXPECT_FALSE(IsSurfaceDamaged(child_id1)); | 277 EXPECT_FALSE(IsSurfaceDamaged(child_id1)); |
| 354 | 278 |
| 355 // The parent should still be blocked on |child_id1| because it's pending. | 279 // The parent should still be blocked on |child_id1| because it's pending. |
| 356 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 280 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 357 UnorderedElementsAre(child_id1)); | 281 UnorderedElementsAre(child_id1)); |
| 358 | 282 |
| 359 // Submit a CompositorFrame without any dependencies to |child_id2|. | 283 // Submit a CompositorFrame without any dependencies to |child_id2|. |
| 360 // parent_support should be activated. | 284 // parent_support should be activated. |
| 361 child_support2().SubmitCompositorFrame( | 285 child_support2().SubmitCompositorFrame( |
| 362 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 286 child_id2.local_surface_id(), |
| 287 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 288 TransferableResourceArray())); |
| 363 | 289 |
| 364 EXPECT_FALSE(dependency_tracker().has_deadline()); | 290 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 365 | 291 |
| 366 // child_surface1 should now be active. | 292 // child_surface1 should now be active. |
| 367 EXPECT_TRUE(child_surface1()->HasActiveFrame()); | 293 EXPECT_TRUE(child_surface1()->HasActiveFrame()); |
| 368 EXPECT_FALSE(child_surface1()->HasPendingFrame()); | 294 EXPECT_FALSE(child_surface1()->HasPendingFrame()); |
| 369 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 295 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); |
| 370 | 296 |
| 371 // parent_surface should now be active. | 297 // parent_surface should now be active. |
| 372 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 298 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 373 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 299 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 374 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 300 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 375 | 301 |
| 376 // All three surfaces |parent_id|, |child_id1|, and |child_id2| should | 302 // All three surfaces |parent_id|, |child_id1|, and |child_id2| should |
| 377 // now report damage. This would trigger a new display frame. | 303 // now report damage. This would trigger a new display frame. |
| 378 EXPECT_TRUE(IsSurfaceDamaged(parent_id)); | 304 EXPECT_TRUE(IsSurfaceDamaged(parent_id)); |
| 379 EXPECT_TRUE(IsSurfaceDamaged(child_id1)); | 305 EXPECT_TRUE(IsSurfaceDamaged(child_id1)); |
| 380 EXPECT_TRUE(IsSurfaceDamaged(child_id2)); | 306 EXPECT_TRUE(IsSurfaceDamaged(child_id2)); |
| 381 } | 307 } |
| 382 | 308 |
| 383 // parent_surface and child_surface1 are blocked on |child_id2|. | 309 // parent_surface and child_surface1 are blocked on |child_id2|. |
| 384 TEST_F(CompositorFrameSinkSupportTest, | 310 TEST_F(SurfaceSynchronizationTest, TwoBlockedOnOne) { |
| 385 DisplayCompositorLockingTwoBlockedOnOne) { | |
| 386 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 311 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 387 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 312 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
| 388 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 313 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
| 389 | 314 |
| 390 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 315 parent_support().SubmitCompositorFrame( |
| 391 MakeCompositorFrame({child_id2})); | 316 parent_id.local_surface_id(), |
| 317 MakeCompositorFrame({child_id2}, {child_id2}, |
| 318 TransferableResourceArray())); |
| 392 | 319 |
| 393 // parent_support is blocked on |child_id2|. | 320 // parent_support is blocked on |child_id2|. |
| 394 EXPECT_TRUE(dependency_tracker().has_deadline()); | 321 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 395 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 322 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 396 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 323 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 397 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 324 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 398 UnorderedElementsAre(child_id2)); | 325 UnorderedElementsAre(child_id2)); |
| 399 | 326 |
| 400 // child_support1 should now be blocked on |child_id2|. | 327 // child_support1 should now be blocked on |child_id2|. |
| 401 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), | 328 child_support1().SubmitCompositorFrame( |
| 402 MakeCompositorFrame({child_id2})); | 329 child_id1.local_surface_id(), |
| 330 MakeCompositorFrame({child_id2}, {child_id2}, |
| 331 TransferableResourceArray())); |
| 403 | 332 |
| 404 EXPECT_TRUE(dependency_tracker().has_deadline()); | 333 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 405 EXPECT_FALSE(child_surface1()->HasActiveFrame()); | 334 EXPECT_FALSE(child_surface1()->HasActiveFrame()); |
| 406 EXPECT_TRUE(child_surface1()->HasPendingFrame()); | 335 EXPECT_TRUE(child_surface1()->HasPendingFrame()); |
| 407 EXPECT_THAT(child_surface1()->blocking_surfaces(), | 336 EXPECT_THAT(child_surface1()->blocking_surfaces(), |
| 408 UnorderedElementsAre(child_id2)); | 337 UnorderedElementsAre(child_id2)); |
| 409 | 338 |
| 410 // The parent should still be blocked on |child_id2|. | 339 // The parent should still be blocked on |child_id2|. |
| 411 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 340 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 412 UnorderedElementsAre(child_id2)); | 341 UnorderedElementsAre(child_id2)); |
| 413 | 342 |
| 414 // Submit a CompositorFrame without any dependencies to |child_id2|. | 343 // Submit a CompositorFrame without any dependencies to |child_id2|. |
| 415 // parent_support should be activated. | 344 // parent_support should be activated. |
| 416 child_support2().SubmitCompositorFrame( | 345 child_support2().SubmitCompositorFrame( |
| 417 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 346 child_id2.local_surface_id(), |
| 347 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 348 TransferableResourceArray())); |
| 418 | 349 |
| 419 EXPECT_FALSE(dependency_tracker().has_deadline()); | 350 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 420 | 351 |
| 421 // child_surface1 should now be active. | 352 // child_surface1 should now be active. |
| 422 EXPECT_TRUE(child_surface1()->HasActiveFrame()); | 353 EXPECT_TRUE(child_surface1()->HasActiveFrame()); |
| 423 EXPECT_FALSE(child_surface1()->HasPendingFrame()); | 354 EXPECT_FALSE(child_surface1()->HasPendingFrame()); |
| 424 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 355 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); |
| 425 | 356 |
| 426 // parent_surface should now be active. | 357 // parent_surface should now be active. |
| 427 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 358 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 428 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 359 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 429 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 360 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 430 } | 361 } |
| 431 | 362 |
| 432 // parent_surface is blocked on |child_id1|, and child_surface2 is blocked on | 363 // parent_surface is blocked on |child_id1|, and child_surface2 is blocked on |
| 433 // |child_id2| until the deadline hits. | 364 // |child_id2| until the deadline hits. |
| 434 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingDeadlineHits) { | 365 TEST_F(SurfaceSynchronizationTest, DeadlineHits) { |
| 435 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 366 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 436 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 367 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
| 437 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 368 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
| 438 | 369 |
| 439 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 370 parent_support().SubmitCompositorFrame( |
| 440 MakeCompositorFrame({child_id1})); | 371 parent_id.local_surface_id(), |
| 372 MakeCompositorFrame({child_id1}, {child_id1}, |
| 373 TransferableResourceArray())); |
| 441 | 374 |
| 442 // parent_support is blocked on |child_id1|. | 375 // parent_support is blocked on |child_id1|. |
| 443 EXPECT_TRUE(dependency_tracker().has_deadline()); | 376 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 444 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 377 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 445 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 378 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 446 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 379 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 447 UnorderedElementsAre(child_id1)); | 380 UnorderedElementsAre(child_id1)); |
| 448 | 381 |
| 449 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), | 382 child_support1().SubmitCompositorFrame( |
| 450 MakeCompositorFrame({child_id2})); | 383 child_id1.local_surface_id(), |
| 384 MakeCompositorFrame({child_id2}, {child_id2}, |
| 385 TransferableResourceArray())); |
| 451 | 386 |
| 452 // child_support1 should now be blocked on |child_id2|. | 387 // child_support1 should now be blocked on |child_id2|. |
| 453 EXPECT_TRUE(dependency_tracker().has_deadline()); | 388 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 454 EXPECT_FALSE(child_surface1()->HasActiveFrame()); | 389 EXPECT_FALSE(child_surface1()->HasActiveFrame()); |
| 455 EXPECT_TRUE(child_surface1()->HasPendingFrame()); | 390 EXPECT_TRUE(child_surface1()->HasPendingFrame()); |
| 456 EXPECT_THAT(child_surface1()->blocking_surfaces(), | 391 EXPECT_THAT(child_surface1()->blocking_surfaces(), |
| 457 UnorderedElementsAre(child_id2)); | 392 UnorderedElementsAre(child_id2)); |
| 458 | 393 |
| 459 // The parent should still be blocked on |child_id1| because it's pending. | 394 // The parent should still be blocked on |child_id1| because it's pending. |
| 460 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 395 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 427 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 493 | 428 |
| 494 // child_surface1 has been activated. | 429 // child_surface1 has been activated. |
| 495 EXPECT_TRUE(child_surface1()->HasActiveFrame()); | 430 EXPECT_TRUE(child_surface1()->HasActiveFrame()); |
| 496 EXPECT_FALSE(child_surface1()->HasPendingFrame()); | 431 EXPECT_FALSE(child_surface1()->HasPendingFrame()); |
| 497 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 432 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); |
| 498 } | 433 } |
| 499 | 434 |
| 500 // Verifies that the deadline does not reset if we submit CompositorFrames | 435 // Verifies that the deadline does not reset if we submit CompositorFrames |
| 501 // to new Surfaces with unresolved dependencies. | 436 // to new Surfaces with unresolved dependencies. |
| 502 TEST_F(CompositorFrameSinkSupportTest, | 437 TEST_F(SurfaceSynchronizationTest, FramesSubmittedAfterDeadlineSet) { |
| 503 DisplayCompositorLockingFramesSubmittedAfterDeadlineSet) { | |
| 504 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); | 438 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); |
| 505 BeginFrameArgs args = | 439 BeginFrameArgs args = |
| 506 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 440 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 507 for (int i = 0; i < 3; ++i) { | 441 for (int i = 0; i < 3; ++i) { |
| 508 LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); | 442 LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); |
| 509 support(i).SubmitCompositorFrame(local_surface_id, | 443 support(i).SubmitCompositorFrame( |
| 510 MakeCompositorFrame({arbitrary_id})); | 444 local_surface_id, MakeCompositorFrame({arbitrary_id}, {arbitrary_id}, |
| 445 TransferableResourceArray())); |
| 511 // The deadline has been set. | 446 // The deadline has been set. |
| 512 EXPECT_TRUE(dependency_tracker().has_deadline()); | 447 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 513 | 448 |
| 514 // support(i) should be blocked on arbitrary_id. | 449 // support(i) should be blocked on arbitrary_id. |
| 515 EXPECT_FALSE(surface(i)->HasActiveFrame()); | 450 EXPECT_FALSE(surface(i)->HasActiveFrame()); |
| 516 EXPECT_TRUE(surface(i)->HasPendingFrame()); | 451 EXPECT_TRUE(surface(i)->HasPendingFrame()); |
| 517 EXPECT_THAT(surface(i)->blocking_surfaces(), | 452 EXPECT_THAT(surface(i)->blocking_surfaces(), |
| 518 UnorderedElementsAre(arbitrary_id)); | 453 UnorderedElementsAre(arbitrary_id)); |
| 519 | 454 |
| 520 // Issue a BeginFrame to get closer to the deadline. | 455 // Issue a BeginFrame to get closer to the deadline. |
| 521 begin_frame_source()->TestOnBeginFrame(args); | 456 begin_frame_source()->TestOnBeginFrame(args); |
| 522 } | 457 } |
| 523 | 458 |
| 524 // The deadline hits and all the Surfaces should activate. | 459 // The deadline hits and all the Surfaces should activate. |
| 525 begin_frame_source()->TestOnBeginFrame(args); | 460 begin_frame_source()->TestOnBeginFrame(args); |
| 526 for (int i = 0; i < 3; ++i) { | 461 for (int i = 0; i < 3; ++i) { |
| 527 EXPECT_TRUE(surface(i)->HasActiveFrame()); | 462 EXPECT_TRUE(surface(i)->HasActiveFrame()); |
| 528 EXPECT_FALSE(surface(i)->HasPendingFrame()); | 463 EXPECT_FALSE(surface(i)->HasPendingFrame()); |
| 529 EXPECT_THAT(surface(i)->blocking_surfaces(), IsEmpty()); | 464 EXPECT_THAT(surface(i)->blocking_surfaces(), IsEmpty()); |
| 530 } | 465 } |
| 531 } | 466 } |
| 532 | 467 |
| 533 // This test verifies at the Surface activates once a CompositorFrame is | 468 // This test verifies at the Surface activates once a CompositorFrame is |
| 534 // submitted that has no unresolved dependencies. | 469 // submitted that has no unresolved dependencies. |
| 535 TEST_F(CompositorFrameSinkSupportTest, | 470 TEST_F(SurfaceSynchronizationTest, NewFrameOverridesOldDependencies) { |
| 536 DisplayCompositorLockingNewFrameOverridesOldDependencies) { | |
| 537 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 471 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 538 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); | 472 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); |
| 539 | 473 |
| 540 // Submit a CompositorFrame that depends on |arbitrary_id|. | 474 // Submit a CompositorFrame that depends on |arbitrary_id|. |
| 541 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 475 parent_support().SubmitCompositorFrame( |
| 542 MakeCompositorFrame({arbitrary_id})); | 476 parent_id.local_surface_id(), |
| 477 MakeCompositorFrame({arbitrary_id}, {arbitrary_id}, |
| 478 TransferableResourceArray())); |
| 543 | 479 |
| 544 // Verify that the CompositorFrame is blocked on |arbitrary_id|. | 480 // Verify that the CompositorFrame is blocked on |arbitrary_id|. |
| 545 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 481 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 546 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 482 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 547 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 483 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 548 UnorderedElementsAre(arbitrary_id)); | 484 UnorderedElementsAre(arbitrary_id)); |
| 549 | 485 |
| 550 // Submit a CompositorFrame that has no dependencies. | 486 // Submit a CompositorFrame that has no dependencies. |
| 551 parent_support().SubmitCompositorFrame( | 487 parent_support().SubmitCompositorFrame( |
| 552 parent_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 488 parent_id.local_surface_id(), |
| 489 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 490 TransferableResourceArray())); |
| 553 | 491 |
| 554 // Verify that the CompositorFrame has been activated. | 492 // Verify that the CompositorFrame has been activated. |
| 555 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 493 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 556 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 494 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 557 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 495 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 558 } | 496 } |
| 559 | 497 |
| 560 // This test verifies that a pending CompositorFrame does not affect surface | 498 // This test verifies that a pending CompositorFrame does not affect surface |
| 561 // references. A new surface from a child will continue to exist as a temporary | 499 // references. A new surface from a child will continue to exist as a temporary |
| 562 // reference until the parent's frame activates. | 500 // reference until the parent's frame activates. |
| 563 TEST_F(CompositorFrameSinkSupportTest, | 501 TEST_F(SurfaceSynchronizationTest, OnlyActiveFramesAffectSurfaceReferences) { |
| 564 OnlyActiveFramesAffectSurfaceReferences) { | |
| 565 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 502 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 566 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 503 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
| 567 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 504 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
| 568 | 505 |
| 569 // child_support1 submits a CompositorFrame without any dependencies. | 506 // child_support1 submits a CompositorFrame without any dependencies. |
| 570 // DidReceiveCompositorFrameAck should call on immediate activation. | 507 // DidReceiveCompositorFrameAck should call on immediate activation. |
| 571 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(1); | 508 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(1); |
| 572 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), | 509 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), |
| 573 MakeCompositorFrame()); | 510 MakeCompositorFrame()); |
| 574 testing::Mock::VerifyAndClearExpectations(&support_client_); | 511 testing::Mock::VerifyAndClearExpectations(&support_client_); |
| 575 | 512 |
| 576 // Verify that the child surface is not blocked. | 513 // Verify that the child surface is not blocked. |
| 577 EXPECT_TRUE(child_surface1()->HasActiveFrame()); | 514 EXPECT_TRUE(child_surface1()->HasActiveFrame()); |
| 578 EXPECT_FALSE(child_surface1()->HasPendingFrame()); | 515 EXPECT_FALSE(child_surface1()->HasPendingFrame()); |
| 579 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 516 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); |
| 580 | 517 |
| 581 // Verify that there's a temporary reference for |child_id1|. | 518 // Verify that there's a temporary reference for |child_id1|. |
| 582 EXPECT_TRUE(HasTemporaryReference(child_id1)); | 519 EXPECT_TRUE(HasTemporaryReference(child_id1)); |
| 583 | 520 |
| 584 // parent_support submits a CompositorFrame that depends on |child_id1| | 521 // parent_support submits a CompositorFrame that depends on |child_id1| |
| 585 // (which is already active) and |child_id2|. Thus, the parent should not | 522 // (which is already active) and |child_id2|. Thus, the parent should not |
| 586 // activate immediately. DidReceiveCompositorFrameAck should not be called | 523 // activate immediately. DidReceiveCompositorFrameAck should not be called |
| 587 // immediately because the parent CompositorFrame is also blocked on | 524 // immediately because the parent CompositorFrame is also blocked on |
| 588 // |child_id2|. | 525 // |child_id2|. |
| 589 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); | 526 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); |
| 590 parent_support().SubmitCompositorFrame( | 527 parent_support().SubmitCompositorFrame( |
| 591 parent_id.local_surface_id(), | 528 parent_id.local_surface_id(), |
| 592 MakeCompositorFrame({child_id1, child_id2})); | 529 MakeCompositorFrame({child_id1, child_id2}, {child_id1, child_id2}, |
| 530 TransferableResourceArray())); |
| 593 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 531 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 594 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 532 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 595 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 533 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 596 UnorderedElementsAre(child_id2)); | 534 UnorderedElementsAre(child_id2)); |
| 597 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty()); | 535 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty()); |
| 598 testing::Mock::VerifyAndClearExpectations(&support_client_); | 536 testing::Mock::VerifyAndClearExpectations(&support_client_); |
| 599 | 537 |
| 600 // Verify that there's a temporary reference for |child_id1| that still | 538 // Verify that there's a temporary reference for |child_id1| that still |
| 601 // exists. | 539 // exists. |
| 602 EXPECT_TRUE(HasTemporaryReference(child_id1)); | 540 EXPECT_TRUE(HasTemporaryReference(child_id1)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 620 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 558 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 621 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 559 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 622 EXPECT_FALSE(HasTemporaryReference(child_id1)); | 560 EXPECT_FALSE(HasTemporaryReference(child_id1)); |
| 623 EXPECT_THAT(GetChildReferences(parent_id), | 561 EXPECT_THAT(GetChildReferences(parent_id), |
| 624 UnorderedElementsAre(child_id1, child_id2)); | 562 UnorderedElementsAre(child_id1, child_id2)); |
| 625 } | 563 } |
| 626 | 564 |
| 627 // This test verifies that we do not double count returned resources when a | 565 // This test verifies that we do not double count returned resources when a |
| 628 // CompositorFrame starts out as pending, then becomes active, and then is | 566 // CompositorFrame starts out as pending, then becomes active, and then is |
| 629 // replaced with another active CompositorFrame. | 567 // replaced with another active CompositorFrame. |
| 630 TEST_F(CompositorFrameSinkSupportTest, | 568 TEST_F(SurfaceSynchronizationTest, ResourcesOnlyReturnedOnce) { |
| 631 DisplayCompositorLockingResourcesOnlyReturnedOnce) { | |
| 632 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 569 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 633 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 570 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 634 | 571 |
| 635 // The parent submits a CompositorFrame that depends on |child_id| before the | 572 // The parent submits a CompositorFrame that depends on |child_id| before the |
| 636 // child submits a CompositorFrame. The CompositorFrame also has resources in | 573 // child submits a CompositorFrame. The CompositorFrame also has resources in |
| 637 // its resource list. | 574 // its resource list. |
| 638 TransferableResource resource = | 575 TransferableResource resource; |
| 639 MakeResource(1337 /* id */, ALPHA_8 /* format */, 1234 /* filter */, | 576 resource.id = 1337; |
| 640 gfx::Size(1234, 5678)); | 577 resource.format = ALPHA_8; |
| 578 resource.filter = 1234; |
| 579 resource.size = gfx::Size(1234, 5678); |
| 641 TransferableResourceArray resource_list = {resource}; | 580 TransferableResourceArray resource_list = {resource}; |
| 642 parent_support().SubmitCompositorFrame( | 581 parent_support().SubmitCompositorFrame( |
| 643 parent_id.local_surface_id(), | 582 parent_id.local_surface_id(), |
| 644 MakeCompositorFrameWithResources({child_id}, resource_list)); | 583 MakeCompositorFrame({child_id}, {child_id}, resource_list)); |
| 645 | 584 |
| 646 // Verify that the CompositorFrame is blocked on |child_id|. | 585 // Verify that the CompositorFrame is blocked on |child_id|. |
| 647 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 586 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 648 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 587 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 649 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 588 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 650 UnorderedElementsAre(child_id)); | 589 UnorderedElementsAre(child_id)); |
| 651 | 590 |
| 652 child_support1().SubmitCompositorFrame( | 591 child_support1().SubmitCompositorFrame( |
| 653 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 592 child_id.local_surface_id(), |
| 593 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 594 TransferableResourceArray())); |
| 654 | 595 |
| 655 // Verify that the child CompositorFrame activates immediately. | 596 // Verify that the child CompositorFrame activates immediately. |
| 656 EXPECT_TRUE(child_surface1()->HasActiveFrame()); | 597 EXPECT_TRUE(child_surface1()->HasActiveFrame()); |
| 657 EXPECT_FALSE(child_surface1()->HasPendingFrame()); | 598 EXPECT_FALSE(child_surface1()->HasPendingFrame()); |
| 658 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 599 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); |
| 659 | 600 |
| 660 // Verify that the parent has activated. | 601 // Verify that the parent has activated. |
| 661 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 602 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 662 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 603 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 663 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 604 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 664 | 605 |
| 606 ReturnedResourceArray returned_resources = {resource.ToReturnedResource()}; |
| 607 EXPECT_CALL(support_client_, |
| 608 DidReceiveCompositorFrameAck(returned_resources)); |
| 609 |
| 665 // The parent submits a CompositorFrame without any dependencies. That frame | 610 // The parent submits a CompositorFrame without any dependencies. That frame |
| 666 // should activate immediately, replacing the earlier frame. The resource from | 611 // should activate immediately, replacing the earlier frame. The resource from |
| 667 // the earlier frame should be returned to the client. | 612 // the earlier frame should be returned to the client. |
| 668 parent_support().SubmitCompositorFrame( | 613 parent_support().SubmitCompositorFrame( |
| 669 parent_id.local_surface_id(), MakeCompositorFrame({empty_surface_ids()})); | 614 parent_id.local_surface_id(), |
| 615 MakeCompositorFrame({empty_surface_ids()}, {empty_surface_ids()}, |
| 616 TransferableResourceArray())); |
| 670 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 617 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 671 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 618 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 672 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 619 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 673 ReturnedResource returned_resource = resource.ToReturnedResource(); | |
| 674 EXPECT_THAT(support_client_.last_returned_resources(), | |
| 675 UnorderedElementsAre(returned_resource)); | |
| 676 } | 620 } |
| 677 | 621 |
| 678 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. | 622 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. |
| 679 // child_support1 evicts its blocked Surface. The parent surface should | 623 // child_support1 evicts its blocked Surface. The parent surface should |
| 680 // activate. | 624 // activate. |
| 681 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { | 625 TEST_F(SurfaceSynchronizationTest, EvictSurfaceWithPendingFrame) { |
| 682 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 626 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 683 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 627 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
| 684 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 628 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
| 685 | 629 |
| 686 // Submit a CompositorFrame that depends on |child_id1|. | 630 // Submit a CompositorFrame that depends on |child_id1|. |
| 687 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 631 parent_support().SubmitCompositorFrame( |
| 688 MakeCompositorFrame({child_id1})); | 632 parent_id1.local_surface_id(), |
| 633 MakeCompositorFrame({child_id1}, {child_id1}, |
| 634 TransferableResourceArray())); |
| 689 | 635 |
| 690 // Verify that the CompositorFrame is blocked on |child_id1|. | 636 // Verify that the CompositorFrame is blocked on |child_id1|. |
| 691 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 637 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 692 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 638 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 693 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 639 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 694 UnorderedElementsAre(child_id1)); | 640 UnorderedElementsAre(child_id1)); |
| 695 | 641 |
| 696 // Submit a CompositorFrame that depends on |child_id2|. | 642 // Submit a CompositorFrame that depends on |child_id2|. |
| 697 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), | 643 child_support1().SubmitCompositorFrame( |
| 698 MakeCompositorFrame({child_id2})); | 644 child_id1.local_surface_id(), |
| 645 MakeCompositorFrame({child_id2}, {child_id2}, |
| 646 TransferableResourceArray())); |
| 699 | 647 |
| 700 // Verify that the CompositorFrame is blocked on |child_id2|. | 648 // Verify that the CompositorFrame is blocked on |child_id2|. |
| 701 EXPECT_FALSE(child_surface1()->HasActiveFrame()); | 649 EXPECT_FALSE(child_surface1()->HasActiveFrame()); |
| 702 EXPECT_TRUE(child_surface1()->HasPendingFrame()); | 650 EXPECT_TRUE(child_surface1()->HasPendingFrame()); |
| 703 EXPECT_THAT(child_surface1()->blocking_surfaces(), | 651 EXPECT_THAT(child_surface1()->blocking_surfaces(), |
| 704 UnorderedElementsAre(child_id2)); | 652 UnorderedElementsAre(child_id2)); |
| 705 | 653 |
| 706 // Evict child_support1's current Surface. | 654 // Evict child_support1's current Surface. |
| 707 // TODO(fsamuel): EvictFrame => EvictCurrentSurface. | 655 // TODO(fsamuel): EvictFrame => EvictCurrentSurface. |
| 708 child_support1().EvictFrame(); | 656 child_support1().EvictFrame(); |
| 709 | 657 |
| 710 // The parent Surface should immediately activate. | 658 // The parent Surface should immediately activate. |
| 711 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 659 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 712 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 660 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 713 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 661 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 714 EXPECT_FALSE(dependency_tracker().has_deadline()); | 662 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 715 } | 663 } |
| 716 | 664 |
| 717 // This test verifies that if a surface has both a pending and active | 665 // This test verifies that if a surface has both a pending and active |
| 718 // CompositorFrame and the pending CompositorFrame activates, replacing the | 666 // CompositorFrame and the pending CompositorFrame activates, replacing the |
| 719 // existing active CompositorFrame, then the surface reference hierarchy will be | 667 // existing active CompositorFrame, then the surface reference hierarchy will be |
| 720 // updated allowing garbage collection of surfaces that are no longer | 668 // updated allowing garbage collection of surfaces that are no longer |
| 721 // referenced. | 669 // referenced. |
| 722 TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) { | 670 TEST_F(SurfaceSynchronizationTest, DropStaleReferencesAfterActivation) { |
| 723 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 671 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 724 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 672 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
| 725 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 673 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); |
| 726 | 674 |
| 727 // The parent submits a CompositorFrame that depends on |child_id1| before the | 675 // The parent submits a CompositorFrame that depends on |child_id1| before the |
| 728 // child submits a CompositorFrame. | 676 // child submits a CompositorFrame. |
| 729 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); | 677 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); |
| 730 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 678 parent_support().SubmitCompositorFrame( |
| 731 MakeCompositorFrame({child_id1})); | 679 parent_id.local_surface_id(), |
| 680 MakeCompositorFrame({child_id1}, {child_id1}, |
| 681 TransferableResourceArray())); |
| 732 | 682 |
| 733 // Verify that the CompositorFrame is blocked on |child_id|. | 683 // Verify that the CompositorFrame is blocked on |child_id|. |
| 734 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 684 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 735 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 685 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 736 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 686 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 737 UnorderedElementsAre(child_id1)); | 687 UnorderedElementsAre(child_id1)); |
| 738 testing::Mock::VerifyAndClearExpectations(&support_client_); | 688 testing::Mock::VerifyAndClearExpectations(&support_client_); |
| 739 | 689 |
| 740 // Verify that no references are added while the CompositorFrame is pending. | 690 // Verify that no references are added while the CompositorFrame is pending. |
| 741 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty()); | 691 EXPECT_THAT(GetChildReferences(parent_id), IsEmpty()); |
| 742 | 692 |
| 743 // DidReceiveCompositorFrameAck should get called twice: once for the child | 693 // DidReceiveCompositorFrameAck should get called twice: once for the child |
| 744 // and once for the now active parent CompositorFrame. | 694 // and once for the now active parent CompositorFrame. |
| 745 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(2); | 695 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(2); |
| 746 child_support1().SubmitCompositorFrame( | 696 child_support1().SubmitCompositorFrame( |
| 747 child_id1.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 697 child_id1.local_surface_id(), |
| 698 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 699 TransferableResourceArray())); |
| 748 testing::Mock::VerifyAndClearExpectations(&support_client_); | 700 testing::Mock::VerifyAndClearExpectations(&support_client_); |
| 749 | 701 |
| 750 // Verify that the child CompositorFrame activates immediately. | 702 // Verify that the child CompositorFrame activates immediately. |
| 751 EXPECT_TRUE(child_surface1()->HasActiveFrame()); | 703 EXPECT_TRUE(child_surface1()->HasActiveFrame()); |
| 752 EXPECT_FALSE(child_surface1()->HasPendingFrame()); | 704 EXPECT_FALSE(child_surface1()->HasPendingFrame()); |
| 753 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 705 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); |
| 754 | 706 |
| 755 // Verify that the parent Surface has activated. | 707 // Verify that the parent Surface has activated. |
| 756 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 708 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 757 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 709 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 758 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 710 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 759 | 711 |
| 760 // Verify that there is no temporary reference for the child and that | 712 // Verify that there is no temporary reference for the child and that |
| 761 // the reference from the parent to the child still exists. | 713 // the reference from the parent to the child still exists. |
| 762 EXPECT_FALSE(HasTemporaryReference(child_id1)); | 714 EXPECT_FALSE(HasTemporaryReference(child_id1)); |
| 763 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1)); | 715 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1)); |
| 764 | 716 |
| 765 // The parent submits another CompositorFrame that depends on |child_id2|. | 717 // The parent submits another CompositorFrame that depends on |child_id2|. |
| 766 // Submitting a pending CompositorFrame will not trigger a CompositorFrameAck. | 718 // Submitting a pending CompositorFrame will not trigger a CompositorFrameAck. |
| 767 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); | 719 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); |
| 768 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 720 parent_support().SubmitCompositorFrame( |
| 769 MakeCompositorFrame({child_id2})); | 721 parent_id.local_surface_id(), |
| 722 MakeCompositorFrame({child_id2}, {child_id2}, |
| 723 TransferableResourceArray())); |
| 770 testing::Mock::VerifyAndClearExpectations(&support_client_); | 724 testing::Mock::VerifyAndClearExpectations(&support_client_); |
| 771 | 725 |
| 772 // The parent surface should now have both a pending and activate | 726 // The parent surface should now have both a pending and activate |
| 773 // CompositorFrame. Verify that the set of child references from | 727 // CompositorFrame. Verify that the set of child references from |
| 774 // |parent_id| are only from the active CompositorFrame. | 728 // |parent_id| are only from the active CompositorFrame. |
| 775 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 729 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 776 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 730 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 777 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 731 EXPECT_THAT(parent_surface()->blocking_surfaces(), |
| 778 UnorderedElementsAre(child_id2)); | 732 UnorderedElementsAre(child_id2)); |
| 779 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1)); | 733 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1)); |
| 780 | 734 |
| 781 child_support2().SubmitCompositorFrame( | 735 child_support2().SubmitCompositorFrame( |
| 782 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 736 child_id2.local_surface_id(), |
| 737 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 738 TransferableResourceArray())); |
| 783 | 739 |
| 784 // Verify that the parent Surface has activated and no longer has a pending | 740 // Verify that the parent Surface has activated and no longer has a pending |
| 785 // CompositorFrame. Also verify that |child_id1| is no longer a child | 741 // CompositorFrame. Also verify that |child_id1| is no longer a child |
| 786 // reference of |parent_id|. | 742 // reference of |parent_id|. |
| 787 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 743 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 788 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 744 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 789 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 745 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); |
| 790 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2)); | 746 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2)); |
| 791 } | 747 } |
| 792 | 748 |
| 793 // Checks whether the latency info are moved to the new surface from the old | 749 // Checks whether the latency info are moved to the new surface from the old |
| 794 // one when LocalSurfaceId changes. No frame has unresolved dependencies. | 750 // one when LocalSurfaceId changes. No frame has unresolved dependencies. |
| 795 TEST_F(CompositorFrameSinkSupportTest, | 751 TEST_F(SurfaceSynchronizationTest, |
| 796 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) { | 752 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) { |
| 797 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 753 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 798 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 754 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 799 const ui::LatencyComponentType latency_type1 = | 755 const ui::LatencyComponentType latency_type1 = |
| 800 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 756 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; |
| 801 const int64_t latency_id1 = 234; | 757 const int64_t latency_id1 = 234; |
| 802 const int64_t latency_sequence_number1 = 5645432; | 758 const int64_t latency_sequence_number1 = 5645432; |
| 803 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 759 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; |
| 804 const int64_t latency_id2 = 31434351; | 760 const int64_t latency_id2 = 31434351; |
| 805 const int64_t latency_sequence_number2 = 663788; | 761 const int64_t latency_sequence_number2 = 663788; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 811 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 856 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 812 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 857 EXPECT_TRUE( | 813 EXPECT_TRUE( |
| 858 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 814 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 859 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 815 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 860 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 816 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 861 } | 817 } |
| 862 | 818 |
| 863 // Checks whether the latency info are moved to the new surface from the old | 819 // Checks whether the latency info are moved to the new surface from the old |
| 864 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. | 820 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. |
| 865 TEST_F(CompositorFrameSinkSupportTest, | 821 TEST_F(SurfaceSynchronizationTest, |
| 866 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { | 822 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { |
| 867 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 823 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 868 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 824 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 869 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 825 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 870 | 826 |
| 871 const ui::LatencyComponentType latency_type1 = | 827 const ui::LatencyComponentType latency_type1 = |
| 872 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 828 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; |
| 873 const int64_t latency_id1 = 234; | 829 const int64_t latency_id1 = 234; |
| 874 const int64_t latency_sequence_number1 = 5645432; | 830 const int64_t latency_sequence_number1 = 5645432; |
| 875 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 831 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; |
| 876 const int64_t latency_id2 = 31434351; | 832 const int64_t latency_id2 = 31434351; |
| 877 const int64_t latency_sequence_number2 = 663788; | 833 const int64_t latency_sequence_number2 = 663788; |
| 878 | 834 |
| 879 // Submit a frame with no unresolved dependecy. | 835 // Submit a frame with no unresolved dependecy. |
| 880 ui::LatencyInfo info; | 836 ui::LatencyInfo info; |
| 881 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); | 837 info.AddLatencyNumber(latency_type1, latency_id1, latency_sequence_number1); |
| 882 | 838 |
| 883 CompositorFrame frame = MakeCompositorFrame(); | 839 CompositorFrame frame = MakeCompositorFrame(); |
| 884 frame.metadata.latency_info.push_back(info); | 840 frame.metadata.latency_info.push_back(info); |
| 885 | 841 |
| 886 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 842 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), |
| 887 std::move(frame)); | 843 std::move(frame)); |
| 888 | 844 |
| 889 // Submit a frame with unresolved dependencies. | 845 // Submit a frame with unresolved dependencies. |
| 890 ui::LatencyInfo info2; | 846 ui::LatencyInfo info2; |
| 891 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); | 847 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); |
| 892 | 848 |
| 893 CompositorFrame frame2 = MakeCompositorFrame({child_id}); | 849 CompositorFrame frame2 = |
| 850 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray()); |
| 894 frame2.metadata.latency_info.push_back(info2); | 851 frame2.metadata.latency_info.push_back(info2); |
| 895 | 852 |
| 896 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 853 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), |
| 897 std::move(frame2)); | 854 std::move(frame2)); |
| 898 | 855 |
| 899 // Verify that the old surface has both an active and a pending frame. | 856 // Verify that the old surface has both an active and a pending frame. |
| 900 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); | 857 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); |
| 901 ASSERT_NE(nullptr, old_surface); | 858 ASSERT_NE(nullptr, old_surface); |
| 902 EXPECT_TRUE(old_surface->HasActiveFrame()); | 859 EXPECT_TRUE(old_surface->HasActiveFrame()); |
| 903 EXPECT_TRUE(old_surface->HasPendingFrame()); | 860 EXPECT_TRUE(old_surface->HasPendingFrame()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 931 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 888 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 932 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 889 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 933 EXPECT_TRUE( | 890 EXPECT_TRUE( |
| 934 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 891 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 935 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 892 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 936 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 893 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 937 } | 894 } |
| 938 | 895 |
| 939 // Checks whether the latency info are moved to the new surface from the old | 896 // Checks whether the latency info are moved to the new surface from the old |
| 940 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. | 897 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. |
| 941 TEST_F(CompositorFrameSinkSupportTest, | 898 TEST_F(SurfaceSynchronizationTest, |
| 942 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { | 899 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { |
| 943 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 900 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 944 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 901 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 945 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 902 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 946 | 903 |
| 947 const ui::LatencyComponentType latency_type1 = | 904 const ui::LatencyComponentType latency_type1 = |
| 948 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 905 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; |
| 949 const int64_t latency_id1 = 234; | 906 const int64_t latency_id1 = 234; |
| 950 const int64_t latency_sequence_number1 = 5645432; | 907 const int64_t latency_sequence_number1 = 5645432; |
| 951 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 908 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 966 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); | 923 Surface* old_surface = surface_manager().GetSurfaceForId(parent_id1); |
| 967 ASSERT_NE(nullptr, old_surface); | 924 ASSERT_NE(nullptr, old_surface); |
| 968 EXPECT_TRUE(old_surface->HasActiveFrame()); | 925 EXPECT_TRUE(old_surface->HasActiveFrame()); |
| 969 EXPECT_FALSE(old_surface->HasPendingFrame()); | 926 EXPECT_FALSE(old_surface->HasPendingFrame()); |
| 970 | 927 |
| 971 // Submit a frame with a new local surface id and with unresolved | 928 // Submit a frame with a new local surface id and with unresolved |
| 972 // dependencies. | 929 // dependencies. |
| 973 ui::LatencyInfo info2; | 930 ui::LatencyInfo info2; |
| 974 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); | 931 info2.AddLatencyNumber(latency_type2, latency_id2, latency_sequence_number2); |
| 975 | 932 |
| 976 CompositorFrame frame2 = MakeCompositorFrame({child_id}); | 933 CompositorFrame frame2 = |
| 934 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray()); |
| 977 frame2.metadata.latency_info.push_back(info2); | 935 frame2.metadata.latency_info.push_back(info2); |
| 978 | 936 |
| 979 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), | 937 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), |
| 980 std::move(frame2)); | 938 std::move(frame2)); |
| 981 | 939 |
| 982 // Verify that the new surface has a pending frame and no active frame. | 940 // Verify that the new surface has a pending frame and no active frame. |
| 983 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); | 941 Surface* surface = surface_manager().GetSurfaceForId(parent_id2); |
| 984 ASSERT_NE(nullptr, surface); | 942 ASSERT_NE(nullptr, surface); |
| 985 EXPECT_TRUE(surface->HasPendingFrame()); | 943 EXPECT_TRUE(surface->HasPendingFrame()); |
| 986 EXPECT_FALSE(surface->HasActiveFrame()); | 944 EXPECT_FALSE(surface->HasActiveFrame()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1008 ui::LatencyInfo::LatencyComponent comp1; | 966 ui::LatencyInfo::LatencyComponent comp1; |
| 1009 EXPECT_TRUE( | 967 EXPECT_TRUE( |
| 1010 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 968 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); |
| 1011 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 969 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); |
| 1012 EXPECT_TRUE( | 970 EXPECT_TRUE( |
| 1013 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 971 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); |
| 1014 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 972 EXPECT_TRUE(aggregated_latency_info.FindLatency( |
| 1015 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 973 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); |
| 1016 } | 974 } |
| 1017 | 975 |
| 1018 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { | 976 TEST_F(SurfaceSynchronizationTest, PassesOnBeginFrameAcks) { |
| 1019 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 977 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
| 1020 | 978 |
| 1021 // Request BeginFrames. | 979 // Request BeginFrames. |
| 1022 display_support().SetNeedsBeginFrame(true); | 980 display_support().SetNeedsBeginFrame(true); |
| 1023 | 981 |
| 1024 // Issue a BeginFrame. | 982 // Issue a BeginFrame. |
| 1025 BeginFrameArgs args = | 983 BeginFrameArgs args = |
| 1026 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 984 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 1027 begin_frame_source()->TestOnBeginFrame(args); | 985 begin_frame_source()->TestOnBeginFrame(args); |
| 1028 | 986 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1040 // to a CompositorFrame to the BeginFrameSource. | 998 // to a CompositorFrame to the BeginFrameSource. |
| 1041 BeginFrameAck ack2(0, 2, 2, true); | 999 BeginFrameAck ack2(0, 2, 2, true); |
| 1042 CompositorFrame frame = MakeCompositorFrame(); | 1000 CompositorFrame frame = MakeCompositorFrame(); |
| 1043 frame.metadata.begin_frame_ack = ack2; | 1001 frame.metadata.begin_frame_ack = ack2; |
| 1044 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1002 display_support().SubmitCompositorFrame(display_id.local_surface_id(), |
| 1045 std::move(frame)); | 1003 std::move(frame)); |
| 1046 EXPECT_EQ(ack2, begin_frame_source()->LastAckForObserver(&display_support())); | 1004 EXPECT_EQ(ack2, begin_frame_source()->LastAckForObserver(&display_support())); |
| 1047 } | 1005 } |
| 1048 | 1006 |
| 1049 // Checks that resources and ack are sent together if possible. | 1007 // Checks that resources and ack are sent together if possible. |
| 1050 TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesWithAck) { | 1008 TEST_F(SurfaceSynchronizationTest, ReturnResourcesWithAck) { |
| 1051 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1009 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 1052 TransferableResource resource; | 1010 TransferableResource resource; |
| 1053 resource.id = 1234; | 1011 resource.id = 1234; |
| 1054 parent_support().SubmitCompositorFrame( | 1012 parent_support().SubmitCompositorFrame( |
| 1055 parent_id.local_surface_id(), | 1013 parent_id.local_surface_id(), |
| 1056 MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); | 1014 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 1015 {resource})); |
| 1057 ReturnedResourceArray returned_resources; | 1016 ReturnedResourceArray returned_resources; |
| 1058 TransferableResource::ReturnResources({resource}, &returned_resources); | 1017 TransferableResource::ReturnResources({resource}, &returned_resources); |
| 1059 EXPECT_CALL(support_client_, ReclaimResources(_)).Times(0); | 1018 EXPECT_CALL(support_client_, ReclaimResources(_)).Times(0); |
| 1060 EXPECT_CALL(support_client_, | 1019 EXPECT_CALL(support_client_, |
| 1061 DidReceiveCompositorFrameAck(Eq(returned_resources))); | 1020 DidReceiveCompositorFrameAck(Eq(returned_resources))); |
| 1062 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1021 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
| 1063 MakeCompositorFrame()); | 1022 MakeCompositorFrame()); |
| 1064 } | 1023 } |
| 1065 | 1024 |
| 1066 // Verifies that if a surface is marked destroyed and a new frame arrives for | 1025 // Verifies that if a surface is marked destroyed and a new frame arrives for |
| 1067 // it, it will be recovered. | 1026 // it, it will be recovered. |
| 1068 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { | 1027 TEST_F(SurfaceSynchronizationTest, SurfaceResurrection) { |
| 1069 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1028 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 1070 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); | 1029 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); |
| 1071 | 1030 |
| 1072 // Add a reference from the parent to the child. | 1031 // Add a reference from the parent to the child. |
| 1073 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1032 parent_support().SubmitCompositorFrame( |
| 1074 MakeCompositorFrame({child_id})); | 1033 parent_id.local_surface_id(), |
| 1034 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
| 1075 | 1035 |
| 1076 // Create the child surface by submitting a frame to it. | 1036 // Create the child surface by submitting a frame to it. |
| 1077 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1037 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1078 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1038 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1079 MakeCompositorFrame()); | 1039 MakeCompositorFrame()); |
| 1080 | 1040 |
| 1081 // Verify that the child surface is created. | 1041 // Verify that the child surface is created. |
| 1082 Surface* surface = surface_manager().GetSurfaceForId(child_id); | 1042 Surface* surface = surface_manager().GetSurfaceForId(child_id); |
| 1083 EXPECT_NE(nullptr, surface); | 1043 EXPECT_NE(nullptr, surface); |
| 1084 | 1044 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1096 | 1056 |
| 1097 // Verify that the surface that was marked destroyed is recovered and is being | 1057 // Verify that the surface that was marked destroyed is recovered and is being |
| 1098 // used again. | 1058 // used again. |
| 1099 Surface* surface2 = surface_manager().GetSurfaceForId(child_id); | 1059 Surface* surface2 = surface_manager().GetSurfaceForId(child_id); |
| 1100 EXPECT_EQ(surface, surface2); | 1060 EXPECT_EQ(surface, surface2); |
| 1101 EXPECT_FALSE(surface2->destroyed()); | 1061 EXPECT_FALSE(surface2->destroyed()); |
| 1102 } | 1062 } |
| 1103 | 1063 |
| 1104 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist | 1064 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist |
| 1105 // anymore, it can still be reused for new surfaces. | 1065 // anymore, it can still be reused for new surfaces. |
| 1106 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { | 1066 TEST_F(SurfaceSynchronizationTest, LocalSurfaceIdIsReusable) { |
| 1107 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1067 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 1108 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); | 1068 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); |
| 1109 | 1069 |
| 1110 // Add a reference from parent. | 1070 // Add a reference from parent. |
| 1111 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1071 parent_support().SubmitCompositorFrame( |
| 1112 MakeCompositorFrame({child_id})); | 1072 parent_id.local_surface_id(), |
| 1073 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
| 1113 | 1074 |
| 1114 // Submit the first frame. Creates the surface. | 1075 // Submit the first frame. Creates the surface. |
| 1115 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1076 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1116 MakeCompositorFrame()); | 1077 MakeCompositorFrame()); |
| 1117 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1078 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1118 | 1079 |
| 1119 // Remove the reference from parant. This allows us to destroy the surface. | 1080 // Remove the reference from parant. This allows us to destroy the surface. |
| 1120 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1081 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
| 1121 MakeCompositorFrame()); | 1082 MakeCompositorFrame()); |
| 1122 | 1083 |
| 1123 // Destroy the surface. | 1084 // Destroy the surface. |
| 1124 child_support1().EvictFrame(); | 1085 child_support1().EvictFrame(); |
| 1125 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1086 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1126 | 1087 |
| 1127 // Submit another frame with the same local surface id. This should work fine | 1088 // Submit another frame with the same local surface id. This should work fine |
| 1128 // and a new surface must be created. | 1089 // and a new surface must be created. |
| 1129 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1090 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), |
| 1130 MakeCompositorFrame()); | 1091 MakeCompositorFrame()); |
| 1131 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1092 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); |
| 1132 } | 1093 } |
| 1133 | 1094 |
| 1134 // This test verifies that a crash does not occur if garbage collection is | 1095 // This test verifies that a crash does not occur if garbage collection is |
| 1135 // triggered during surface dependency resolution. This test triggers garbage | 1096 // triggered during surface dependency resolution. This test triggers garbage |
| 1136 // collection during surface resolution, by causing an activation to remove | 1097 // collection during surface resolution, by causing an activation to remove |
| 1137 // a surface subtree from the root. Both the old subtree and the new | 1098 // a surface subtree from the root. Both the old subtree and the new |
| 1138 // activated subtree refer to the same dependency. The old subtree was activated | 1099 // activated subtree refer to the same dependency. The old subtree was activated |
| 1139 // by deadline, and the new subtree was activated by a dependency finally | 1100 // by deadline, and the new subtree was activated by a dependency finally |
| 1140 // resolving. | 1101 // resolving. |
| 1141 TEST_F(CompositorFrameSinkSupportTest, DependencyTrackingGarbageCollection) { | 1102 TEST_F(SurfaceSynchronizationTest, DependencyTrackingGarbageCollection) { |
| 1142 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 1103 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
| 1143 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1104 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 1144 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 1105 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 1145 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 1106 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 1146 | 1107 |
| 1147 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 1108 parent_support().SubmitCompositorFrame( |
| 1148 MakeCompositorFrame({child_id})); | 1109 parent_id1.local_surface_id(), |
| 1149 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1110 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
| 1150 MakeCompositorFrame({parent_id1})); | 1111 display_support().SubmitCompositorFrame( |
| 1112 display_id.local_surface_id(), |
| 1113 MakeCompositorFrame({parent_id1}, {parent_id1}, |
| 1114 TransferableResourceArray())); |
| 1151 | 1115 |
| 1152 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1116 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1153 | 1117 |
| 1154 BeginFrameArgs args = | 1118 BeginFrameArgs args = |
| 1155 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 1119 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 1156 | 1120 |
| 1157 // Advance BeginFrames to trigger a deadline. | 1121 // Advance BeginFrames to trigger a deadline. |
| 1158 for (int i = 0; i < 3; ++i) { | 1122 for (int i = 0; i < 3; ++i) { |
| 1159 begin_frame_source()->TestOnBeginFrame(args); | 1123 begin_frame_source()->TestOnBeginFrame(args); |
| 1160 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1124 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1161 } | 1125 } |
| 1162 begin_frame_source()->TestOnBeginFrame(args); | 1126 begin_frame_source()->TestOnBeginFrame(args); |
| 1163 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1127 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 1164 | 1128 |
| 1165 EXPECT_TRUE(display_surface()->HasActiveFrame()); | 1129 EXPECT_TRUE(display_surface()->HasActiveFrame()); |
| 1166 EXPECT_FALSE(display_surface()->HasPendingFrame()); | 1130 EXPECT_FALSE(display_surface()->HasPendingFrame()); |
| 1167 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 1131 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 1168 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1132 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 1169 | 1133 |
| 1170 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), | 1134 parent_support().SubmitCompositorFrame( |
| 1171 MakeCompositorFrame({child_id})); | 1135 parent_id2.local_surface_id(), |
| 1172 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1136 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
| 1173 MakeCompositorFrame({parent_id2})); | 1137 display_support().SubmitCompositorFrame( |
| 1138 display_id.local_surface_id(), |
| 1139 MakeCompositorFrame({parent_id2}, {parent_id2}, |
| 1140 TransferableResourceArray())); |
| 1174 | 1141 |
| 1175 // The display surface now has two CompositorFrames. One that is pending, | 1142 // The display surface now has two CompositorFrames. One that is pending, |
| 1176 // indirectly blocked on child_id and one that is active, also indirectly | 1143 // indirectly blocked on child_id and one that is active, also indirectly |
| 1177 // referring to child_id, but activated due to the deadline above. | 1144 // referring to child_id, but activated due to the deadline above. |
| 1178 EXPECT_TRUE(display_surface()->HasActiveFrame()); | 1145 EXPECT_TRUE(display_surface()->HasActiveFrame()); |
| 1179 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 1146 EXPECT_TRUE(display_surface()->HasPendingFrame()); |
| 1180 | 1147 |
| 1181 // Submitting a CompositorFrame will trigger garbage collection of the | 1148 // Submitting a CompositorFrame will trigger garbage collection of the |
| 1182 // |parent_id1| subtree. This should not crash. | 1149 // |parent_id1| subtree. This should not crash. |
| 1183 child_support1().SubmitCompositorFrame( | 1150 child_support1().SubmitCompositorFrame( |
| 1184 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 1151 child_id.local_surface_id(), |
| 1152 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
| 1153 TransferableResourceArray())); |
| 1185 } | 1154 } |
| 1186 | 1155 |
| 1187 // This test verifies that a crash does not occur if garbage collection is | 1156 // This test verifies that a crash does not occur if garbage collection is |
| 1188 // triggered when a deadline forces frame activation. This test triggers garbage | 1157 // triggered when a deadline forces frame activation. This test triggers garbage |
| 1189 // collection during deadline activation by causing the activation of a display | 1158 // collection during deadline activation by causing the activation of a display |
| 1190 // frame to replace a previously activated display frame that was referring to | 1159 // frame to replace a previously activated display frame that was referring to |
| 1191 // a now-unreachable surface subtree. That subtree gets garbage collected during | 1160 // a now-unreachable surface subtree. That subtree gets garbage collected during |
| 1192 // deadline activation. SurfaceDependencyTracker is also tracking a surface | 1161 // deadline activation. SurfaceDependencyTracker is also tracking a surface |
| 1193 // from that subtree due to an unresolved dependency. This test verifies that | 1162 // from that subtree due to an unresolved dependency. This test verifies that |
| 1194 // this dependency resolution does not crash. | 1163 // this dependency resolution does not crash. |
| 1195 TEST_F(CompositorFrameSinkSupportTest, GarbageCollectionOnDeadline) { | 1164 TEST_F(SurfaceSynchronizationTest, GarbageCollectionOnDeadline) { |
| 1196 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 1165 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
| 1197 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1166 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 1198 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 1167 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 1199 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 1168 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 1200 | 1169 |
| 1201 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1170 display_support().SubmitCompositorFrame( |
| 1202 MakeCompositorFrame({parent_id1})); | 1171 display_id.local_surface_id(), |
| 1172 MakeCompositorFrame({parent_id1}, {parent_id1}, |
| 1173 TransferableResourceArray())); |
| 1203 | 1174 |
| 1204 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 1175 EXPECT_TRUE(display_surface()->HasPendingFrame()); |
| 1205 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1176 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1206 EXPECT_FALSE(display_surface()->HasActiveFrame()); | 1177 EXPECT_FALSE(display_surface()->HasActiveFrame()); |
| 1207 | 1178 |
| 1208 // Advance BeginFrames to trigger a deadline. This activates the | 1179 // Advance BeginFrames to trigger a deadline. This activates the |
| 1209 // CompositorFrame submitted above. | 1180 // CompositorFrame submitted above. |
| 1210 BeginFrameArgs args = | 1181 BeginFrameArgs args = |
| 1211 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 1182 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 1212 for (int i = 0; i < 3; ++i) { | 1183 for (int i = 0; i < 3; ++i) { |
| 1213 begin_frame_source()->TestOnBeginFrame(args); | 1184 begin_frame_source()->TestOnBeginFrame(args); |
| 1214 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1185 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1215 } | 1186 } |
| 1216 begin_frame_source()->TestOnBeginFrame(args); | 1187 begin_frame_source()->TestOnBeginFrame(args); |
| 1217 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1188 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 1218 EXPECT_FALSE(display_surface()->HasPendingFrame()); | 1189 EXPECT_FALSE(display_surface()->HasPendingFrame()); |
| 1219 EXPECT_TRUE(display_surface()->HasActiveFrame()); | 1190 EXPECT_TRUE(display_surface()->HasActiveFrame()); |
| 1220 | 1191 |
| 1221 // |parent_id1| is blocked on |child_id|, but |display_id|'s CompositorFrame | 1192 // |parent_id1| is blocked on |child_id|, but |display_id|'s CompositorFrame |
| 1222 // has activated due to a deadline. |parent_id1| will be tracked by the | 1193 // has activated due to a deadline. |parent_id1| will be tracked by the |
| 1223 // SurfaceDependencyTracker. | 1194 // SurfaceDependencyTracker. |
| 1224 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 1195 parent_support().SubmitCompositorFrame( |
| 1225 MakeCompositorFrame({child_id})); | 1196 parent_id1.local_surface_id(), |
| 1197 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
| 1226 | 1198 |
| 1227 // By submitting a display CompositorFrame, and replacing the parent's | 1199 // By submitting a display CompositorFrame, and replacing the parent's |
| 1228 // CompositorFrame with another surface ID, parent_id1 becomes unreachable and | 1200 // CompositorFrame with another surface ID, parent_id1 becomes unreachable and |
| 1229 // a candidate for garbage collection. | 1201 // a candidate for garbage collection. |
| 1230 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1202 display_support().SubmitCompositorFrame( |
| 1231 MakeCompositorFrame({parent_id2})); | 1203 display_id.local_surface_id(), |
| 1204 MakeCompositorFrame({parent_id2}, {parent_id2}, |
| 1205 TransferableResourceArray())); |
| 1232 | 1206 |
| 1233 // Now |parent_id1| is only kept alive by the active |display_id| frame. | 1207 // Now |parent_id1| is only kept alive by the active |display_id| frame. |
| 1234 parent_support().SubmitCompositorFrame(parent_id2.local_surface_id(), | 1208 parent_support().SubmitCompositorFrame( |
| 1235 MakeCompositorFrame({child_id})); | 1209 parent_id2.local_surface_id(), |
| 1210 MakeCompositorFrame({child_id}, {child_id}, TransferableResourceArray())); |
| 1236 | 1211 |
| 1237 // SurfaceDependencyTracker should now be tracking |display_id|, |parent_id1| | 1212 // SurfaceDependencyTracker should now be tracking |display_id|, |parent_id1| |
| 1238 // and |parent_id2|. By activating the pending |display_id| frame by deadline, | 1213 // and |parent_id2|. By activating the pending |display_id| frame by deadline, |
| 1239 // |parent_id1| becomes unreachable and is garbage collected while | 1214 // |parent_id1| becomes unreachable and is garbage collected while |
| 1240 // SurfaceDependencyTracker is in the process of activating surfaces. This | 1215 // SurfaceDependencyTracker is in the process of activating surfaces. This |
| 1241 // should not cause a crash or use-after-free. | 1216 // should not cause a crash or use-after-free. |
| 1242 for (int i = 0; i < 3; ++i) { | 1217 for (int i = 0; i < 3; ++i) { |
| 1243 begin_frame_source()->TestOnBeginFrame(args); | 1218 begin_frame_source()->TestOnBeginFrame(args); |
| 1244 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1219 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1245 } | 1220 } |
| 1246 begin_frame_source()->TestOnBeginFrame(args); | 1221 begin_frame_source()->TestOnBeginFrame(args); |
| 1247 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1222 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 1248 } | 1223 } |
| 1249 | 1224 |
| 1250 // This test verifies that a CompositorFrame will only blocked on embedded | 1225 // This test verifies that a CompositorFrame will only blocked on embedded |
| 1251 // surfaces but not on other retained surface IDs in the CompositorFrame. | 1226 // surfaces but not on other retained surface IDs in the CompositorFrame. |
| 1252 TEST_F(CompositorFrameSinkSupportTest, OnlyBlockOnEmbeddedSurfaces) { | 1227 TEST_F(SurfaceSynchronizationTest, OnlyBlockOnEmbeddedSurfaces) { |
| 1253 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 1228 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
| 1254 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1229 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 1255 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 1230 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); |
| 1256 | 1231 |
| 1257 display_support().SubmitCompositorFrame( | 1232 display_support().SubmitCompositorFrame( |
| 1258 display_id.local_surface_id(), | 1233 display_id.local_surface_id(), |
| 1259 MakeCompositorFrame({parent_id1}, {parent_id1, parent_id2})); | 1234 MakeCompositorFrame({parent_id1}, {parent_id1, parent_id2}, |
| 1235 TransferableResourceArray())); |
| 1260 | 1236 |
| 1261 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 1237 EXPECT_TRUE(display_surface()->HasPendingFrame()); |
| 1262 EXPECT_FALSE(display_surface()->HasActiveFrame()); | 1238 EXPECT_FALSE(display_surface()->HasActiveFrame()); |
| 1263 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1239 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1264 | 1240 |
| 1265 // Verify that the display CompositorFrame will only block on |parent_id1| but | 1241 // Verify that the display CompositorFrame will only block on |parent_id1| but |
| 1266 // not |parent_id2|. | 1242 // not |parent_id2|. |
| 1267 EXPECT_THAT(display_surface()->blocking_surfaces(), | 1243 EXPECT_THAT(display_surface()->blocking_surfaces(), |
| 1268 UnorderedElementsAre(parent_id1)); | 1244 UnorderedElementsAre(parent_id1)); |
| 1269 // Verify that the display surface holds no references while its | 1245 // Verify that the display surface holds no references while its |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1280 EXPECT_TRUE(display_surface()->HasActiveFrame()); | 1256 EXPECT_TRUE(display_surface()->HasActiveFrame()); |
| 1281 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty()); | 1257 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty()); |
| 1282 | 1258 |
| 1283 // Only a reference to |parent_id1| is added because |parent_id2| does not | 1259 // Only a reference to |parent_id1| is added because |parent_id2| does not |
| 1284 // exist. | 1260 // exist. |
| 1285 EXPECT_THAT(GetChildReferences(display_id), UnorderedElementsAre(parent_id1)); | 1261 EXPECT_THAT(GetChildReferences(display_id), UnorderedElementsAre(parent_id1)); |
| 1286 } | 1262 } |
| 1287 | 1263 |
| 1288 // This test verifies that a late arriving CompositorFrame activates immediately | 1264 // This test verifies that a late arriving CompositorFrame activates immediately |
| 1289 // and does not trigger a new deadline. | 1265 // and does not trigger a new deadline. |
| 1290 TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) { | 1266 TEST_F(SurfaceSynchronizationTest, LateArrivingDependency) { |
| 1291 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 1267 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); |
| 1292 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1268 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); |
| 1293 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 1269 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); |
| 1294 | 1270 |
| 1295 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1271 display_support().SubmitCompositorFrame( |
| 1296 MakeCompositorFrame({parent_id1})); | 1272 display_id.local_surface_id(), |
| 1273 MakeCompositorFrame({parent_id1}, {parent_id1}, |
| 1274 TransferableResourceArray())); |
| 1297 | 1275 |
| 1298 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 1276 EXPECT_TRUE(display_surface()->HasPendingFrame()); |
| 1299 EXPECT_FALSE(display_surface()->HasActiveFrame()); | 1277 EXPECT_FALSE(display_surface()->HasActiveFrame()); |
| 1300 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1278 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1301 | 1279 |
| 1302 // Advance BeginFrames to trigger a deadline. This activates the | 1280 // Advance BeginFrames to trigger a deadline. This activates the |
| 1303 // CompositorFrame submitted above. | 1281 // CompositorFrame submitted above. |
| 1304 BeginFrameArgs args = | 1282 BeginFrameArgs args = |
| 1305 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 1283 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); |
| 1306 for (int i = 0; i < 3; ++i) { | 1284 for (int i = 0; i < 3; ++i) { |
| 1307 begin_frame_source()->TestOnBeginFrame(args); | 1285 begin_frame_source()->TestOnBeginFrame(args); |
| 1308 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1286 EXPECT_TRUE(dependency_tracker().has_deadline()); |
| 1309 } | 1287 } |
| 1310 begin_frame_source()->TestOnBeginFrame(args); | 1288 begin_frame_source()->TestOnBeginFrame(args); |
| 1311 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1289 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 1312 EXPECT_FALSE(display_surface()->HasPendingFrame()); | 1290 EXPECT_FALSE(display_surface()->HasPendingFrame()); |
| 1313 EXPECT_TRUE(display_surface()->HasActiveFrame()); | 1291 EXPECT_TRUE(display_surface()->HasActiveFrame()); |
| 1314 | 1292 |
| 1315 // A late arriving CompositorFrame should activate immediately without | 1293 // A late arriving CompositorFrame should activate immediately without |
| 1316 // scheduling a deadline and without waiting for dependencies to resolve. | 1294 // scheduling a deadline and without waiting for dependencies to resolve. |
| 1317 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 1295 parent_support().SubmitCompositorFrame( |
| 1318 MakeCompositorFrame({child_id1})); | 1296 parent_id1.local_surface_id(), |
| 1297 MakeCompositorFrame({child_id1}, {child_id1}, |
| 1298 TransferableResourceArray())); |
| 1319 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1299 EXPECT_FALSE(dependency_tracker().has_deadline()); |
| 1320 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1300 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 1321 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 1301 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 1322 } | 1302 } |
| 1323 | 1303 |
| 1324 } // namespace test | 1304 } // namespace test |
| 1325 } // namespace cc | 1305 } // namespace cc |
| OLD | NEW |