Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "cc/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" | 
| 6 | 6 | 
| 7 #include "base/macros.h" | 7 #include "base/macros.h" | 
| 
 
Fady Samuel
2017/04/26 00:44:14
Wow, this file has become massive. How about two f
 
Alex Z.
2017/04/27 22:10:01
Done.
 
 | |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" | 
| 9 #include "cc/output/copy_output_request.h" | |
| 10 #include "cc/output/copy_output_result.h" | |
| 11 #include "cc/resources/resource_provider.h" | |
| 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 12 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 
| 10 #include "cc/surfaces/frame_sink_id.h" | 13 #include "cc/surfaces/frame_sink_id.h" | 
| 11 #include "cc/surfaces/surface_id.h" | 14 #include "cc/surfaces/surface_id.h" | 
| 15 #include "cc/surfaces/surface_info.h" | |
| 12 #include "cc/surfaces/surface_manager.h" | 16 #include "cc/surfaces/surface_manager.h" | 
| 13 #include "cc/test/begin_frame_args_test.h" | 17 #include "cc/test/begin_frame_args_test.h" | 
| 14 #include "cc/test/fake_external_begin_frame_source.h" | 18 #include "cc/test/fake_external_begin_frame_source.h" | 
| 15 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" | 
| 16 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" | 
| 17 | 21 | 
| 18 using testing::UnorderedElementsAre; | 22 using testing::UnorderedElementsAre; | 
| 19 using testing::IsEmpty; | 23 using testing::IsEmpty; | 
| 20 using testing::SizeIs; | 24 using testing::SizeIs; | 
| 21 using testing::Invoke; | 25 using testing::Invoke; | 
| 22 using testing::_; | 26 using testing::_; | 
| 23 using testing::Eq; | 27 using testing::Eq; | 
| 24 | 28 | 
| 25 namespace cc { | 29 namespace cc { | 
| 26 namespace test { | 30 namespace test { | 
| 27 namespace { | 31 namespace { | 
| 28 | 32 | 
| 33 constexpr bool kIsRoot = true; | |
| 34 constexpr bool kIsChildRoot = false; | |
| 35 constexpr bool kHandlesFrameSinkIdInvalidation = true; | |
| 36 constexpr bool kNeedsSyncPoints = true; | |
| 37 | |
| 29 constexpr FrameSinkId kDisplayFrameSink(2, 0); | 38 constexpr FrameSinkId kDisplayFrameSink(2, 0); | 
| 30 constexpr FrameSinkId kParentFrameSink(3, 0); | 39 constexpr FrameSinkId kParentFrameSink(3, 0); | 
| 31 constexpr FrameSinkId kChildFrameSink1(65563, 0); | 40 constexpr FrameSinkId kChildFrameSink1(65563, 0); | 
| 32 constexpr FrameSinkId kChildFrameSink2(65564, 0); | 41 constexpr FrameSinkId kChildFrameSink2(65564, 0); | 
| 33 constexpr FrameSinkId kArbitraryFrameSink(1337, 7331); | 42 constexpr FrameSinkId kArbitraryFrameSink(1337, 7331); | 
| 34 | 43 | 
| 44 constexpr FrameSinkId kArbitraryFrameSinkId(1, 1); | |
| 45 constexpr FrameSinkId kAnotherArbitraryFrameSinkId(2, 2); | |
| 46 constexpr FrameSinkId kYetAnotherArbitraryFrameSinkId(3, 3); | |
| 47 | |
| 48 const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create(); | |
| 49 const base::UnguessableToken kArbitrarySourceId1 = | |
| 50 base::UnguessableToken::Deserialize(0xdead, 0xbeef); | |
| 51 const base::UnguessableToken kArbitrarySourceId2 = | |
| 52 base::UnguessableToken::Deserialize(0xdead, 0xbee0); | |
| 53 | |
| 54 gpu::SyncToken GenTestSyncToken(int id) { | |
| 55 gpu::SyncToken token; | |
| 56 token.Set(gpu::CommandBufferNamespace::GPU_IO, 0, | |
| 57 gpu::CommandBufferId::FromUnsafeValue(id), 1); | |
| 58 return token; | |
| 59 } | |
| 60 | |
| 61 std::vector<SurfaceId> empty_surface_ids() { | |
| 62 return std::vector<SurfaceId>(); | |
| 63 } | |
| 64 | |
| 65 SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { | |
| 66 return SurfaceId( | |
| 67 frame_sink_id, | |
| 68 LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); | |
| 69 } | |
| 70 | |
| 71 CompositorFrame MakeCompositorFrame(std::vector<SurfaceId> embedded_surfaces, | |
| 72 std::vector<SurfaceId> referenced_surfaces, | |
| 73 TransferableResourceArray resource_list) { | |
| 74 CompositorFrame compositor_frame; | |
| 75 compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, true); | |
| 76 compositor_frame.metadata.embedded_surfaces = std::move(embedded_surfaces); | |
| 77 compositor_frame.metadata.referenced_surfaces = | |
| 78 std::move(referenced_surfaces); | |
| 79 compositor_frame.resource_list = std::move(resource_list); | |
| 80 return compositor_frame; | |
| 81 } | |
| 82 | |
| 83 CompositorFrame MakeCompositorFrame() { | |
| 84 return MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), | |
| 85 TransferableResourceArray()); | |
| 86 } | |
| 87 | |
| 35 class MockCompositorFrameSinkSupportClient | 88 class MockCompositorFrameSinkSupportClient | 
| 36 : public CompositorFrameSinkSupportClient { | 89 : public CompositorFrameSinkSupportClient { | 
| 37 public: | 90 public: | 
| 38 MockCompositorFrameSinkSupportClient() { | 91 explicit MockCompositorFrameSinkSupportClient( | 
| 92 bool create_surface_during_eviction) { | |
| 39 ON_CALL(*this, ReclaimResources(_)) | 93 ON_CALL(*this, ReclaimResources(_)) | 
| 40 .WillByDefault(Invoke( | 94 .WillByDefault(Invoke( | 
| 41 this, | 95 this, | 
| 42 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); | 96 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); | 
| 43 ON_CALL(*this, DidReceiveCompositorFrameAck(_)) | 97 ON_CALL(*this, DidReceiveCompositorFrameAck(_)) | 
| 44 .WillByDefault(Invoke( | 98 .WillByDefault( | 
| 45 this, | 99 Invoke(this, create_surface_during_eviction | 
| 46 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); | 100 ? &MockCompositorFrameSinkSupportClient:: | 
| 101 CreateSurfaceDrawCallback | |
| 102 : &MockCompositorFrameSinkSupportClient:: | |
| 103 ReclaimResourcesInternal)); | |
| 47 } | 104 } | 
| 48 | 105 | 
| 106 void set_support(CompositorFrameSinkSupport* support) { support_ = support; } | |
| 107 | |
| 49 ReturnedResourceArray& last_returned_resources() { | 108 ReturnedResourceArray& last_returned_resources() { | 
| 50 return last_returned_resources_; | 109 return last_returned_resources_; | 
| 51 } | 110 } | 
| 52 | 111 | 
| 53 // CompositorFrameSinkSupportClient implementation. | 112 // CompositorFrameSinkSupportClient implementation. | 
| 54 MOCK_METHOD1(DidReceiveCompositorFrameAck, | 113 MOCK_METHOD1(DidReceiveCompositorFrameAck, | 
| 55 void(const ReturnedResourceArray&)); | 114 void(const ReturnedResourceArray&)); | 
| 56 MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&)); | 115 MOCK_METHOD1(OnBeginFrame, void(const BeginFrameArgs&)); | 
| 57 MOCK_METHOD1(ReclaimResources, void(const ReturnedResourceArray&)); | 116 MOCK_METHOD1(ReclaimResources, void(const ReturnedResourceArray&)); | 
| 58 MOCK_METHOD2(WillDrawSurface, void(const LocalSurfaceId&, const gfx::Rect&)); | 117 MOCK_METHOD2(WillDrawSurface, void(const LocalSurfaceId&, const gfx::Rect&)); | 
| 59 | 118 | 
| 60 private: | 119 private: | 
| 61 void ReclaimResourcesInternal(const ReturnedResourceArray& resources) { | 120 void ReclaimResourcesInternal(const ReturnedResourceArray& resources) { | 
| 62 last_returned_resources_ = resources; | 121 last_returned_resources_ = resources; | 
| 63 } | 122 } | 
| 64 | 123 | 
| 124 void CreateSurfaceDrawCallback(const ReturnedResourceArray& resources) { | |
| 125 last_returned_resources_ = resources; | |
| 126 LocalSurfaceId new_id(7, base::UnguessableToken::Create()); | |
| 127 ASSERT_TRUE(support_); | |
| 128 ON_CALL(*this, DidReceiveCompositorFrameAck(_)) | |
| 129 .WillByDefault(Invoke( | |
| 130 this, | |
| 131 &MockCompositorFrameSinkSupportClient::ReclaimResourcesInternal)); | |
| 132 support_->SubmitCompositorFrame(new_id, MakeCompositorFrame()); | |
| 133 support_->EvictFrame(); | |
| 134 } | |
| 135 | |
| 65 ReturnedResourceArray last_returned_resources_; | 136 ReturnedResourceArray last_returned_resources_; | 
| 137 CompositorFrameSinkSupport* support_ = nullptr; | |
| 66 }; | 138 }; | 
| 67 | 139 | 
| 68 std::vector<SurfaceId> empty_surface_ids() { | 140 class FakeCompositorFrameSinkSupportClient | 
| 69 return std::vector<SurfaceId>(); | 141 : public CompositorFrameSinkSupportClient { | 
| 70 } | 142 public: | 
| 71 | 143 FakeCompositorFrameSinkSupportClient() = default; | 
| 72 SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { | 144 ~FakeCompositorFrameSinkSupportClient() override = default; | 
| 73 return SurfaceId( | 145 | 
| 74 frame_sink_id, | 146 void DidReceiveCompositorFrameAck( | 
| 75 LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); | 147 const ReturnedResourceArray& resources) override { | 
| 76 } | 148 InsertResources(resources); | 
| 77 | 149 } | 
| 78 CompositorFrame MakeCompositorFrame(std::vector<SurfaceId> embedded_surfaces, | 150 | 
| 79 std::vector<SurfaceId> referenced_surfaces, | 151 void OnBeginFrame(const BeginFrameArgs& args) override {} | 
| 80 TransferableResourceArray resource_list) { | 152 | 
| 81 CompositorFrame compositor_frame; | 153 void ReclaimResources(const ReturnedResourceArray& resources) override { | 
| 82 compositor_frame.metadata.begin_frame_ack = BeginFrameAck(0, 1, 1, true); | 154 InsertResources(resources); | 
| 83 compositor_frame.metadata.embedded_surfaces = std::move(embedded_surfaces); | 155 } | 
| 84 compositor_frame.metadata.referenced_surfaces = | 156 | 
| 85 std::move(referenced_surfaces); | 157 void WillDrawSurface(const LocalSurfaceId& local_surface_id, | 
| 86 compositor_frame.resource_list = std::move(resource_list); | 158 const gfx::Rect& damage_rect) override {} | 
| 87 return compositor_frame; | 159 | 
| 88 } | 160 void clear_returned_resources() { returned_resources_.clear(); } | 
| 89 | 161 const ReturnedResourceArray& returned_resources() { | 
| 90 CompositorFrame MakeCompositorFrame() { | 162 return returned_resources_; | 
| 91 return MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), | 163 } | 
| 92 TransferableResourceArray()); | 164 | 
| 165 private: | |
| 166 void InsertResources(const ReturnedResourceArray& resources) { | |
| 167 returned_resources_.insert(returned_resources_.end(), resources.begin(), | |
| 168 resources.end()); | |
| 169 } | |
| 170 | |
| 171 ReturnedResourceArray returned_resources_; | |
| 172 | |
| 173 DISALLOW_COPY_AND_ASSIGN(FakeCompositorFrameSinkSupportClient); | |
| 174 }; | |
| 175 | |
| 176 class CompositorFrameSinkSupportTest : public testing::Test, | |
| 177 public SurfaceObserver { | |
| 178 public: | |
| 179 CompositorFrameSinkSupportTest() | |
| 180 : support_( | |
| 181 CompositorFrameSinkSupport::Create(&fake_support_client_, | |
| 182 &manager_, | |
| 183 kArbitraryFrameSinkId, | |
| 184 kIsRoot, | |
| 185 kHandlesFrameSinkIdInvalidation, | |
| 186 kNeedsSyncPoints)), | |
| 187 local_surface_id_(3, kArbitraryToken), | |
| 188 frame_sync_token_(GenTestSyncToken(4)), | |
| 189 consumer_sync_token_(GenTestSyncToken(5)) { | |
| 190 manager_.AddObserver(this); | |
| 191 } | |
| 192 | |
| 193 const SurfaceId& last_created_surface_id() const { | |
| 194 return last_created_surface_id_; | |
| 195 } | |
| 196 | |
| 197 // SurfaceObserver implementation. | |
| 198 void OnSurfaceCreated(const SurfaceInfo& surface_info) override { | |
| 199 last_created_surface_id_ = surface_info.id(); | |
| 200 last_surface_info_ = surface_info; | |
| 201 } | |
| 202 | |
| 203 void OnSurfaceDamaged(const SurfaceId& id, bool* changed) override { | |
| 204 *changed = true; | |
| 205 } | |
| 206 | |
| 207 ~CompositorFrameSinkSupportTest() override { | |
| 208 manager_.RemoveObserver(this); | |
| 209 support_->EvictFrame(); | |
| 210 } | |
| 211 | |
| 212 void SubmitCompositorFrameWithResources(ResourceId* resource_ids, | |
| 213 size_t num_resource_ids) { | |
| 214 CompositorFrame frame = MakeCompositorFrame(); | |
| 215 for (size_t i = 0u; i < num_resource_ids; ++i) { | |
| 216 TransferableResource resource; | |
| 217 resource.id = resource_ids[i]; | |
| 218 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | |
| 219 resource.mailbox_holder.sync_token = frame_sync_token_; | |
| 220 frame.resource_list.push_back(resource); | |
| 221 } | |
| 222 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); | |
| 223 EXPECT_EQ(last_created_surface_id_.local_surface_id(), local_surface_id_); | |
| 224 } | |
| 225 | |
| 226 void UnrefResources(ResourceId* ids_to_unref, | |
| 227 int* counts_to_unref, | |
| 228 size_t num_ids_to_unref) { | |
| 229 ReturnedResourceArray unref_array; | |
| 230 for (size_t i = 0; i < num_ids_to_unref; ++i) { | |
| 231 ReturnedResource resource; | |
| 232 resource.sync_token = consumer_sync_token_; | |
| 233 resource.id = ids_to_unref[i]; | |
| 234 resource.count = counts_to_unref[i]; | |
| 235 unref_array.push_back(resource); | |
| 236 } | |
| 237 support_->UnrefResources(unref_array); | |
| 238 } | |
| 239 | |
| 240 void CheckReturnedResourcesMatchExpected(ResourceId* expected_returned_ids, | |
| 241 int* expected_returned_counts, | |
| 242 size_t expected_resources, | |
| 243 gpu::SyncToken expected_sync_token) { | |
| 244 const ReturnedResourceArray& actual_resources = | |
| 245 fake_support_client_.returned_resources(); | |
| 246 ASSERT_EQ(expected_resources, actual_resources.size()); | |
| 247 for (size_t i = 0; i < expected_resources; ++i) { | |
| 248 ReturnedResource resource = actual_resources[i]; | |
| 249 EXPECT_EQ(expected_sync_token, resource.sync_token); | |
| 250 EXPECT_EQ(expected_returned_ids[i], resource.id); | |
| 251 EXPECT_EQ(expected_returned_counts[i], resource.count); | |
| 252 } | |
| 253 fake_support_client_.clear_returned_resources(); | |
| 254 } | |
| 255 | |
| 256 void RefCurrentFrameResources() { | |
| 257 Surface* surface = manager_.GetSurfaceForId( | |
| 258 SurfaceId(support_->frame_sink_id(), local_surface_id_)); | |
| 259 support_->RefResources(surface->GetActiveFrame().resource_list); | |
| 260 } | |
| 261 | |
| 262 protected: | |
| 263 SurfaceManager manager_; | |
| 264 FakeCompositorFrameSinkSupportClient fake_support_client_; | |
| 265 std::unique_ptr<CompositorFrameSinkSupport> support_; | |
| 266 LocalSurfaceId local_surface_id_; | |
| 267 SurfaceId last_created_surface_id_; | |
| 268 SurfaceInfo last_surface_info_; | |
| 269 | |
| 270 // This is the sync token submitted with the frame. It should never be | |
| 271 // returned to the client. | |
| 272 const gpu::SyncToken frame_sync_token_; | |
| 273 | |
| 274 // This is the sync token returned by the consumer. It should always be | |
| 275 // returned to the client. | |
| 276 const gpu::SyncToken consumer_sync_token_; | |
| 277 }; | |
| 278 | |
| 279 // Tests submitting a frame with resources followed by one with no resources | |
| 280 // with no resource provider action in between. | |
| 281 TEST_F(CompositorFrameSinkSupportTest, ResourceLifetimeSimple) { | |
| 282 ResourceId first_frame_ids[] = {1, 2, 3}; | |
| 283 SubmitCompositorFrameWithResources(first_frame_ids, | |
| 284 arraysize(first_frame_ids)); | |
| 285 | |
| 286 // All of the resources submitted in the first frame are still in use at this | |
| 287 // time by virtue of being in the pending frame, so none can be returned to | |
| 288 // the client yet. | |
| 289 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 290 fake_support_client_.clear_returned_resources(); | |
| 291 | |
| 292 // The second frame references no resources of first frame and thus should | |
| 293 // make all resources of first frame available to be returned. | |
| 294 SubmitCompositorFrameWithResources(NULL, 0); | |
| 295 | |
| 296 ResourceId expected_returned_ids[] = {1, 2, 3}; | |
| 297 int expected_returned_counts[] = {1, 1, 1}; | |
| 298 // Resources were never consumed so no sync token should be set. | |
| 299 CheckReturnedResourcesMatchExpected( | |
| 300 expected_returned_ids, expected_returned_counts, | |
| 301 arraysize(expected_returned_counts), gpu::SyncToken()); | |
| 302 | |
| 303 ResourceId third_frame_ids[] = {4, 5, 6}; | |
| 304 SubmitCompositorFrameWithResources(third_frame_ids, | |
| 305 arraysize(third_frame_ids)); | |
| 306 | |
| 307 // All of the resources submitted in the third frame are still in use at this | |
| 308 // time by virtue of being in the pending frame, so none can be returned to | |
| 309 // the client yet. | |
| 310 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 311 fake_support_client_.clear_returned_resources(); | |
| 312 | |
| 313 // The forth frame references no resources of third frame and thus should | |
| 314 // make all resources of third frame available to be returned. | |
| 315 ResourceId forth_frame_ids[] = {7, 8, 9}; | |
| 316 SubmitCompositorFrameWithResources(forth_frame_ids, | |
| 317 arraysize(forth_frame_ids)); | |
| 318 | |
| 319 ResourceId forth_expected_returned_ids[] = {4, 5, 6}; | |
| 320 int forth_expected_returned_counts[] = {1, 1, 1}; | |
| 321 // Resources were never consumed so no sync token should be set. | |
| 322 CheckReturnedResourcesMatchExpected( | |
| 323 forth_expected_returned_ids, forth_expected_returned_counts, | |
| 324 arraysize(forth_expected_returned_counts), gpu::SyncToken()); | |
| 325 } | |
| 326 | |
| 327 // Tests submitting a frame with resources followed by one with no resources | |
| 328 // with the resource provider holding everything alive. | |
| 329 TEST_F(CompositorFrameSinkSupportTest, | |
| 330 ResourceLifetimeSimpleWithProviderHoldingAlive) { | |
| 331 ResourceId first_frame_ids[] = {1, 2, 3}; | |
| 332 SubmitCompositorFrameWithResources(first_frame_ids, | |
| 333 arraysize(first_frame_ids)); | |
| 334 | |
| 335 // All of the resources submitted in the first frame are still in use at this | |
| 336 // time by virtue of being in the pending frame, so none can be returned to | |
| 337 // the client yet. | |
| 338 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 339 fake_support_client_.clear_returned_resources(); | |
| 340 | |
| 341 // Hold on to everything. | |
| 342 RefCurrentFrameResources(); | |
| 343 | |
| 344 // The second frame references no resources and thus should make all resources | |
| 345 // available to be returned as soon as the resource provider releases them. | |
| 346 SubmitCompositorFrameWithResources(NULL, 0); | |
| 347 | |
| 348 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 349 fake_support_client_.clear_returned_resources(); | |
| 350 | |
| 351 int release_counts[] = {1, 1, 1}; | |
| 352 UnrefResources(first_frame_ids, release_counts, arraysize(first_frame_ids)); | |
| 353 | |
| 354 // None is returned to the client since DidReceiveCompositorAck is not | |
| 355 // invoked. | |
| 356 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 357 | |
| 358 // Submitting an empty frame causes previous resources referenced by the | |
| 359 // previous frame to be returned to client. | |
| 360 SubmitCompositorFrameWithResources(nullptr, 0); | |
| 361 ResourceId expected_returned_ids[] = {1, 2, 3}; | |
| 362 int expected_returned_counts[] = {1, 1, 1}; | |
| 363 CheckReturnedResourcesMatchExpected( | |
| 364 expected_returned_ids, expected_returned_counts, | |
| 365 arraysize(expected_returned_counts), consumer_sync_token_); | |
| 366 } | |
| 367 | |
| 368 // Tests referencing a resource, unref'ing it to zero, then using it again | |
| 369 // before returning it to the client. | |
| 370 TEST_F(CompositorFrameSinkSupportTest, ResourceReusedBeforeReturn) { | |
| 371 ResourceId first_frame_ids[] = {7}; | |
| 372 SubmitCompositorFrameWithResources(first_frame_ids, | |
| 373 arraysize(first_frame_ids)); | |
| 374 | |
| 375 // This removes all references to resource id 7. | |
| 376 SubmitCompositorFrameWithResources(NULL, 0); | |
| 377 | |
| 378 // This references id 7 again. | |
| 379 SubmitCompositorFrameWithResources(first_frame_ids, | |
| 380 arraysize(first_frame_ids)); | |
| 381 | |
| 382 // This removes it again. | |
| 383 SubmitCompositorFrameWithResources(NULL, 0); | |
| 384 | |
| 385 // Now it should be returned. | |
| 386 // We don't care how many entries are in the returned array for 7, so long as | |
| 387 // the total returned count matches the submitted count. | |
| 388 const ReturnedResourceArray& returned = | |
| 389 fake_support_client_.returned_resources(); | |
| 390 size_t return_count = 0; | |
| 391 for (size_t i = 0; i < returned.size(); ++i) { | |
| 392 EXPECT_EQ(7u, returned[i].id); | |
| 393 return_count += returned[i].count; | |
| 394 } | |
| 395 EXPECT_EQ(2u, return_count); | |
| 396 } | |
| 397 | |
| 398 // Tests having resources referenced multiple times, as if referenced by | |
| 399 // multiple providers. | |
| 400 TEST_F(CompositorFrameSinkSupportTest, ResourceRefMultipleTimes) { | |
| 401 ResourceId first_frame_ids[] = {3, 4}; | |
| 402 SubmitCompositorFrameWithResources(first_frame_ids, | |
| 403 arraysize(first_frame_ids)); | |
| 404 | |
| 405 // Ref resources from the first frame twice. | |
| 406 RefCurrentFrameResources(); | |
| 407 RefCurrentFrameResources(); | |
| 408 | |
| 409 ResourceId second_frame_ids[] = {4, 5}; | |
| 410 SubmitCompositorFrameWithResources(second_frame_ids, | |
| 411 arraysize(second_frame_ids)); | |
| 412 | |
| 413 // Ref resources from the second frame 3 times. | |
| 414 RefCurrentFrameResources(); | |
| 415 RefCurrentFrameResources(); | |
| 416 RefCurrentFrameResources(); | |
| 417 | |
| 418 // Submit a frame with no resources to remove all current frame refs from | |
| 419 // submitted resources. | |
| 420 SubmitCompositorFrameWithResources(NULL, 0); | |
| 421 | |
| 422 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 423 fake_support_client_.clear_returned_resources(); | |
| 424 | |
| 425 // Expected current refs: | |
| 426 // 3 -> 2 | |
| 427 // 4 -> 2 + 3 = 5 | |
| 428 // 5 -> 3 | |
| 429 { | |
| 430 SCOPED_TRACE("unref all 3"); | |
| 431 ResourceId ids_to_unref[] = {3, 4, 5}; | |
| 432 int counts[] = {1, 1, 1}; | |
| 433 UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref)); | |
| 434 | |
| 435 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 436 fake_support_client_.clear_returned_resources(); | |
| 437 | |
| 438 UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref)); | |
| 439 SubmitCompositorFrameWithResources(nullptr, 0); | |
| 440 ResourceId expected_returned_ids[] = {3}; | |
| 441 int expected_returned_counts[] = {1}; | |
| 442 CheckReturnedResourcesMatchExpected( | |
| 443 expected_returned_ids, expected_returned_counts, | |
| 444 arraysize(expected_returned_counts), consumer_sync_token_); | |
| 445 } | |
| 446 | |
| 447 // Expected refs remaining: | |
| 448 // 4 -> 3 | |
| 449 // 5 -> 1 | |
| 450 { | |
| 451 SCOPED_TRACE("unref 4 and 5"); | |
| 452 ResourceId ids_to_unref[] = {4, 5}; | |
| 453 int counts[] = {1, 1}; | |
| 454 UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref)); | |
| 455 SubmitCompositorFrameWithResources(nullptr, 0); | |
| 456 | |
| 457 ResourceId expected_returned_ids[] = {5}; | |
| 458 int expected_returned_counts[] = {1}; | |
| 459 CheckReturnedResourcesMatchExpected( | |
| 460 expected_returned_ids, expected_returned_counts, | |
| 461 arraysize(expected_returned_counts), consumer_sync_token_); | |
| 462 } | |
| 463 | |
| 464 // Now, just 2 refs remaining on resource 4. Unref both at once and make sure | |
| 465 // the returned count is correct. | |
| 466 { | |
| 467 SCOPED_TRACE("unref only 4"); | |
| 468 ResourceId ids_to_unref[] = {4}; | |
| 469 int counts[] = {2}; | |
| 470 UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref)); | |
| 471 SubmitCompositorFrameWithResources(nullptr, 0); | |
| 472 | |
| 473 ResourceId expected_returned_ids[] = {4}; | |
| 474 int expected_returned_counts[] = {2}; | |
| 475 CheckReturnedResourcesMatchExpected( | |
| 476 expected_returned_ids, expected_returned_counts, | |
| 477 arraysize(expected_returned_counts), consumer_sync_token_); | |
| 478 } | |
| 479 } | |
| 480 | |
| 481 TEST_F(CompositorFrameSinkSupportTest, ResourceLifetime) { | |
| 482 ResourceId first_frame_ids[] = {1, 2, 3}; | |
| 483 SubmitCompositorFrameWithResources(first_frame_ids, | |
| 484 arraysize(first_frame_ids)); | |
| 485 | |
| 486 // All of the resources submitted in the first frame are still in use at this | |
| 487 // time by virtue of being in the pending frame, so none can be returned to | |
| 488 // the client yet. | |
| 489 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 490 fake_support_client_.clear_returned_resources(); | |
| 491 | |
| 492 // The second frame references some of the same resources, but some different | |
| 493 // ones. We expect to receive back resource 1 with a count of 1 since it was | |
| 494 // only referenced by the first frame. | |
| 495 ResourceId second_frame_ids[] = {2, 3, 4}; | |
| 496 SubmitCompositorFrameWithResources(second_frame_ids, | |
| 497 arraysize(second_frame_ids)); | |
| 498 { | |
| 499 SCOPED_TRACE("second frame"); | |
| 500 ResourceId expected_returned_ids[] = {1}; | |
| 501 int expected_returned_counts[] = {1}; | |
| 502 CheckReturnedResourcesMatchExpected( | |
| 503 expected_returned_ids, expected_returned_counts, | |
| 504 arraysize(expected_returned_counts), gpu::SyncToken()); | |
| 505 } | |
| 506 | |
| 507 // The third frame references a disjoint set of resources, so we expect to | |
| 508 // receive back all resources from the first and second frames. Resource IDs 2 | |
| 509 // and 3 will have counts of 2, since they were used in both frames, and | |
| 510 // resource ID 4 will have a count of 1. | |
| 511 ResourceId third_frame_ids[] = {10, 11, 12, 13}; | |
| 512 SubmitCompositorFrameWithResources(third_frame_ids, | |
| 513 arraysize(third_frame_ids)); | |
| 514 | |
| 515 { | |
| 516 SCOPED_TRACE("third frame"); | |
| 517 ResourceId expected_returned_ids[] = {2, 3, 4}; | |
| 518 int expected_returned_counts[] = {2, 2, 1}; | |
| 519 CheckReturnedResourcesMatchExpected( | |
| 520 expected_returned_ids, expected_returned_counts, | |
| 521 arraysize(expected_returned_counts), gpu::SyncToken()); | |
| 522 } | |
| 523 | |
| 524 // Simulate a ResourceProvider taking a ref on all of the resources. | |
| 525 RefCurrentFrameResources(); | |
| 526 | |
| 527 ResourceId fourth_frame_ids[] = {12, 13}; | |
| 528 SubmitCompositorFrameWithResources(fourth_frame_ids, | |
| 529 arraysize(fourth_frame_ids)); | |
| 530 | |
| 531 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 532 | |
| 533 RefCurrentFrameResources(); | |
| 534 | |
| 535 // All resources are still being used by the external reference, so none can | |
| 536 // be returned to the client. | |
| 537 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 538 | |
| 539 // Release resources associated with the first RefCurrentFrameResources() call | |
| 540 // first. | |
| 541 { | |
| 542 ResourceId ids_to_unref[] = {10, 11, 12, 13}; | |
| 543 int counts[] = {1, 1, 1, 1}; | |
| 544 UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref)); | |
| 545 } | |
| 546 | |
| 547 // Nothing is returned to the client yet since DidReceiveCompositorFrameAck | |
| 548 // is not invoked. | |
| 549 { | |
| 550 SCOPED_TRACE("fourth frame, first unref"); | |
| 551 ResourceId expected_returned_ids[] = {}; | |
| 552 int expected_returned_counts[] = {}; | |
| 553 CheckReturnedResourcesMatchExpected(expected_returned_ids, | |
| 554 expected_returned_counts, 0, | |
| 555 consumer_sync_token_); | |
| 556 } | |
| 557 | |
| 558 { | |
| 559 ResourceId ids_to_unref[] = {12, 13}; | |
| 560 int counts[] = {1, 1}; | |
| 561 UnrefResources(ids_to_unref, counts, arraysize(ids_to_unref)); | |
| 562 } | |
| 563 | |
| 564 // Resources 12 and 13 are still in use by the current frame, so they | |
| 565 // shouldn't be available to be returned. | |
| 566 EXPECT_EQ(0u, fake_support_client_.returned_resources().size()); | |
| 567 | |
| 568 // If we submit an empty frame, however, they should become available. | |
| 569 // Resources that were previously unref'd also return at this point. | |
| 570 SubmitCompositorFrameWithResources(NULL, 0u); | |
| 571 | |
| 572 { | |
| 573 SCOPED_TRACE("fourth frame, second unref"); | |
| 574 ResourceId expected_returned_ids[] = {10, 11, 12, 13}; | |
| 575 int expected_returned_counts[] = {1, 1, 2, 2}; | |
| 576 CheckReturnedResourcesMatchExpected( | |
| 577 expected_returned_ids, expected_returned_counts, | |
| 578 arraysize(expected_returned_counts), consumer_sync_token_); | |
| 579 } | |
| 580 } | |
| 581 | |
| 582 TEST_F(CompositorFrameSinkSupportTest, BlankNoIndexIncrement) { | |
| 583 LocalSurfaceId local_surface_id(6, kArbitraryToken); | |
| 584 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); | |
| 585 support_->SubmitCompositorFrame(local_surface_id, MakeCompositorFrame()); | |
| 586 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
| 587 ASSERT_NE(nullptr, surface); | |
| 588 EXPECT_EQ(2, surface->frame_index()); | |
| 589 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); | |
| 590 } | |
| 591 | |
| 592 TEST_F(CompositorFrameSinkSupportTest, AddDuringEviction) { | |
| 593 constexpr bool kAddDuringEviction = true; | |
| 594 MockCompositorFrameSinkSupportClient mock_client(kAddDuringEviction); | |
| 595 std::unique_ptr<CompositorFrameSinkSupport> support = | |
| 596 CompositorFrameSinkSupport::Create( | |
| 597 &mock_client, &manager_, kAnotherArbitraryFrameSinkId, kIsRoot, | |
| 598 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | |
| 599 mock_client.set_support(support.get()); | |
| 600 LocalSurfaceId local_surface_id(6, kArbitraryToken); | |
| 601 | |
| 602 EXPECT_CALL(mock_client, DidReceiveCompositorFrameAck(_)).Times(0); | |
| 603 support->SubmitCompositorFrame(local_surface_id, MakeCompositorFrame()); | |
| 604 | |
| 605 EXPECT_CALL(mock_client, DidReceiveCompositorFrameAck(_)).Times(2); | |
| 606 support->EvictFrame(); | |
| 607 } | |
| 608 | |
| 609 // Tests doing an EvictFrame before shutting down the factory. | |
| 610 TEST_F(CompositorFrameSinkSupportTest, EvictFrame) { | |
| 611 constexpr bool kAddDuringEviction = false; | |
| 612 MockCompositorFrameSinkSupportClient mock_client(kAddDuringEviction); | |
| 613 std::unique_ptr<CompositorFrameSinkSupport> support = | |
| 614 CompositorFrameSinkSupport::Create( | |
| 615 &mock_client, &manager_, kAnotherArbitraryFrameSinkId, kIsRoot, | |
| 616 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | |
| 617 mock_client.set_support(support.get()); | |
| 618 LocalSurfaceId local_surface_id(7, kArbitraryToken); | |
| 619 SurfaceId id(kAnotherArbitraryFrameSinkId, local_surface_id); | |
| 620 | |
| 621 TransferableResource resource; | |
| 622 resource.id = 1; | |
| 623 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | |
| 624 CompositorFrame frame = MakeCompositorFrame(); | |
| 625 frame.resource_list.push_back(resource); | |
| 626 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); | |
| 627 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); | |
| 628 local_surface_id_ = LocalSurfaceId(); | |
| 629 | |
| 630 EXPECT_TRUE(manager_.GetSurfaceForId(id)); | |
| 631 EXPECT_TRUE(mock_client.last_returned_resources().empty()); | |
| 632 EXPECT_CALL(mock_client, DidReceiveCompositorFrameAck(_)).Times(1); | |
| 633 support->EvictFrame(); | |
| 634 EXPECT_FALSE(manager_.GetSurfaceForId(id)); | |
| 635 EXPECT_FALSE(mock_client.last_returned_resources().empty()); | |
| 636 } | |
| 637 | |
| 638 // Tests doing an EvictSurface which has unregistered dependency. | |
| 639 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceDependencyUnRegistered) { | |
| 640 constexpr bool kAddDuringEviction = false; | |
| 641 MockCompositorFrameSinkSupportClient mock_client(kAddDuringEviction); | |
| 642 std::unique_ptr<CompositorFrameSinkSupport> support = | |
| 643 CompositorFrameSinkSupport::Create( | |
| 644 &mock_client, &manager_, kAnotherArbitraryFrameSinkId, kIsRoot, | |
| 645 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | |
| 646 mock_client.set_support(support.get()); | |
| 647 LocalSurfaceId local_surface_id(7, kArbitraryToken); | |
| 648 | |
| 649 TransferableResource resource; | |
| 650 resource.id = 1; | |
| 651 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | |
| 652 CompositorFrame frame = MakeCompositorFrame(); | |
| 653 frame.resource_list.push_back(resource); | |
| 654 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); | |
| 655 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); | |
| 656 local_surface_id_ = LocalSurfaceId(); | |
| 657 | |
| 658 SurfaceId surface_id(kAnotherArbitraryFrameSinkId, local_surface_id); | |
| 659 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
| 660 surface->AddDestructionDependency( | |
| 661 SurfaceSequence(kYetAnotherArbitraryFrameSinkId, 4)); | |
| 662 | |
| 663 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | |
| 664 EXPECT_TRUE(mock_client.last_returned_resources().empty()); | |
| 665 EXPECT_CALL(mock_client, DidReceiveCompositorFrameAck(_)).Times(1); | |
| 666 support->EvictFrame(); | |
| 667 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); | |
| 668 EXPECT_FALSE(mock_client.last_returned_resources().empty()); | |
| 669 } | |
| 670 | |
| 671 // Tests doing an EvictSurface which has registered dependency. | |
| 672 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceDependencyRegistered) { | |
| 673 constexpr bool kAddDuringEviction = false; | |
| 674 MockCompositorFrameSinkSupportClient mock_client(kAddDuringEviction); | |
| 675 std::unique_ptr<CompositorFrameSinkSupport> support = | |
| 676 CompositorFrameSinkSupport::Create( | |
| 677 &mock_client, &manager_, kAnotherArbitraryFrameSinkId, kIsRoot, | |
| 678 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | |
| 679 mock_client.set_support(support.get()); | |
| 680 LocalSurfaceId local_surface_id(7, kArbitraryToken); | |
| 681 | |
| 682 TransferableResource resource; | |
| 683 resource.id = 1; | |
| 684 resource.mailbox_holder.texture_target = GL_TEXTURE_2D; | |
| 685 CompositorFrame frame = MakeCompositorFrame(); | |
| 686 frame.resource_list.push_back(resource); | |
| 687 uint32_t execute_count = 0; | |
| 688 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); | |
| 689 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id); | |
| 690 local_surface_id_ = LocalSurfaceId(); | |
| 691 | |
| 692 manager_.RegisterFrameSinkId(kYetAnotherArbitraryFrameSinkId); | |
| 693 | |
| 694 SurfaceId surface_id(kAnotherArbitraryFrameSinkId, local_surface_id); | |
| 695 Surface* surface = manager_.GetSurfaceForId(surface_id); | |
| 696 surface->AddDestructionDependency( | |
| 697 SurfaceSequence(kYetAnotherArbitraryFrameSinkId, 4)); | |
| 698 | |
| 699 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | |
| 700 EXPECT_TRUE(mock_client.last_returned_resources().empty()); | |
| 701 EXPECT_CALL(mock_client, DidReceiveCompositorFrameAck(_)).Times(1); | |
| 702 support->EvictFrame(); | |
| 703 EXPECT_TRUE(manager_.GetSurfaceForId(surface_id)); | |
| 704 EXPECT_TRUE(mock_client.last_returned_resources().empty()); | |
| 705 EXPECT_EQ(0u, execute_count); | |
| 706 | |
| 707 manager_.SatisfySequence(SurfaceSequence(kYetAnotherArbitraryFrameSinkId, 4)); | |
| 708 EXPECT_FALSE(manager_.GetSurfaceForId(surface_id)); | |
| 709 EXPECT_FALSE(mock_client.last_returned_resources().empty()); | |
| 710 } | |
| 711 | |
| 712 TEST_F(CompositorFrameSinkSupportTest, DestroySequence) { | |
| 713 LocalSurfaceId local_surface_id2(5, kArbitraryToken); | |
| 714 std::unique_ptr<CompositorFrameSinkSupport> support2 = | |
| 715 CompositorFrameSinkSupport::Create( | |
| 716 &fake_support_client_, &manager_, kYetAnotherArbitraryFrameSinkId, | |
| 717 kIsChildRoot, kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | |
| 718 SurfaceId id2(kYetAnotherArbitraryFrameSinkId, local_surface_id2); | |
| 719 support2->SubmitCompositorFrame(local_surface_id2, MakeCompositorFrame()); | |
| 720 | |
| 721 // Check that waiting before the sequence is satisfied works. | |
| 722 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | |
| 723 SurfaceSequence(kYetAnotherArbitraryFrameSinkId, 4)); | |
| 724 support2->EvictFrame(); | |
| 725 | |
| 726 DCHECK(manager_.GetSurfaceForId(id2)); | |
| 727 manager_.SatisfySequence(SurfaceSequence(kYetAnotherArbitraryFrameSinkId, 4)); | |
| 728 manager_.SatisfySequence(SurfaceSequence(kYetAnotherArbitraryFrameSinkId, 6)); | |
| 729 DCHECK(!manager_.GetSurfaceForId(id2)); | |
| 730 | |
| 731 // Check that waiting after the sequence is satisfied works. | |
| 732 support2->SubmitCompositorFrame(local_surface_id2, MakeCompositorFrame()); | |
| 733 DCHECK(manager_.GetSurfaceForId(id2)); | |
| 734 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | |
| 735 SurfaceSequence(kAnotherArbitraryFrameSinkId, 6)); | |
| 736 support2->EvictFrame(); | |
| 737 DCHECK(!manager_.GetSurfaceForId(id2)); | |
| 738 } | |
| 739 | |
| 740 // Tests that Surface ID namespace invalidation correctly allows | |
| 741 // Sequences to be ignored. | |
| 742 TEST_F(CompositorFrameSinkSupportTest, InvalidFrameSinkId) { | |
| 743 FrameSinkId frame_sink_id(1234, 5678); | |
| 744 | |
| 745 LocalSurfaceId local_surface_id(5, kArbitraryToken); | |
| 746 SurfaceId id(support_->frame_sink_id(), local_surface_id); | |
| 747 support_->SubmitCompositorFrame(local_surface_id, MakeCompositorFrame()); | |
| 748 | |
| 749 manager_.RegisterFrameSinkId(frame_sink_id); | |
| 750 manager_.GetSurfaceForId(id)->AddDestructionDependency( | |
| 751 SurfaceSequence(frame_sink_id, 4)); | |
| 752 | |
| 753 support_->EvictFrame(); | |
| 754 | |
| 755 // Verify the dependency has prevented the surface from getting destroyed. | |
| 756 EXPECT_TRUE(manager_.GetSurfaceForId(id)); | |
| 757 | |
| 758 manager_.InvalidateFrameSinkId(frame_sink_id); | |
| 759 | |
| 760 // Verify that the invalidated namespace caused the unsatisfied sequence | |
| 761 // to be ignored. | |
| 762 EXPECT_FALSE(manager_.GetSurfaceForId(id)); | |
| 763 } | |
| 764 | |
| 765 TEST_F(CompositorFrameSinkSupportTest, DestroyCycle) { | |
| 766 LocalSurfaceId local_surface_id2(5, kArbitraryToken); | |
| 767 SurfaceId id2(kYetAnotherArbitraryFrameSinkId, local_surface_id2); | |
| 768 std::unique_ptr<CompositorFrameSinkSupport> support2 = | |
| 769 CompositorFrameSinkSupport::Create( | |
| 770 &fake_support_client_, &manager_, kYetAnotherArbitraryFrameSinkId, | |
| 771 kIsChildRoot, kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | |
| 772 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); | |
| 773 // Give id2 a frame that references local_surface_id_. | |
| 774 { | |
| 775 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | |
| 776 CompositorFrame frame = MakeCompositorFrame(); | |
| 777 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 778 frame.metadata.referenced_surfaces.push_back( | |
| 779 SurfaceId(support_->frame_sink_id(), local_surface_id_)); | |
| 780 support2->SubmitCompositorFrame(local_surface_id2, std::move(frame)); | |
| 781 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id2); | |
| 782 } | |
| 783 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | |
| 784 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | |
| 785 support2->EvictFrame(); | |
| 786 // Give local_surface_id_ a frame that references id2. | |
| 787 { | |
| 788 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | |
| 789 CompositorFrame frame = MakeCompositorFrame(); | |
| 790 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 791 frame.metadata.referenced_surfaces.push_back(id2); | |
| 792 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); | |
| 793 } | |
| 794 support_->EvictFrame(); | |
| 795 EXPECT_TRUE(manager_.GetSurfaceForId(id2)); | |
| 796 // local_surface_id_ should be retained by reference from id2. | |
| 797 EXPECT_TRUE(manager_.GetSurfaceForId( | |
| 798 SurfaceId(support_->frame_sink_id(), local_surface_id_))); | |
| 799 | |
| 800 // Satisfy last destruction dependency for id2. | |
| 801 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | |
| 802 | |
| 803 // id2 and local_surface_id_ are in a reference cycle that has no surface | |
| 804 // sequences holding on to it, so they should be destroyed. | |
| 805 EXPECT_TRUE(!manager_.GetSurfaceForId(id2)); | |
| 806 EXPECT_TRUE(!manager_.GetSurfaceForId( | |
| 807 SurfaceId(support_->frame_sink_id(), local_surface_id_))); | |
| 808 | |
| 809 local_surface_id_ = LocalSurfaceId(); | |
| 810 } | |
| 811 | |
| 812 void CopyRequestTestCallback(bool* called, | |
| 813 std::unique_ptr<CopyOutputResult> result) { | |
| 814 *called = true; | |
| 815 } | |
| 816 | |
| 817 TEST_F(CompositorFrameSinkSupportTest, DuplicateCopyRequest) { | |
| 818 { | |
| 819 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | |
| 820 CompositorFrame frame = MakeCompositorFrame(); | |
| 821 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 822 frame.metadata.referenced_surfaces.push_back( | |
| 823 SurfaceId(support_->frame_sink_id(), local_surface_id_)); | |
| 824 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); | |
| 825 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id_); | |
| 826 } | |
| 827 | |
| 828 bool called1 = false; | |
| 829 std::unique_ptr<CopyOutputRequest> request; | |
| 830 request = CopyOutputRequest::CreateRequest( | |
| 831 base::Bind(&CopyRequestTestCallback, &called1)); | |
| 832 request->set_source(kArbitrarySourceId1); | |
| 833 | |
| 834 support_->RequestCopyOfSurface(std::move(request)); | |
| 835 EXPECT_FALSE(called1); | |
| 836 | |
| 837 bool called2 = false; | |
| 838 request = CopyOutputRequest::CreateRequest( | |
| 839 base::Bind(&CopyRequestTestCallback, &called2)); | |
| 840 request->set_source(kArbitrarySourceId2); | |
| 841 | |
| 842 support_->RequestCopyOfSurface(std::move(request)); | |
| 843 // Callbacks have different sources so neither should be called. | |
| 844 EXPECT_FALSE(called1); | |
| 845 EXPECT_FALSE(called2); | |
| 846 | |
| 847 bool called3 = false; | |
| 848 request = CopyOutputRequest::CreateRequest( | |
| 849 base::Bind(&CopyRequestTestCallback, &called3)); | |
| 850 request->set_source(kArbitrarySourceId1); | |
| 851 | |
| 852 support_->RequestCopyOfSurface(std::move(request)); | |
| 853 // Two callbacks are from source1, so the first should be called. | |
| 854 EXPECT_TRUE(called1); | |
| 855 EXPECT_FALSE(called2); | |
| 856 EXPECT_FALSE(called3); | |
| 857 | |
| 858 support_->EvictFrame(); | |
| 859 local_surface_id_ = LocalSurfaceId(); | |
| 860 EXPECT_TRUE(called1); | |
| 861 EXPECT_TRUE(called2); | |
| 862 EXPECT_TRUE(called3); | |
| 863 } | |
| 864 | |
| 865 // Check whether the SurfaceInfo object is created and populated correctly | |
| 866 // after the frame submission. | |
| 867 TEST_F(CompositorFrameSinkSupportTest, SurfaceInfo) { | |
| 868 CompositorFrame frame = MakeCompositorFrame(); | |
| 869 | |
| 870 auto render_pass = RenderPass::Create(); | |
| 871 render_pass->SetNew(1, gfx::Rect(5, 6), gfx::Rect(), gfx::Transform()); | |
| 872 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 873 | |
| 874 render_pass = RenderPass::Create(); | |
| 875 render_pass->SetNew(2, gfx::Rect(7, 8), gfx::Rect(), gfx::Transform()); | |
| 876 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 877 | |
| 878 frame.metadata.device_scale_factor = 2.5f; | |
| 879 | |
| 880 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); | |
| 881 SurfaceId expected_surface_id(support_->frame_sink_id(), local_surface_id_); | |
| 882 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); | |
| 883 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); | |
| 884 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); | |
| 93 } | 885 } | 
| 94 | 886 | 
| 95 CompositorFrame MakeCompositorFrame(std::vector<SurfaceId> embedded_surfaces) { | 887 CompositorFrame MakeCompositorFrame(std::vector<SurfaceId> embedded_surfaces) { | 
| 96 return MakeCompositorFrame(embedded_surfaces, embedded_surfaces, | 888 return MakeCompositorFrame(embedded_surfaces, embedded_surfaces, | 
| 97 TransferableResourceArray()); | 889 TransferableResourceArray()); | 
| 98 } | 890 } | 
| 99 | 891 | 
| 100 CompositorFrame MakeCompositorFrame( | 892 CompositorFrame MakeCompositorFrame( | 
| 101 std::vector<SurfaceId> embedded_surfaces, | 893 std::vector<SurfaceId> embedded_surfaces, | 
| 102 std::vector<SurfaceId> referenced_surfaces) { | 894 std::vector<SurfaceId> referenced_surfaces) { | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 119 TransferableResource resource; | 911 TransferableResource resource; | 
| 120 resource.id = id; | 912 resource.id = id; | 
| 121 resource.format = format; | 913 resource.format = format; | 
| 122 resource.filter = filter; | 914 resource.filter = filter; | 
| 123 resource.size = size; | 915 resource.size = size; | 
| 124 return resource; | 916 return resource; | 
| 125 } | 917 } | 
| 126 | 918 | 
| 127 } // namespace | 919 } // namespace | 
| 128 | 920 | 
| 129 class CompositorFrameSinkSupportTest : public testing::Test, | 921 class SurfaceReferenceTest : public testing::Test, public SurfaceObserver { | 
| 130 public SurfaceObserver { | |
| 131 public: | 922 public: | 
| 132 CompositorFrameSinkSupportTest() | 923 SurfaceReferenceTest() | 
| 133 : surface_manager_(SurfaceManager::LifetimeType::REFERENCES) {} | 924 : support_client_(false /* create_surface_during_eviction */), | 
| 134 ~CompositorFrameSinkSupportTest() override {} | 925 surface_manager_(SurfaceManager::LifetimeType::REFERENCES) {} | 
| 926 ~SurfaceReferenceTest() override {} | |
| 135 | 927 | 
| 136 CompositorFrameSinkSupport& display_support() { return *supports_[0]; } | 928 CompositorFrameSinkSupport& display_support() { return *supports_[0]; } | 
| 137 Surface* display_surface() { | 929 Surface* display_surface() { | 
| 138 return display_support().current_surface_for_testing(); | 930 return display_support().current_surface_for_testing(); | 
| 139 } | 931 } | 
| 140 | 932 | 
| 141 CompositorFrameSinkSupport& parent_support() { return *supports_[1]; } | 933 CompositorFrameSinkSupport& parent_support() { return *supports_[1]; } | 
| 142 Surface* parent_surface() { | 934 Surface* parent_surface() { | 
| 143 return parent_support().current_surface_for_testing(); | 935 return parent_support().current_surface_for_testing(); | 
| 144 } | 936 } | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 return *surface_manager_.dependency_tracker(); | 970 return *surface_manager_.dependency_tracker(); | 
| 179 } | 971 } | 
| 180 | 972 | 
| 181 FakeExternalBeginFrameSource* begin_frame_source() { | 973 FakeExternalBeginFrameSource* begin_frame_source() { | 
| 182 return begin_frame_source_.get(); | 974 return begin_frame_source_.get(); | 
| 183 } | 975 } | 
| 184 | 976 | 
| 185 // testing::Test: | 977 // testing::Test: | 
| 186 void SetUp() override { | 978 void SetUp() override { | 
| 187 testing::Test::SetUp(); | 979 testing::Test::SetUp(); | 
| 188 constexpr bool is_root = true; | 980 | 
| 189 constexpr bool is_child_root = false; | |
| 190 constexpr bool handles_frame_sink_id_invalidation = true; | |
| 191 constexpr bool needs_sync_points = true; | |
| 192 begin_frame_source_ = | 981 begin_frame_source_ = | 
| 193 base::MakeUnique<FakeExternalBeginFrameSource>(0.f, false); | 982 base::MakeUnique<FakeExternalBeginFrameSource>(0.f, false); | 
| 194 surface_manager_.SetDependencyTracker( | 983 surface_manager_.SetDependencyTracker( | 
| 195 base::MakeUnique<SurfaceDependencyTracker>(&surface_manager_, | 984 base::MakeUnique<SurfaceDependencyTracker>(&surface_manager_, | 
| 196 begin_frame_source_.get())); | 985 begin_frame_source_.get())); | 
| 197 surface_manager_.AddObserver(this); | 986 surface_manager_.AddObserver(this); | 
| 198 supports_.push_back(CompositorFrameSinkSupport::Create( | 987 supports_.push_back(CompositorFrameSinkSupport::Create( | 
| 199 &support_client_, &surface_manager_, kDisplayFrameSink, is_root, | 988 &support_client_, &surface_manager_, kDisplayFrameSink, kIsRoot, | 
| 200 handles_frame_sink_id_invalidation, needs_sync_points)); | 989 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); | 
| 201 supports_.push_back(CompositorFrameSinkSupport::Create( | 990 supports_.push_back(CompositorFrameSinkSupport::Create( | 
| 202 &support_client_, &surface_manager_, kParentFrameSink, is_child_root, | 991 &support_client_, &surface_manager_, kParentFrameSink, kIsChildRoot, | 
| 203 handles_frame_sink_id_invalidation, needs_sync_points)); | 992 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); | 
| 204 supports_.push_back(CompositorFrameSinkSupport::Create( | 993 supports_.push_back(CompositorFrameSinkSupport::Create( | 
| 205 &support_client_, &surface_manager_, kChildFrameSink1, is_child_root, | 994 &support_client_, &surface_manager_, kChildFrameSink1, kIsChildRoot, | 
| 206 handles_frame_sink_id_invalidation, needs_sync_points)); | 995 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); | 
| 207 supports_.push_back(CompositorFrameSinkSupport::Create( | 996 supports_.push_back(CompositorFrameSinkSupport::Create( | 
| 208 &support_client_, &surface_manager_, kChildFrameSink2, is_child_root, | 997 &support_client_, &surface_manager_, kChildFrameSink2, kIsChildRoot, | 
| 209 handles_frame_sink_id_invalidation, needs_sync_points)); | 998 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); | 
| 210 | 999 | 
| 211 // Normally, the BeginFrameSource would be registered by the Display. We | 1000 // Normally, the BeginFrameSource would be registered by the Display. We | 
| 212 // register it here so that BeginFrames are received by the display support, | 1001 // register it here so that BeginFrames are received by the display support, | 
| 213 // for use in the PassesOnBeginFrameAcks test. Other supports do not receive | 1002 // for use in the PassesOnBeginFrameAcks test. Other supports do not receive | 
| 214 // BeginFrames, since the frame sink hierarchy is not set up in this test. | 1003 // BeginFrames, since the frame sink hierarchy is not set up in this test. | 
| 215 surface_manager_.RegisterBeginFrameSource(begin_frame_source_.get(), | 1004 surface_manager_.RegisterBeginFrameSource(begin_frame_source_.get(), | 
| 216 kDisplayFrameSink); | 1005 kDisplayFrameSink); | 
| 217 } | 1006 } | 
| 218 | 1007 | 
| 219 void TearDown() override { | 1008 void TearDown() override { | 
| (...skipping 22 matching lines...) Expand all Loading... | |
| 242 | 1031 | 
| 243 protected: | 1032 protected: | 
| 244 testing::NiceMock<MockCompositorFrameSinkSupportClient> support_client_; | 1033 testing::NiceMock<MockCompositorFrameSinkSupportClient> support_client_; | 
| 245 | 1034 | 
| 246 private: | 1035 private: | 
| 247 base::flat_set<SurfaceId> damaged_surfaces_; | 1036 base::flat_set<SurfaceId> damaged_surfaces_; | 
| 248 SurfaceManager surface_manager_; | 1037 SurfaceManager surface_manager_; | 
| 249 std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; | 1038 std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; | 
| 250 std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; | 1039 std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; | 
| 251 | 1040 | 
| 252 DISALLOW_COPY_AND_ASSIGN(CompositorFrameSinkSupportTest); | 1041 DISALLOW_COPY_AND_ASSIGN(SurfaceReferenceTest); | 
| 253 }; | 1042 }; | 
| 254 | 1043 | 
| 255 // The display root surface should have a surface reference from the top-level | 1044 // The display root surface should have a surface reference from the top-level | 
| 256 // root added/removed when a CompositorFrame is submitted with a new SurfaceId. | 1045 // root added/removed when a CompositorFrame is submitted with a new SurfaceId. | 
| 257 TEST_F(CompositorFrameSinkSupportTest, RootSurfaceReceivesReferences) { | 1046 TEST_F(SurfaceReferenceTest, RootSurfaceReceivesReferences) { | 
| 258 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); | 1047 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); | 
| 259 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); | 1048 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); | 
| 260 | 1049 | 
| 261 // Submit a CompositorFrame for the first display root surface. | 1050 // Submit a CompositorFrame for the first display root surface. | 
| 262 display_support().SubmitCompositorFrame(display_id_first.local_surface_id(), | 1051 display_support().SubmitCompositorFrame(display_id_first.local_surface_id(), | 
| 263 MakeCompositorFrame()); | 1052 MakeCompositorFrame()); | 
| 264 | 1053 | 
| 265 // A surface reference from the top-level root is added and there shouldn't be | 1054 // A surface reference from the top-level root is added and there shouldn't be | 
| 266 // a temporary reference. | 1055 // a temporary reference. | 
| 267 EXPECT_FALSE(HasTemporaryReference(display_id_first)); | 1056 EXPECT_FALSE(HasTemporaryReference(display_id_first)); | 
| 268 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), | 1057 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), | 
| 269 UnorderedElementsAre(display_id_first)); | 1058 UnorderedElementsAre(display_id_first)); | 
| 270 | 1059 | 
| 271 // Submit a CompositorFrame for the second display root surface. | 1060 // Submit a CompositorFrame for the second display root surface. | 
| 272 display_support().SubmitCompositorFrame(display_id_second.local_surface_id(), | 1061 display_support().SubmitCompositorFrame(display_id_second.local_surface_id(), | 
| 273 MakeCompositorFrame()); | 1062 MakeCompositorFrame()); | 
| 274 | 1063 | 
| 275 // A surface reference from the top-level root to |display_id_second| should | 1064 // A surface reference from the top-level root to |display_id_second| should | 
| 276 // be added and the reference to |display_root_first| removed. | 1065 // be added and the reference to |display_root_first| removed. | 
| 277 EXPECT_FALSE(HasTemporaryReference(display_id_second)); | 1066 EXPECT_FALSE(HasTemporaryReference(display_id_second)); | 
| 278 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), | 1067 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), | 
| 279 UnorderedElementsAre(display_id_second)); | 1068 UnorderedElementsAre(display_id_second)); | 
| 280 | 1069 | 
| 281 // Surface |display_id_first| is unreachable and should get deleted. | 1070 // Surface |display_id_first| is unreachable and should get deleted. | 
| 282 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(display_id_first)); | 1071 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(display_id_first)); | 
| 283 } | 1072 } | 
| 284 | 1073 | 
| 285 // The parent Surface is blocked on |child_id1| and |child_id2|. | 1074 // The parent Surface is blocked on |child_id1| and |child_id2|. | 
| 286 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedOnTwo) { | 1075 TEST_F(SurfaceReferenceTest, DisplayCompositorLockingBlockedOnTwo) { | 
| 
 
Fady Samuel
2017/04/26 00:44:13
Please rename "SurfaceReferenceTest" to SurfaceSyn
 
Alex Z.
2017/04/27 22:10:01
Done.
 
 | |
| 287 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1076 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 288 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 1077 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 
| 289 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 1078 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 
| 290 | 1079 | 
| 291 parent_support().SubmitCompositorFrame( | 1080 parent_support().SubmitCompositorFrame( | 
| 292 parent_id.local_surface_id(), | 1081 parent_id.local_surface_id(), | 
| 293 MakeCompositorFrame({child_id1, child_id2})); | 1082 MakeCompositorFrame({child_id1, child_id2})); | 
| 294 | 1083 | 
| 295 // parent_support is blocked on |child_id1| and |child_id2|. | 1084 // parent_support is blocked on |child_id1| and |child_id2|. | 
| 296 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1085 EXPECT_TRUE(dependency_tracker().has_deadline()); | 
| (...skipping 18 matching lines...) Expand all Loading... | |
| 315 child_support2().SubmitCompositorFrame( | 1104 child_support2().SubmitCompositorFrame( | 
| 316 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 1105 child_id2.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 
| 317 | 1106 | 
| 318 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1107 EXPECT_FALSE(dependency_tracker().has_deadline()); | 
| 319 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 1108 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 
| 320 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1109 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 
| 321 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1110 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 322 } | 1111 } | 
| 323 | 1112 | 
| 324 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. | 1113 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. | 
| 325 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedChain) { | 1114 TEST_F(SurfaceReferenceTest, DisplayCompositorLockingBlockedChain) { | 
| 326 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1115 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 327 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 1116 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 
| 328 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 1117 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 
| 329 | 1118 | 
| 330 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1119 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 
| 331 MakeCompositorFrame({child_id1})); | 1120 MakeCompositorFrame({child_id1})); | 
| 332 | 1121 | 
| 333 // parent_support is blocked on |child_id1|. | 1122 // parent_support is blocked on |child_id1|. | 
| 334 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1123 EXPECT_TRUE(dependency_tracker().has_deadline()); | 
| 335 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 1124 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1163 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 375 | 1164 | 
| 376 // All three surfaces |parent_id|, |child_id1|, and |child_id2| should | 1165 // All three surfaces |parent_id|, |child_id1|, and |child_id2| should | 
| 377 // now report damage. This would trigger a new display frame. | 1166 // now report damage. This would trigger a new display frame. | 
| 378 EXPECT_TRUE(IsSurfaceDamaged(parent_id)); | 1167 EXPECT_TRUE(IsSurfaceDamaged(parent_id)); | 
| 379 EXPECT_TRUE(IsSurfaceDamaged(child_id1)); | 1168 EXPECT_TRUE(IsSurfaceDamaged(child_id1)); | 
| 380 EXPECT_TRUE(IsSurfaceDamaged(child_id2)); | 1169 EXPECT_TRUE(IsSurfaceDamaged(child_id2)); | 
| 381 } | 1170 } | 
| 382 | 1171 | 
| 383 // parent_surface and child_surface1 are blocked on |child_id2|. | 1172 // parent_surface and child_surface1 are blocked on |child_id2|. | 
| 384 TEST_F(CompositorFrameSinkSupportTest, | 1173 TEST_F(SurfaceReferenceTest, DisplayCompositorLockingTwoBlockedOnOne) { | 
| 385 DisplayCompositorLockingTwoBlockedOnOne) { | |
| 386 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1174 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 387 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 1175 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 
| 388 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 1176 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 
| 389 | 1177 | 
| 390 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1178 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 
| 391 MakeCompositorFrame({child_id2})); | 1179 MakeCompositorFrame({child_id2})); | 
| 392 | 1180 | 
| 393 // parent_support is blocked on |child_id2|. | 1181 // parent_support is blocked on |child_id2|. | 
| 394 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1182 EXPECT_TRUE(dependency_tracker().has_deadline()); | 
| 395 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 1183 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 
| (...skipping 28 matching lines...) Expand all Loading... | |
| 424 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 1212 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 
| 425 | 1213 | 
| 426 // parent_surface should now be active. | 1214 // parent_surface should now be active. | 
| 427 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 1215 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 
| 428 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1216 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 
| 429 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1217 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 430 } | 1218 } | 
| 431 | 1219 | 
| 432 // parent_surface is blocked on |child_id1|, and child_surface2 is blocked on | 1220 // parent_surface is blocked on |child_id1|, and child_surface2 is blocked on | 
| 433 // |child_id2| until the deadline hits. | 1221 // |child_id2| until the deadline hits. | 
| 434 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingDeadlineHits) { | 1222 TEST_F(SurfaceReferenceTest, DisplayCompositorLockingDeadlineHits) { | 
| 435 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1223 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 436 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 1224 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 
| 437 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 1225 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 
| 438 | 1226 | 
| 439 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1227 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 
| 440 MakeCompositorFrame({child_id1})); | 1228 MakeCompositorFrame({child_id1})); | 
| 441 | 1229 | 
| 442 // parent_support is blocked on |child_id1|. | 1230 // parent_support is blocked on |child_id1|. | 
| 443 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1231 EXPECT_TRUE(dependency_tracker().has_deadline()); | 
| 444 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 1232 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 492 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1280 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 493 | 1281 | 
| 494 // child_surface1 has been activated. | 1282 // child_surface1 has been activated. | 
| 495 EXPECT_TRUE(child_surface1()->HasActiveFrame()); | 1283 EXPECT_TRUE(child_surface1()->HasActiveFrame()); | 
| 496 EXPECT_FALSE(child_surface1()->HasPendingFrame()); | 1284 EXPECT_FALSE(child_surface1()->HasPendingFrame()); | 
| 497 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 1285 EXPECT_THAT(child_surface1()->blocking_surfaces(), IsEmpty()); | 
| 498 } | 1286 } | 
| 499 | 1287 | 
| 500 // Verifies that the deadline does not reset if we submit CompositorFrames | 1288 // Verifies that the deadline does not reset if we submit CompositorFrames | 
| 501 // to new Surfaces with unresolved dependencies. | 1289 // to new Surfaces with unresolved dependencies. | 
| 502 TEST_F(CompositorFrameSinkSupportTest, | 1290 TEST_F(SurfaceReferenceTest, | 
| 503 DisplayCompositorLockingFramesSubmittedAfterDeadlineSet) { | 1291 DisplayCompositorLockingFramesSubmittedAfterDeadlineSet) { | 
| 504 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); | 1292 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); | 
| 505 BeginFrameArgs args = | 1293 BeginFrameArgs args = | 
| 506 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 1294 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 
| 507 for (int i = 0; i < 3; ++i) { | 1295 for (int i = 0; i < 3; ++i) { | 
| 508 LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); | 1296 LocalSurfaceId local_surface_id(1, base::UnguessableToken::Create()); | 
| 509 support(i).SubmitCompositorFrame(local_surface_id, | 1297 support(i).SubmitCompositorFrame(local_surface_id, | 
| 510 MakeCompositorFrame({arbitrary_id})); | 1298 MakeCompositorFrame({arbitrary_id})); | 
| 511 // The deadline has been set. | 1299 // The deadline has been set. | 
| 512 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1300 EXPECT_TRUE(dependency_tracker().has_deadline()); | 
| (...skipping 12 matching lines...) Expand all Loading... | |
| 525 begin_frame_source()->TestOnBeginFrame(args); | 1313 begin_frame_source()->TestOnBeginFrame(args); | 
| 526 for (int i = 0; i < 3; ++i) { | 1314 for (int i = 0; i < 3; ++i) { | 
| 527 EXPECT_TRUE(surface(i)->HasActiveFrame()); | 1315 EXPECT_TRUE(surface(i)->HasActiveFrame()); | 
| 528 EXPECT_FALSE(surface(i)->HasPendingFrame()); | 1316 EXPECT_FALSE(surface(i)->HasPendingFrame()); | 
| 529 EXPECT_THAT(surface(i)->blocking_surfaces(), IsEmpty()); | 1317 EXPECT_THAT(surface(i)->blocking_surfaces(), IsEmpty()); | 
| 530 } | 1318 } | 
| 531 } | 1319 } | 
| 532 | 1320 | 
| 533 // This test verifies at the Surface activates once a CompositorFrame is | 1321 // This test verifies at the Surface activates once a CompositorFrame is | 
| 534 // submitted that has no unresolved dependencies. | 1322 // submitted that has no unresolved dependencies. | 
| 535 TEST_F(CompositorFrameSinkSupportTest, | 1323 TEST_F(SurfaceReferenceTest, | 
| 536 DisplayCompositorLockingNewFrameOverridesOldDependencies) { | 1324 DisplayCompositorLockingNewFrameOverridesOldDependencies) { | 
| 537 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1325 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 538 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); | 1326 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1); | 
| 539 | 1327 | 
| 540 // Submit a CompositorFrame that depends on |arbitrary_id|. | 1328 // Submit a CompositorFrame that depends on |arbitrary_id|. | 
| 541 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1329 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 
| 542 MakeCompositorFrame({arbitrary_id})); | 1330 MakeCompositorFrame({arbitrary_id})); | 
| 543 | 1331 | 
| 544 // Verify that the CompositorFrame is blocked on |arbitrary_id|. | 1332 // Verify that the CompositorFrame is blocked on |arbitrary_id|. | 
| 545 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 1333 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 
| 546 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 1334 EXPECT_TRUE(parent_surface()->HasPendingFrame()); | 
| 547 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 1335 EXPECT_THAT(parent_surface()->blocking_surfaces(), | 
| 548 UnorderedElementsAre(arbitrary_id)); | 1336 UnorderedElementsAre(arbitrary_id)); | 
| 549 | 1337 | 
| 550 // Submit a CompositorFrame that has no dependencies. | 1338 // Submit a CompositorFrame that has no dependencies. | 
| 551 parent_support().SubmitCompositorFrame( | 1339 parent_support().SubmitCompositorFrame( | 
| 552 parent_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 1340 parent_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); | 
| 553 | 1341 | 
| 554 // Verify that the CompositorFrame has been activated. | 1342 // Verify that the CompositorFrame has been activated. | 
| 555 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 1343 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 
| 556 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1344 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 
| 557 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1345 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 558 } | 1346 } | 
| 559 | 1347 | 
| 560 // This test verifies that a pending CompositorFrame does not affect surface | 1348 // This test verifies that a pending CompositorFrame does not affect surface | 
| 561 // references. A new surface from a child will continue to exist as a temporary | 1349 // references. A new surface from a child will continue to exist as a temporary | 
| 562 // reference until the parent's frame activates. | 1350 // reference until the parent's frame activates. | 
| 563 TEST_F(CompositorFrameSinkSupportTest, | 1351 TEST_F(SurfaceReferenceTest, OnlyActiveFramesAffectSurfaceReferences) { | 
| 564 OnlyActiveFramesAffectSurfaceReferences) { | |
| 565 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1352 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 566 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 1353 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 
| 567 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 1354 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 
| 568 | 1355 | 
| 569 // child_support1 submits a CompositorFrame without any dependencies. | 1356 // child_support1 submits a CompositorFrame without any dependencies. | 
| 570 // DidReceiveCompositorFrameAck should call on immediate activation. | 1357 // DidReceiveCompositorFrameAck should call on immediate activation. | 
| 571 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(1); | 1358 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(1); | 
| 572 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), | 1359 child_support1().SubmitCompositorFrame(child_id1.local_surface_id(), | 
| 573 MakeCompositorFrame()); | 1360 MakeCompositorFrame()); | 
| 574 testing::Mock::VerifyAndClearExpectations(&support_client_); | 1361 testing::Mock::VerifyAndClearExpectations(&support_client_); | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1407 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 
| 621 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1408 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 622 EXPECT_FALSE(HasTemporaryReference(child_id1)); | 1409 EXPECT_FALSE(HasTemporaryReference(child_id1)); | 
| 623 EXPECT_THAT(GetChildReferences(parent_id), | 1410 EXPECT_THAT(GetChildReferences(parent_id), | 
| 624 UnorderedElementsAre(child_id1, child_id2)); | 1411 UnorderedElementsAre(child_id1, child_id2)); | 
| 625 } | 1412 } | 
| 626 | 1413 | 
| 627 // This test verifies that we do not double count returned resources when a | 1414 // This test verifies that we do not double count returned resources when a | 
| 628 // CompositorFrame starts out as pending, then becomes active, and then is | 1415 // CompositorFrame starts out as pending, then becomes active, and then is | 
| 629 // replaced with another active CompositorFrame. | 1416 // replaced with another active CompositorFrame. | 
| 630 TEST_F(CompositorFrameSinkSupportTest, | 1417 TEST_F(SurfaceReferenceTest, | 
| 631 DisplayCompositorLockingResourcesOnlyReturnedOnce) { | 1418 DisplayCompositorLockingResourcesOnlyReturnedOnce) { | 
| 632 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1419 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 633 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 1420 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 
| 634 | 1421 | 
| 635 // The parent submits a CompositorFrame that depends on |child_id| before the | 1422 // The parent submits a CompositorFrame that depends on |child_id| before the | 
| 636 // child submits a CompositorFrame. The CompositorFrame also has resources in | 1423 // child submits a CompositorFrame. The CompositorFrame also has resources in | 
| 637 // its resource list. | 1424 // its resource list. | 
| 638 TransferableResource resource = | 1425 TransferableResource resource = | 
| 639 MakeResource(1337 /* id */, ALPHA_8 /* format */, 1234 /* filter */, | 1426 MakeResource(1337 /* id */, ALPHA_8 /* format */, 1234 /* filter */, | 
| 640 gfx::Size(1234, 5678)); | 1427 gfx::Size(1234, 5678)); | 
| (...skipping 30 matching lines...) Expand all Loading... | |
| 671 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1458 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 
| 672 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1459 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 673 ReturnedResource returned_resource = resource.ToReturnedResource(); | 1460 ReturnedResource returned_resource = resource.ToReturnedResource(); | 
| 674 EXPECT_THAT(support_client_.last_returned_resources(), | 1461 EXPECT_THAT(support_client_.last_returned_resources(), | 
| 675 UnorderedElementsAre(returned_resource)); | 1462 UnorderedElementsAre(returned_resource)); | 
| 676 } | 1463 } | 
| 677 | 1464 | 
| 678 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. | 1465 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. | 
| 679 // child_support1 evicts its blocked Surface. The parent surface should | 1466 // child_support1 evicts its blocked Surface. The parent surface should | 
| 680 // activate. | 1467 // activate. | 
| 681 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { | 1468 TEST_F(SurfaceReferenceTest, EvictSurfaceWithPendingFrame) { | 
| 682 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1469 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 
| 683 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 1470 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 
| 684 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 1471 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 
| 685 | 1472 | 
| 686 // Submit a CompositorFrame that depends on |child_id1|. | 1473 // Submit a CompositorFrame that depends on |child_id1|. | 
| 687 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 1474 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 
| 688 MakeCompositorFrame({child_id1})); | 1475 MakeCompositorFrame({child_id1})); | 
| 689 | 1476 | 
| 690 // Verify that the CompositorFrame is blocked on |child_id1|. | 1477 // Verify that the CompositorFrame is blocked on |child_id1|. | 
| 691 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 1478 EXPECT_FALSE(parent_surface()->HasActiveFrame()); | 
| (...skipping 20 matching lines...) Expand all Loading... | |
| 712 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1499 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 
| 713 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1500 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 714 EXPECT_FALSE(dependency_tracker().has_deadline()); | 1501 EXPECT_FALSE(dependency_tracker().has_deadline()); | 
| 715 } | 1502 } | 
| 716 | 1503 | 
| 717 // This test verifies that if a surface has both a pending and active | 1504 // This test verifies that if a surface has both a pending and active | 
| 718 // CompositorFrame and the pending CompositorFrame activates, replacing the | 1505 // CompositorFrame and the pending CompositorFrame activates, replacing the | 
| 719 // existing active CompositorFrame, then the surface reference hierarchy will be | 1506 // existing active CompositorFrame, then the surface reference hierarchy will be | 
| 720 // updated allowing garbage collection of surfaces that are no longer | 1507 // updated allowing garbage collection of surfaces that are no longer | 
| 721 // referenced. | 1508 // referenced. | 
| 722 TEST_F(CompositorFrameSinkSupportTest, DropStaleReferencesAfterActivation) { | 1509 TEST_F(SurfaceReferenceTest, DropStaleReferencesAfterActivation) { | 
| 723 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1510 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 724 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 1511 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 
| 725 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 1512 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); | 
| 726 | 1513 | 
| 727 // The parent submits a CompositorFrame that depends on |child_id1| before the | 1514 // The parent submits a CompositorFrame that depends on |child_id1| before the | 
| 728 // child submits a CompositorFrame. | 1515 // child submits a CompositorFrame. | 
| 729 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); | 1516 EXPECT_CALL(support_client_, DidReceiveCompositorFrameAck(_)).Times(0); | 
| 730 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1517 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 
| 731 MakeCompositorFrame({child_id1})); | 1518 MakeCompositorFrame({child_id1})); | 
| 732 | 1519 | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 785 // CompositorFrame. Also verify that |child_id1| is no longer a child | 1572 // CompositorFrame. Also verify that |child_id1| is no longer a child | 
| 786 // reference of |parent_id|. | 1573 // reference of |parent_id|. | 
| 787 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 1574 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 
| 788 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 1575 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 
| 789 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 1576 EXPECT_THAT(parent_surface()->blocking_surfaces(), IsEmpty()); | 
| 790 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2)); | 1577 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2)); | 
| 791 } | 1578 } | 
| 792 | 1579 | 
| 793 // Checks whether the latency info are moved to the new surface from the old | 1580 // Checks whether the latency info are moved to the new surface from the old | 
| 794 // one when LocalSurfaceId changes. No frame has unresolved dependencies. | 1581 // one when LocalSurfaceId changes. No frame has unresolved dependencies. | 
| 795 TEST_F(CompositorFrameSinkSupportTest, | 1582 TEST_F(SurfaceReferenceTest, | 
| 796 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) { | 1583 LatencyInfoCarriedOverOnResize_NoUnresolvedDependencies) { | 
| 797 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1584 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 
| 798 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 1585 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 
| 799 const ui::LatencyComponentType latency_type1 = | 1586 const ui::LatencyComponentType latency_type1 = | 
| 800 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 1587 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 
| 801 const int64_t latency_id1 = 234; | 1588 const int64_t latency_id1 = 234; | 
| 802 const int64_t latency_sequence_number1 = 5645432; | 1589 const int64_t latency_sequence_number1 = 5645432; | 
| 803 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 1590 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 
| 804 const int64_t latency_id2 = 31434351; | 1591 const int64_t latency_id2 = 31434351; | 
| 805 const int64_t latency_sequence_number2 = 663788; | 1592 const int64_t latency_sequence_number2 = 663788; | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 855 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 1642 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 
| 856 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 1643 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 
| 857 EXPECT_TRUE( | 1644 EXPECT_TRUE( | 
| 858 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 1645 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 
| 859 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 1646 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 
| 860 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 1647 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 
| 861 } | 1648 } | 
| 862 | 1649 | 
| 863 // Checks whether the latency info are moved to the new surface from the old | 1650 // Checks whether the latency info are moved to the new surface from the old | 
| 864 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. | 1651 // one when LocalSurfaceId changes. Old surface has unresolved dependencies. | 
| 865 TEST_F(CompositorFrameSinkSupportTest, | 1652 TEST_F(SurfaceReferenceTest, | 
| 866 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { | 1653 LatencyInfoCarriedOverOnResize_OldSurfaceHasPendingAndActiveFrame) { | 
| 867 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1654 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 
| 868 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 1655 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 
| 869 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 1656 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 
| 870 | 1657 | 
| 871 const ui::LatencyComponentType latency_type1 = | 1658 const ui::LatencyComponentType latency_type1 = | 
| 872 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 1659 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 
| 873 const int64_t latency_id1 = 234; | 1660 const int64_t latency_id1 = 234; | 
| 874 const int64_t latency_sequence_number1 = 5645432; | 1661 const int64_t latency_sequence_number1 = 5645432; | 
| 875 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 1662 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 931 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 1718 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 
| 932 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 1719 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 
| 933 EXPECT_TRUE( | 1720 EXPECT_TRUE( | 
| 934 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 1721 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 
| 935 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 1722 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 
| 936 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 1723 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 
| 937 } | 1724 } | 
| 938 | 1725 | 
| 939 // Checks whether the latency info are moved to the new surface from the old | 1726 // Checks whether the latency info are moved to the new surface from the old | 
| 940 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. | 1727 // one when LocalSurfaceId changes. The new surface has unresolved dependencies. | 
| 941 TEST_F(CompositorFrameSinkSupportTest, | 1728 TEST_F(SurfaceReferenceTest, | 
| 942 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { | 1729 LatencyInfoCarriedOverOnResize_NewSurfaceHasPendingFrame) { | 
| 943 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1730 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 
| 944 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 1731 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 
| 945 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 1732 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 
| 946 | 1733 | 
| 947 const ui::LatencyComponentType latency_type1 = | 1734 const ui::LatencyComponentType latency_type1 = | 
| 948 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 1735 ui::BROWSER_SNAPSHOT_FRAME_NUMBER_COMPONENT; | 
| 949 const int64_t latency_id1 = 234; | 1736 const int64_t latency_id1 = 234; | 
| 950 const int64_t latency_sequence_number1 = 5645432; | 1737 const int64_t latency_sequence_number1 = 5645432; | 
| 951 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 1738 const ui::LatencyComponentType latency_type2 = ui::TAB_SHOW_COMPONENT; | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1008 ui::LatencyInfo::LatencyComponent comp1; | 1795 ui::LatencyInfo::LatencyComponent comp1; | 
| 1009 EXPECT_TRUE( | 1796 EXPECT_TRUE( | 
| 1010 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 1797 aggregated_latency_info.FindLatency(latency_type1, latency_id1, &comp1)); | 
| 1011 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 1798 EXPECT_EQ(latency_sequence_number1, comp1.sequence_number); | 
| 1012 EXPECT_TRUE( | 1799 EXPECT_TRUE( | 
| 1013 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 1800 aggregated_latency_info.FindLatency(latency_type2, latency_id2, nullptr)); | 
| 1014 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 1801 EXPECT_TRUE(aggregated_latency_info.FindLatency( | 
| 1015 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 1802 ui::DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT, nullptr)); | 
| 1016 } | 1803 } | 
| 1017 | 1804 | 
| 1018 TEST_F(CompositorFrameSinkSupportTest, PassesOnBeginFrameAcks) { | 1805 TEST_F(SurfaceReferenceTest, PassesOnBeginFrameAcks) { | 
| 1019 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 1806 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 
| 1020 | 1807 | 
| 1021 // Request BeginFrames. | 1808 // Request BeginFrames. | 
| 1022 display_support().SetNeedsBeginFrame(true); | 1809 display_support().SetNeedsBeginFrame(true); | 
| 1023 | 1810 | 
| 1024 // Issue a BeginFrame. | 1811 // Issue a BeginFrame. | 
| 1025 BeginFrameArgs args = | 1812 BeginFrameArgs args = | 
| 1026 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 1813 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, 0, 1); | 
| 1027 begin_frame_source()->TestOnBeginFrame(args); | 1814 begin_frame_source()->TestOnBeginFrame(args); | 
| 1028 | 1815 | 
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1040 // to a CompositorFrame to the BeginFrameSource. | 1827 // to a CompositorFrame to the BeginFrameSource. | 
| 1041 BeginFrameAck ack2(0, 2, 2, true); | 1828 BeginFrameAck ack2(0, 2, 2, true); | 
| 1042 CompositorFrame frame = MakeCompositorFrame(); | 1829 CompositorFrame frame = MakeCompositorFrame(); | 
| 1043 frame.metadata.begin_frame_ack = ack2; | 1830 frame.metadata.begin_frame_ack = ack2; | 
| 1044 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1831 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 
| 1045 std::move(frame)); | 1832 std::move(frame)); | 
| 1046 EXPECT_EQ(ack2, begin_frame_source()->LastAckForObserver(&display_support())); | 1833 EXPECT_EQ(ack2, begin_frame_source()->LastAckForObserver(&display_support())); | 
| 1047 } | 1834 } | 
| 1048 | 1835 | 
| 1049 // Checks that resources and ack are sent together if possible. | 1836 // Checks that resources and ack are sent together if possible. | 
| 1050 TEST_F(CompositorFrameSinkSupportTest, ReturnResourcesWithAck) { | 1837 TEST_F(SurfaceReferenceTest, ReturnResourcesWithAck) { | 
| 1051 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1838 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 1052 TransferableResource resource; | 1839 TransferableResource resource; | 
| 1053 resource.id = 1234; | 1840 resource.id = 1234; | 
| 1054 parent_support().SubmitCompositorFrame( | 1841 parent_support().SubmitCompositorFrame( | 
| 1055 parent_id.local_surface_id(), | 1842 parent_id.local_surface_id(), | 
| 1056 MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); | 1843 MakeCompositorFrameWithResources(empty_surface_ids(), {resource})); | 
| 1057 ReturnedResourceArray returned_resources; | 1844 ReturnedResourceArray returned_resources; | 
| 1058 TransferableResource::ReturnResources({resource}, &returned_resources); | 1845 TransferableResource::ReturnResources({resource}, &returned_resources); | 
| 1059 EXPECT_CALL(support_client_, ReclaimResources(_)).Times(0); | 1846 EXPECT_CALL(support_client_, ReclaimResources(_)).Times(0); | 
| 1060 EXPECT_CALL(support_client_, | 1847 EXPECT_CALL(support_client_, | 
| 1061 DidReceiveCompositorFrameAck(Eq(returned_resources))); | 1848 DidReceiveCompositorFrameAck(Eq(returned_resources))); | 
| 1062 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1849 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 
| 1063 MakeCompositorFrame()); | 1850 MakeCompositorFrame()); | 
| 1064 } | 1851 } | 
| 1065 | 1852 | 
| 1066 // Verifies that if a surface is marked destroyed and a new frame arrives for | 1853 // Verifies that if a surface is marked destroyed and a new frame arrives for | 
| 1067 // it, it will be recovered. | 1854 // it, it will be recovered. | 
| 1068 TEST_F(CompositorFrameSinkSupportTest, SurfaceResurrection) { | 1855 TEST_F(SurfaceReferenceTest, SurfaceResurrection) { | 
| 1069 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1856 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 1070 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); | 1857 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); | 
| 1071 | 1858 | 
| 1072 // Add a reference from the parent to the child. | 1859 // Add a reference from the parent to the child. | 
| 1073 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1860 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 
| 1074 MakeCompositorFrame({child_id})); | 1861 MakeCompositorFrame({child_id})); | 
| 1075 | 1862 | 
| 1076 // Create the child surface by submitting a frame to it. | 1863 // Create the child surface by submitting a frame to it. | 
| 1077 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1864 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(child_id)); | 
| 1078 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1865 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1096 | 1883 | 
| 1097 // Verify that the surface that was marked destroyed is recovered and is being | 1884 // Verify that the surface that was marked destroyed is recovered and is being | 
| 1098 // used again. | 1885 // used again. | 
| 1099 Surface* surface2 = surface_manager().GetSurfaceForId(child_id); | 1886 Surface* surface2 = surface_manager().GetSurfaceForId(child_id); | 
| 1100 EXPECT_EQ(surface, surface2); | 1887 EXPECT_EQ(surface, surface2); | 
| 1101 EXPECT_FALSE(surface2->destroyed()); | 1888 EXPECT_FALSE(surface2->destroyed()); | 
| 1102 } | 1889 } | 
| 1103 | 1890 | 
| 1104 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist | 1891 // Verifies that if a LocalSurfaceId belonged to a surface that doesn't exist | 
| 1105 // anymore, it can still be reused for new surfaces. | 1892 // anymore, it can still be reused for new surfaces. | 
| 1106 TEST_F(CompositorFrameSinkSupportTest, LocalSurfaceIdIsReusable) { | 1893 TEST_F(SurfaceReferenceTest, LocalSurfaceIdIsReusable) { | 
| 1107 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 1894 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); | 
| 1108 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); | 1895 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 3); | 
| 1109 | 1896 | 
| 1110 // Add a reference from parent. | 1897 // Add a reference from parent. | 
| 1111 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 1898 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), | 
| 1112 MakeCompositorFrame({child_id})); | 1899 MakeCompositorFrame({child_id})); | 
| 1113 | 1900 | 
| 1114 // Submit the first frame. Creates the surface. | 1901 // Submit the first frame. Creates the surface. | 
| 1115 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 1902 child_support1().SubmitCompositorFrame(child_id.local_surface_id(), | 
| 1116 MakeCompositorFrame()); | 1903 MakeCompositorFrame()); | 
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1131 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); | 1918 EXPECT_NE(nullptr, surface_manager().GetSurfaceForId(child_id)); | 
| 1132 } | 1919 } | 
| 1133 | 1920 | 
| 1134 // This test verifies that a crash does not occur if garbage collection is | 1921 // This test verifies that a crash does not occur if garbage collection is | 
| 1135 // triggered during surface dependency resolution. This test triggers garbage | 1922 // triggered during surface dependency resolution. This test triggers garbage | 
| 1136 // collection during surface resolution, by causing an activation to remove | 1923 // collection during surface resolution, by causing an activation to remove | 
| 1137 // a surface subtree from the root. Both the old subtree and the new | 1924 // a surface subtree from the root. Both the old subtree and the new | 
| 1138 // activated subtree refer to the same dependency. The old subtree was activated | 1925 // activated subtree refer to the same dependency. The old subtree was activated | 
| 1139 // by deadline, and the new subtree was activated by a dependency finally | 1926 // by deadline, and the new subtree was activated by a dependency finally | 
| 1140 // resolving. | 1927 // resolving. | 
| 1141 TEST_F(CompositorFrameSinkSupportTest, DependencyTrackingGarbageCollection) { | 1928 TEST_F(SurfaceReferenceTest, DependencyTrackingGarbageCollection) { | 
| 1142 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 1929 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 
| 1143 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1930 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 
| 1144 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 1931 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 
| 1145 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 1932 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 
| 1146 | 1933 | 
| 1147 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 1934 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 
| 1148 MakeCompositorFrame({child_id})); | 1935 MakeCompositorFrame({child_id})); | 
| 1149 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1936 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 
| 1150 MakeCompositorFrame({parent_id1})); | 1937 MakeCompositorFrame({parent_id1})); | 
| 1151 | 1938 | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1185 } | 1972 } | 
| 1186 | 1973 | 
| 1187 // This test verifies that a crash does not occur if garbage collection is | 1974 // This test verifies that a crash does not occur if garbage collection is | 
| 1188 // triggered when a deadline forces frame activation. This test triggers garbage | 1975 // triggered when a deadline forces frame activation. This test triggers garbage | 
| 1189 // collection during deadline activation by causing the activation of a display | 1976 // collection during deadline activation by causing the activation of a display | 
| 1190 // frame to replace a previously activated display frame that was referring to | 1977 // frame to replace a previously activated display frame that was referring to | 
| 1191 // a now-unreachable surface subtree. That subtree gets garbage collected during | 1978 // a now-unreachable surface subtree. That subtree gets garbage collected during | 
| 1192 // deadline activation. SurfaceDependencyTracker is also tracking a surface | 1979 // deadline activation. SurfaceDependencyTracker is also tracking a surface | 
| 1193 // from that subtree due to an unresolved dependency. This test verifies that | 1980 // from that subtree due to an unresolved dependency. This test verifies that | 
| 1194 // this dependency resolution does not crash. | 1981 // this dependency resolution does not crash. | 
| 1195 TEST_F(CompositorFrameSinkSupportTest, GarbageCollectionOnDeadline) { | 1982 TEST_F(SurfaceReferenceTest, GarbageCollectionOnDeadline) { | 
| 1196 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 1983 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 
| 1197 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 1984 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 
| 1198 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 1985 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 
| 1199 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 1986 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); | 
| 1200 | 1987 | 
| 1201 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 1988 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 
| 1202 MakeCompositorFrame({parent_id1})); | 1989 MakeCompositorFrame({parent_id1})); | 
| 1203 | 1990 | 
| 1204 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 1991 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 
| 1205 EXPECT_TRUE(dependency_tracker().has_deadline()); | 1992 EXPECT_TRUE(dependency_tracker().has_deadline()); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1242 for (int i = 0; i < 3; ++i) { | 2029 for (int i = 0; i < 3; ++i) { | 
| 1243 begin_frame_source()->TestOnBeginFrame(args); | 2030 begin_frame_source()->TestOnBeginFrame(args); | 
| 1244 EXPECT_TRUE(dependency_tracker().has_deadline()); | 2031 EXPECT_TRUE(dependency_tracker().has_deadline()); | 
| 1245 } | 2032 } | 
| 1246 begin_frame_source()->TestOnBeginFrame(args); | 2033 begin_frame_source()->TestOnBeginFrame(args); | 
| 1247 EXPECT_FALSE(dependency_tracker().has_deadline()); | 2034 EXPECT_FALSE(dependency_tracker().has_deadline()); | 
| 1248 } | 2035 } | 
| 1249 | 2036 | 
| 1250 // This test verifies that a CompositorFrame will only blocked on embedded | 2037 // This test verifies that a CompositorFrame will only blocked on embedded | 
| 1251 // surfaces but not on other retained surface IDs in the CompositorFrame. | 2038 // surfaces but not on other retained surface IDs in the CompositorFrame. | 
| 1252 TEST_F(CompositorFrameSinkSupportTest, OnlyBlockOnEmbeddedSurfaces) { | 2039 TEST_F(SurfaceReferenceTest, OnlyBlockOnEmbeddedSurfaces) { | 
| 1253 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 2040 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 
| 1254 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 2041 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 
| 1255 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 2042 const SurfaceId parent_id2 = MakeSurfaceId(kParentFrameSink, 2); | 
| 1256 | 2043 | 
| 1257 display_support().SubmitCompositorFrame( | 2044 display_support().SubmitCompositorFrame( | 
| 1258 display_id.local_surface_id(), | 2045 display_id.local_surface_id(), | 
| 1259 MakeCompositorFrame({parent_id1}, {parent_id1, parent_id2})); | 2046 MakeCompositorFrame({parent_id1}, {parent_id1, parent_id2})); | 
| 1260 | 2047 | 
| 1261 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 2048 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 
| 1262 EXPECT_FALSE(display_surface()->HasActiveFrame()); | 2049 EXPECT_FALSE(display_surface()->HasActiveFrame()); | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1280 EXPECT_TRUE(display_surface()->HasActiveFrame()); | 2067 EXPECT_TRUE(display_surface()->HasActiveFrame()); | 
| 1281 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty()); | 2068 EXPECT_THAT(display_surface()->blocking_surfaces(), IsEmpty()); | 
| 1282 | 2069 | 
| 1283 // Only a reference to |parent_id1| is added because |parent_id2| does not | 2070 // Only a reference to |parent_id1| is added because |parent_id2| does not | 
| 1284 // exist. | 2071 // exist. | 
| 1285 EXPECT_THAT(GetChildReferences(display_id), UnorderedElementsAre(parent_id1)); | 2072 EXPECT_THAT(GetChildReferences(display_id), UnorderedElementsAre(parent_id1)); | 
| 1286 } | 2073 } | 
| 1287 | 2074 | 
| 1288 // This test verifies that a late arriving CompositorFrame activates immediately | 2075 // This test verifies that a late arriving CompositorFrame activates immediately | 
| 1289 // and does not trigger a new deadline. | 2076 // and does not trigger a new deadline. | 
| 1290 TEST_F(CompositorFrameSinkSupportTest, LateArrivingDependency) { | 2077 TEST_F(SurfaceReferenceTest, LateArrivingDependency) { | 
| 1291 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 2078 const SurfaceId display_id = MakeSurfaceId(kDisplayFrameSink, 1); | 
| 1292 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 2079 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); | 
| 1293 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 2080 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); | 
| 1294 | 2081 | 
| 1295 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 2082 display_support().SubmitCompositorFrame(display_id.local_surface_id(), | 
| 1296 MakeCompositorFrame({parent_id1})); | 2083 MakeCompositorFrame({parent_id1})); | 
| 1297 | 2084 | 
| 1298 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 2085 EXPECT_TRUE(display_surface()->HasPendingFrame()); | 
| 1299 EXPECT_FALSE(display_surface()->HasActiveFrame()); | 2086 EXPECT_FALSE(display_surface()->HasActiveFrame()); | 
| 1300 EXPECT_TRUE(dependency_tracker().has_deadline()); | 2087 EXPECT_TRUE(dependency_tracker().has_deadline()); | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 1316 // scheduling a deadline and without waiting for dependencies to resolve. | 2103 // scheduling a deadline and without waiting for dependencies to resolve. | 
| 1317 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 2104 parent_support().SubmitCompositorFrame(parent_id1.local_surface_id(), | 
| 1318 MakeCompositorFrame({child_id1})); | 2105 MakeCompositorFrame({child_id1})); | 
| 1319 EXPECT_FALSE(dependency_tracker().has_deadline()); | 2106 EXPECT_FALSE(dependency_tracker().has_deadline()); | 
| 1320 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 2107 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 
| 1321 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 2108 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 
| 1322 } | 2109 } | 
| 1323 | 2110 | 
| 1324 } // namespace test | 2111 } // namespace test | 
| 1325 } // namespace cc | 2112 } // namespace cc | 
| OLD | NEW |