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

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

Issue 2688043002: Retain references to surfaces from both active AND pending CompositorFrames (Closed)
Patch Set: Added TODOs and addressed comments 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
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.cc ('k') | cc/surfaces/surface.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 compositor_frame.metadata.referenced_surfaces = 43 compositor_frame.metadata.referenced_surfaces =
44 std::move(referenced_surfaces); 44 std::move(referenced_surfaces);
45 return compositor_frame; 45 return compositor_frame;
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 class CompositorFrameSinkSupportTest : public testing::Test, 50 class CompositorFrameSinkSupportTest : public testing::Test,
51 public CompositorFrameSinkSupportClient { 51 public CompositorFrameSinkSupportClient {
52 public: 52 public:
53 CompositorFrameSinkSupportTest() {} 53 CompositorFrameSinkSupportTest()
54 : surface_manager_(SurfaceManager::LifetimeType::REFERENCES) {}
54 ~CompositorFrameSinkSupportTest() override {} 55 ~CompositorFrameSinkSupportTest() override {}
55 56
56 CompositorFrameSinkSupport& parent_support() { return *supports_[0]; } 57 CompositorFrameSinkSupport& parent_support() { return *supports_[0]; }
57 Surface* parent_surface() { 58 Surface* parent_surface() {
58 return parent_support().current_surface_for_testing(); 59 return parent_support().current_surface_for_testing();
59 } 60 }
61 const ReferencedSurfaceTracker& parent_reference_tracker() {
62 return parent_support().ReferenceTrackerForTesting();
63 }
60 64
61 CompositorFrameSinkSupport& child_support1() { return *supports_[1]; } 65 CompositorFrameSinkSupport& child_support1() { return *supports_[1]; }
62 Surface* child_surface1() { 66 Surface* child_surface1() {
63 return child_support1().current_surface_for_testing(); 67 return child_support1().current_surface_for_testing();
64 } 68 }
65 69
66 CompositorFrameSinkSupport& child_support2() { return *supports_[2]; } 70 CompositorFrameSinkSupport& child_support2() { return *supports_[2]; }
67 Surface* child_surface2() { 71 Surface* child_surface2() {
68 return child_support2().current_surface_for_testing(); 72 return child_support2().current_surface_for_testing();
69 } 73 }
(...skipping 28 matching lines...) Expand all
98 supports_.push_back(base::MakeUnique<CompositorFrameSinkSupport>( 102 supports_.push_back(base::MakeUnique<CompositorFrameSinkSupport>(
99 this, &surface_manager_, kChildFrameSink1, nullptr /* display */, 103 this, &surface_manager_, kChildFrameSink1, nullptr /* display */,
100 nullptr /* display_begin_frame_source */)); 104 nullptr /* display_begin_frame_source */));
101 supports_.push_back(base::MakeUnique<CompositorFrameSinkSupport>( 105 supports_.push_back(base::MakeUnique<CompositorFrameSinkSupport>(
102 this, &surface_manager_, kChildFrameSink2, nullptr /* display */, 106 this, &surface_manager_, kChildFrameSink2, nullptr /* display */,
103 nullptr /* display_begin_frame_source */)); 107 nullptr /* display_begin_frame_source */));
104 } 108 }
105 109
106 void TearDown() override { 110 void TearDown() override {
107 surface_manager_.SetDependencyTracker(nullptr); 111 surface_manager_.SetDependencyTracker(nullptr);
112
113 // SurfaceDependencyTracker depends on this BeginFrameSource and so it must
114 // be destroyed AFTER the dependency tracker is destroyed.
108 begin_frame_source_.reset(); 115 begin_frame_source_.reset();
116
109 supports_.clear(); 117 supports_.clear();
110 } 118 }
111 119
112 // CompositorFrameSinkSupportClient implementation. 120 // CompositorFrameSinkSupportClient implementation.
113 void DidReceiveCompositorFrameAck() override {} 121 void DidReceiveCompositorFrameAck() override {}
114 void OnBeginFrame(const BeginFrameArgs& args) override {} 122 void OnBeginFrame(const BeginFrameArgs& args) override {}
115 void ReclaimResources(const ReturnedResourceArray& resources) override {} 123 void ReclaimResources(const ReturnedResourceArray& resources) override {}
116 void WillDrawSurface() override {} 124 void WillDrawSurface() override {}
117 125
118 private: 126 private:
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // Submit a CompositorFrame that has no dependencies. 388 // Submit a CompositorFrame that has no dependencies.
381 parent_support().SubmitCompositorFrame( 389 parent_support().SubmitCompositorFrame(
382 parent_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids())); 390 parent_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids()));
383 391
384 // Verify that the CompositorFrame has been activated. 392 // Verify that the CompositorFrame has been activated.
385 EXPECT_TRUE(parent_surface()->HasActiveFrame()); 393 EXPECT_TRUE(parent_surface()->HasActiveFrame());
386 EXPECT_FALSE(parent_surface()->HasPendingFrame()); 394 EXPECT_FALSE(parent_surface()->HasPendingFrame());
387 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty()); 395 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty());
388 } 396 }
389 397
398 // This test verifies that the set of references from a Surface includes both
399 // the pending and active CompositorFrames.
400 TEST_F(CompositorFrameSinkSupportTest,
401 DisplayCompositorLockingReferencesFromPendingAndActiveFrames) {
402 const SurfaceId parent_id = MakeSurfaceId(kParentFrameSink, 1);
403 const SurfaceId child_id = MakeSurfaceId(kChildFrameSink1, 1);
404 const SurfaceId arbitrary_id = MakeSurfaceId(kArbitraryFrameSink, 1);
405 const SurfaceReference parent_child_reference(parent_id, child_id);
406 const SurfaceReference parent_arbitrary_reference(parent_id, arbitrary_id);
407
408 // child_support1 submits a CompositorFrame without any dependencies.
409 child_support1().SubmitCompositorFrame(
410 child_id.local_surface_id(), MakeCompositorFrame(empty_surface_ids()));
411
412 // Verify that the child surface is not blocked.
413 EXPECT_TRUE(child_surface1()->HasActiveFrame());
414 EXPECT_FALSE(child_surface1()->HasPendingFrame());
415 EXPECT_THAT(child_surface1()->blocking_surfaces_for_testing(), IsEmpty());
416
417 // parent_support submits a CompositorFrame that depends on |child_id1|
418 // which is already active. Thus, this CompositorFrame should activate
419 // immediately.
420 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
421 MakeCompositorFrame({child_id}));
422 EXPECT_TRUE(parent_surface()->HasActiveFrame());
423 EXPECT_FALSE(parent_surface()->HasPendingFrame());
424 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(), IsEmpty());
425 // Verify that the parent will add a reference to the |child_id|.
426 EXPECT_THAT(parent_reference_tracker().references_to_add(),
427 UnorderedElementsAre(parent_child_reference));
428 EXPECT_THAT(parent_reference_tracker().references_to_remove(), IsEmpty());
429
430 // parent_support now submits another CompositorFrame to the same surface
431 // but depends on arbitrary_id. The parent surface should now have both
432 // a pending and active CompositorFrame.
433 parent_support().SubmitCompositorFrame(parent_id.local_surface_id(),
434 MakeCompositorFrame({arbitrary_id}));
435 EXPECT_TRUE(parent_surface()->HasActiveFrame());
436 EXPECT_TRUE(parent_surface()->HasPendingFrame());
437 EXPECT_THAT(parent_surface()->blocking_surfaces_for_testing(),
438 UnorderedElementsAre(arbitrary_id));
439 // Verify that the parent will add a reference to |arbitrary_id| and will not
440 // remove a reference to |child_id|.
441 EXPECT_THAT(parent_reference_tracker().references_to_add(),
442 UnorderedElementsAre(parent_arbitrary_reference));
443 EXPECT_THAT(parent_reference_tracker().references_to_remove(), IsEmpty());
444 }
445
390 } // namespace test 446 } // namespace test
391 } // namespace cc 447 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/compositor_frame_sink_support.cc ('k') | cc/surfaces/surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698