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