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

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

Issue 2715973003: Refactor how temporary references are stored. (Closed)
Patch Set: Rebase. Created 3 years, 9 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
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 104 }
105 105
106 SurfaceManager& surface_manager() { return surface_manager_; } 106 SurfaceManager& surface_manager() { return surface_manager_; }
107 107
108 // Returns all the references where |surface_id| is the parent. 108 // Returns all the references where |surface_id| is the parent.
109 const SurfaceManager::SurfaceIdSet& GetChildReferences( 109 const SurfaceManager::SurfaceIdSet& GetChildReferences(
110 const SurfaceId& surface_id) { 110 const SurfaceId& surface_id) {
111 return surface_manager().parent_to_child_refs_[surface_id]; 111 return surface_manager().parent_to_child_refs_[surface_id];
112 } 112 }
113 113
114 // Returns all the temporary references for the given frame sink id. 114 // Returns true if there is a temporary reference for |surface_id|.
115 std::vector<LocalSurfaceId> GetTempReferences( 115 bool HasTemporaryReference(const SurfaceId& surface_id) {
116 const FrameSinkId& frame_sink_id) { 116 return surface_manager().HasTemporaryReference(surface_id);
117 return surface_manager().temp_references_[frame_sink_id];
118 } 117 }
119 118
120 SurfaceDependencyTracker& dependency_tracker() { 119 SurfaceDependencyTracker& dependency_tracker() {
121 return *surface_manager_.dependency_tracker(); 120 return *surface_manager_.dependency_tracker();
122 } 121 }
123 122
124 FakeExternalBeginFrameSource* begin_frame_source() { 123 FakeExternalBeginFrameSource* begin_frame_source() {
125 return begin_frame_source_.get(); 124 return begin_frame_source_.get();
126 } 125 }
127 126
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); 189 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1);
191 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); 190 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2);
192 191
193 // Submit a CompositorFrame for the first display root surface. 192 // Submit a CompositorFrame for the first display root surface.
194 display_support().SubmitCompositorFrame( 193 display_support().SubmitCompositorFrame(
195 display_id_first.local_surface_id(), 194 display_id_first.local_surface_id(),
196 MakeCompositorFrame({MakeSurfaceId(kParentFrameSink, 1)})); 195 MakeCompositorFrame({MakeSurfaceId(kParentFrameSink, 1)}));
197 196
198 // A surface reference from the top-level root is added and there shouldn't be 197 // A surface reference from the top-level root is added and there shouldn't be
199 // a temporary reference. 198 // a temporary reference.
200 EXPECT_THAT(GetTempReferences(kDisplayFrameSink), IsEmpty()); 199 EXPECT_FALSE(HasTemporaryReference(display_id_first));
201 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), 200 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()),
202 UnorderedElementsAre(display_id_first)); 201 UnorderedElementsAre(display_id_first));
203 202
204 // Submit a CompositorFrame for the second display root surface. 203 // Submit a CompositorFrame for the second display root surface.
205 display_support().SubmitCompositorFrame( 204 display_support().SubmitCompositorFrame(
206 display_id_second.local_surface_id(), 205 display_id_second.local_surface_id(),
207 MakeCompositorFrame({MakeSurfaceId(kParentFrameSink, 2)})); 206 MakeCompositorFrame({MakeSurfaceId(kParentFrameSink, 2)}));
208 207
209 // A surface reference from the top-level root to |display_id_second| should 208 // A surface reference from the top-level root to |display_id_second| should
210 // be added and the reference to |display_root_first| removed. 209 // be added and the reference to |display_root_first| removed.
211 EXPECT_THAT(GetTempReferences(kDisplayFrameSink), IsEmpty()); 210 EXPECT_FALSE(HasTemporaryReference(display_id_second));
212 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()), 211 EXPECT_THAT(GetChildReferences(surface_manager().GetRootSurfaceId()),
213 UnorderedElementsAre(display_id_second)); 212 UnorderedElementsAre(display_id_second));
214 213
215 // Surface |display_id_first| is unreachable and should get deleted. 214 // Surface |display_id_first| is unreachable and should get deleted.
216 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(display_id_first)); 215 EXPECT_EQ(nullptr, surface_manager().GetSurfaceForId(display_id_first));
217 } 216 }
218 217
219 // The parent Surface is blocked on |child_id1| and |child_id2|. 218 // The parent Surface is blocked on |child_id1| and |child_id2|.
220 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedOnTwo) { 219 TEST_F(CompositorFrameSinkSupportTest, DisplayCompositorLockingBlockedOnTwo) {
221 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1); 220 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 child_support1().SubmitCompositorFrame( 604 child_support1().SubmitCompositorFrame(
606 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 605 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids()));
607 606
608 // Verify that the child CompositorFrame activates immediately. 607 // Verify that the child CompositorFrame activates immediately.
609 EXPECT_TRUE(child_surface1()->HasActiveFrame()); 608 EXPECT_TRUE(child_surface1()->HasActiveFrame());
610 EXPECT_FALSE(child_surface1()->HasPendingFrame()); 609 EXPECT_FALSE(child_surface1()->HasPendingFrame());
611 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty()); 610 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty());
612 611
613 // Verify that there is no temporary reference for the child and that 612 // Verify that there is no temporary reference for the child and that
614 // the reference from the parent to the child still exists. 613 // the reference from the parent to the child still exists.
615 EXPECT_THAT(GetTempReferences(child_id.frame_sink_id()), IsEmpty()); 614 EXPECT_FALSE(HasTemporaryReference(child_id));
616 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id)); 615 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id));
617 } 616 }
618 617
619 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|. 618 // The parent Surface is blocked on |child_id2| which is blocked on |child_id3|.
620 // child_support1 evicts its blocked Surface. The parent surface should 619 // child_support1 evicts its blocked Surface. The parent surface should
621 // activate. 620 // activate.
622 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) { 621 TEST_F(CompositorFrameSinkSupportTest, EvictSurfaceWithPendingFrame) {
623 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1); 622 const SurfaceId parent_id1 = MakeSurfaceId(kParentFrameSink, 1);
624 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1); 623 const SurfaceId child_id1 = MakeSurfaceId(kChildFrameSink1, 1);
625 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1); 624 const SurfaceId child_id2 = MakeSurfaceId(kChildFrameSink2, 1);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 EXPECT_FALSE(child_surface1()->HasPendingFrame()); 687 EXPECT_FALSE(child_surface1()->HasPendingFrame());
689 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty()); 688 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty());
690 689
691 // Verify that the parent Surface has activated. 690 // Verify that the parent Surface has activated.
692 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 691 EXPECT_TRUE(parent_surface()->HasActiveFrame());
693 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 692 EXPECT_FALSE(parent_surface()->HasPendingFrame());
694 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty()); 693 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty());
695 694
696 // Verify that there is no temporary reference for the child and that 695 // Verify that there is no temporary reference for the child and that
697 // the reference from the parent to the child still exists. 696 // the reference from the parent to the child still exists.
698 EXPECT_THAT(GetTempReferences(child_id1.frame_sink_id()), IsEmpty()); 697 EXPECT_FALSE(HasTemporaryReference(child_id1));
699 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1)); 698 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id1));
700 699
701 // The parent submits another CompositorFrame that depends on |child_id2|. 700 // The parent submits another CompositorFrame that depends on |child_id2|.
702 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(), 701 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
703 MakeCompositorFrame({child_id2})); 702 MakeCompositorFrame({child_id2}));
704 703
705 // The parent surface should now have both a pending and activate 704 // The parent surface should now have both a pending and activate
706 // CompositorFrame. Verify that the set of child references from 705 // CompositorFrame. Verify that the set of child references from
707 // |parent_id| include both the pending and active CompositorFrames. 706 // |parent_id| include both the pending and active CompositorFrames.
708 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 707 EXPECT_TRUE(parent_surface()->HasActiveFrame());
(...skipping 10 matching lines...) Expand all
719 // CompositorFrame. Also verify that |child_id1| is no longer a child 718 // CompositorFrame. Also verify that |child_id1| is no longer a child
720 // reference of |parent_id|. 719 // reference of |parent_id|.
721 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 720 EXPECT_TRUE(parent_surface()->HasActiveFrame());
722 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 721 EXPECT_FALSE(parent_surface()->HasPendingFrame());
723 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty()); 722 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty());
724 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2)); 723 EXPECT_THAT(GetChildReferences(parent_id), UnorderedElementsAre(child_id2));
725 } 724 }
726 725
727 } // namespace test 726 } // namespace test
728 } // namespace cc 727 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/surfaces/surface_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698