Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: cc/surfaces/compositor_frame_sink_support_unittest.cc

Issue 2716553004: Add temporary reference ownership to SurfaceManager. (Closed)
Patch Set: Cleanup. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. 105 // Returns all the references where |surface_id| is the parent.
106 const SurfaceManager::SurfaceIdSet& GetChildReferences( 106 const SurfaceManager::SurfaceIdSet& GetChildReferences(
107 const SurfaceId& surface_id) { 107 const SurfaceId& surface_id) {
108 return surface_manager().parent_to_child_refs_[surface_id]; 108 return surface_manager().parent_to_child_refs_[surface_id];
109 } 109 }
110 110
111 // Returns all the temporary references for the given frame sink id. 111 // Returns true if there is a temporary reference for |surface_id|.
112 std::vector<LocalSurfaceId> GetTempReferences( 112 bool HasTemporaryReference(const SurfaceId& surface_id) {
113 const FrameSinkId& frame_sink_id) { 113 return surface_manager().HasTemporaryReference(surface_id);
114 return surface_manager().temp_references_[frame_sink_id];
115 } 114 }
116 115
117 SurfaceDependencyTracker& dependency_tracker() { 116 SurfaceDependencyTracker& dependency_tracker() {
118 return *surface_manager_.dependency_tracker(); 117 return *surface_manager_.dependency_tracker();
119 } 118 }
120 119
121 FakeExternalBeginFrameSource* begin_frame_source() { 120 FakeExternalBeginFrameSource* begin_frame_source() {
122 return begin_frame_source_.get(); 121 return begin_frame_source_.get();
123 } 122 }
124 123
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 child_support1().SubmitCompositorFrame( 565 child_support1().SubmitCompositorFrame(
567 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 566 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids()));
568 567
569 // Verify that the child CompositorFrame activates immediately. 568 // Verify that the child CompositorFrame activates immediately.
570 EXPECT_TRUE(child_surface1()->HasActiveFrame()); 569 EXPECT_TRUE(child_surface1()->HasActiveFrame());
571 EXPECT_FALSE(child_surface1()->HasPendingFrame()); 570 EXPECT_FALSE(child_surface1()->HasPendingFrame());
572 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty()); 571 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty());
573 572
574 // Verify that there is no temporary reference for the child and that 573 // Verify that there is no temporary reference for the child and that
575 // the reference from the parent to the child still exists. 574 // the reference from the parent to the child still exists.
576 EXPECT_THAT(GetTempReferences(child_id.frame_sink_id()), IsEmpty()); 575 EXPECT_FALSE(HasTemporaryReference(child_id));
577 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id)); 576 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id));
578 } 577 }
579 578
580 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. 579 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|.
581 // child_support1 evicts its blocked Surface. The parent surface should 580 // child_support1 evicts its blocked Surface. The parent surface should
582 // activate. 581 // activate.
583 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { 582 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) {
584 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 583 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
585 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 584 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
586 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); 585 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 EXPECT_FALSE(child_surface1()->HasPendingFrame()); 648 EXPECT_FALSE(child_surface1()->HasPendingFrame());
650 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty()); 649 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty());
651 650
652 // Verify that the parent Surface has activated. 651 // Verify that the parent Surface has activated.
653 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 652 EXPECT_TRUE(parent_surface()->HasActiveFrame());
654 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 653 EXPECT_FALSE(parent_surface()->HasPendingFrame());
655 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty()); 654 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty());
656 655
657 // Verify that there is no temporary reference for the child and that 656 // Verify that there is no temporary reference for the child and that
658 // the reference from the parent to the child still exists. 657 // the reference from the parent to the child still exists.
659 EXPECT_THAT(GetTempReferences(child_id1.frame_sink_id()), IsEmpty()); 658 EXPECT_FALSE(HasTemporaryReference(child_id1));
660 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1)); 659 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1));
661 660
662 // The parent submits another CompositorFrame that depends on |child_id2|. 661 // The parent submits another CompositorFrame that depends on |child_id2|.
663 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 662 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
664 MakeCompositorFrame({child_id2})); 663 MakeCompositorFrame({child_id2}));
665 664
666 // The parent surface should now have both a pending and activate 665 // The parent surface should now have both a pending and activate
667 // CompositorFrame. Verify that the set of child references from 666 // CompositorFrame. Verify that the set of child references from
668 // |parent_id| include both the pending and active CompositorFrames. 667 // |parent_id| include both the pending and active CompositorFrames.
669 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 668 EXPECT_TRUE(parent_surface()->HasActiveFrame());
(...skipping 10 matching lines...) Expand all
680 // CompositorFrame. Also verify that |child_id1| is no longer a child 679 // CompositorFrame. Also verify that |child_id1| is no longer a child
681 // reference of |parent_id|. 680 // reference of |parent_id|.
682 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 681 EXPECT_TRUE(parent_surface()->HasActiveFrame());
683 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 682 EXPECT_FALSE(parent_surface()->HasPendingFrame());
684 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty()); 683 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty());
685 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2)); 684 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2));
686 } 685 }
687 686
688 } // namespace test 687 } // namespace test
689 } // namespace cc 688 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698