| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" | 9 #include "cc/surfaces/compositor_frame_sink_support_client.h" |
| 10 #include "cc/surfaces/frame_sink_id.h" | 10 #include "cc/surfaces/frame_sink_id.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return child_support2().current_surface_for_testing(); | 95 return child_support2().current_surface_for_testing(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 CompositorFrameSinkSupport& support(int index) { return *supports_[index]; } | 98 CompositorFrameSinkSupport& support(int index) { return *supports_[index]; } |
| 99 Surface* surface(int index) { | 99 Surface* surface(int index) { |
| 100 return support(index).current_surface_for_testing(); | 100 return support(index).current_surface_for_testing(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 SurfaceManager& surface_manager() { return surface_manager_; } | 103 SurfaceManager& surface_manager() { return surface_manager_; } |
| 104 | 104 |
| 105 // Returns all the references where |surface_id| is the parent. |
| 106 const SurfaceManager::SurfaceIdSet& GetChildReferences( |
| 107 const SurfaceId& surface_id) { |
| 108 return surface_manager().parent_to_child_refs_[surface_id]; |
| 109 } |
| 110 |
| 111 // Returns all the temporary references for the given frame sink id. |
| 112 std::vector<LocalSurfaceId> GetTempReferences( |
| 113 const FrameSinkId& frame_sink_id) { |
| 114 return surface_manager().temp_references_[frame_sink_id]; |
| 115 } |
| 116 |
| 105 SurfaceDependencyTracker& dependency_tracker() { | 117 SurfaceDependencyTracker& dependency_tracker() { |
| 106 return *surface_manager_.dependency_tracker(); | 118 return *surface_manager_.dependency_tracker(); |
| 107 } | 119 } |
| 108 | 120 |
| 109 FakeExternalBeginFrameSource* begin_frame_source() { | 121 FakeExternalBeginFrameSource* begin_frame_source() { |
| 110 return begin_frame_source_.get(); | 122 return begin_frame_source_.get(); |
| 111 } | 123 } |
| 112 | 124 |
| 113 ReturnedResourceArray& last_returned_resources() { | 125 ReturnedResourceArray& last_returned_resources() { |
| 114 return last_returned_resources_; | 126 return last_returned_resources_; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 parent_support().SubmitCompositorFrame( | 529 parent_support().SubmitCompositorFrame( |
| 518 parent_id.local_surface_id(), MakeCompositorFrame({empty_surface_ids()})); | 530 parent_id.local_surface_id(), MakeCompositorFrame({empty_surface_ids()})); |
| 519 EXPECT_TRUE(parent_surface()->HasActiveFrame()); | 531 EXPECT_TRUE(parent_surface()->HasActiveFrame()); |
| 520 EXPECT_FALSE(parent_surface()->HasPendingFrame()); | 532 EXPECT_FALSE(parent_surface()->HasPendingFrame()); |
| 521 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty()); | 533 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty()); |
| 522 ReturnedResource returned_resource = resource.ToReturnedResource(); | 534 ReturnedResource returned_resource = resource.ToReturnedResource(); |
| 523 EXPECT_THAT(last_returned_resources(), | 535 EXPECT_THAT(last_returned_resources(), |
| 524 UnorderedElementsAre(returned_resource)); | 536 UnorderedElementsAre(returned_resource)); |
| 525 } | 537 } |
| 526 | 538 |
| 539 // This test verifies that a SurfaceReference from parent to child can be added |
| 540 // prior to the child submitting a CompositorFrame. This test also verifies that |
| 541 // when the child later submits a CompositorFrame, |
| 542 TEST_F(CompositorFrameSinkSupportTest, |
| 543 DisplayCompositorLockingReferenceAddedBeforeChildExists) { |
| 544 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); |
| 545 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1); |
| 546 |
| 547 // The parent submits a CompositorFrame that depends on |child_id| before the |
| 548 // child submits a CompositorFrame. |
| 549 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), |
| 550 MakeCompositorFrame({child_id})); |
| 551 |
| 552 // Verify that the CompositorFrame is blocked on |child_id|. |
| 553 EXPECT_FALSE(parent_surface()->HasActiveFrame()); |
| 554 EXPECT_TRUE(parent_surface()->HasPendingFrame()); |
| 555 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), |
| 556 UnorderedElementsAre(child_id)); |
| 557 |
| 558 // Verify that a SurfaceReference(parent_id, child_id) exists in the |
| 559 // SurfaceManager. |
| 560 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id)); |
| 561 |
| 562 child_support1().SubmitCompositorFrame( |
| 563 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); |
| 564 |
| 565 // Verify that the child CompositorFrame activates immediately. |
| 566 EXPECT_TRUE(child_surface1()->HasActiveFrame()); |
| 567 EXPECT_FALSE(child_surface1()->HasPendingFrame()); |
| 568 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty()); |
| 569 |
| 570 // Verify that there is no temporary reference for the child and that |
| 571 // the reference from the parent to the child still exists. |
| 572 EXPECT_THAT(GetTempReferences(child_id.frame_sink_id()), IsEmpty()); |
| 573 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id)); |
| 574 } |
| 575 |
| 527 } // namespace test | 576 } // namespace test |
| 528 } // namespace cc | 577 } // namespace cc |
| OLD | NEW |