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 "base/containers/flat_set.h" | 5 #include "base/containers/flat_set.h" |
6 #include "cc/surfaces/compositor_frame_sink_support.h" | 6 #include "cc/surfaces/compositor_frame_sink_support.h" |
7 #include "cc/surfaces/surface_id.h" | 7 #include "cc/surfaces/surface_id.h" |
8 #include "cc/surfaces/surface_manager.h" | 8 #include "cc/surfaces/surface_manager.h" |
9 #include "cc/surfaces/surface_observer.h" | 9 #include "cc/surfaces/surface_observer.h" |
10 #include "cc/test/begin_frame_args_test.h" | 10 #include "cc/test/begin_frame_args_test.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 FakeExternalBeginFrameSource* begin_frame_source() { | 100 FakeExternalBeginFrameSource* begin_frame_source() { |
101 return begin_frame_source_.get(); | 101 return begin_frame_source_.get(); |
102 } | 102 } |
103 | 103 |
104 // testing::Test: | 104 // testing::Test: |
105 void SetUp() override { | 105 void SetUp() override { |
106 testing::Test::SetUp(); | 106 testing::Test::SetUp(); |
107 | 107 |
108 begin_frame_source_ = | 108 begin_frame_source_ = |
109 base::MakeUnique<FakeExternalBeginFrameSource>(0.f, false); | 109 base::MakeUnique<FakeExternalBeginFrameSource>(0.f, false); |
110 surface_manager_.SetDependencyTracker( | 110 dependency_tracker_ = base::MakeUnique<SurfaceDependencyTracker>( |
111 base::MakeUnique<SurfaceDependencyTracker>(&surface_manager_, | 111 &surface_manager_, begin_frame_source_.get()); |
112 begin_frame_source_.get())); | 112 surface_manager_.SetDependencyTracker(dependency_tracker_.get()); |
113 surface_manager_.AddObserver(this); | 113 surface_manager_.AddObserver(this); |
114 supports_.push_back(CompositorFrameSinkSupport::Create( | 114 supports_.push_back(CompositorFrameSinkSupport::Create( |
115 &support_client_, &surface_manager_, kDisplayFrameSink, kIsRoot, | 115 &support_client_, &surface_manager_, kDisplayFrameSink, kIsRoot, |
116 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); | 116 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
117 supports_.push_back(CompositorFrameSinkSupport::Create( | 117 supports_.push_back(CompositorFrameSinkSupport::Create( |
118 &support_client_, &surface_manager_, kParentFrameSink, kIsChildRoot, | 118 &support_client_, &surface_manager_, kParentFrameSink, kIsChildRoot, |
119 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); | 119 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
120 supports_.push_back(CompositorFrameSinkSupport::Create( | 120 supports_.push_back(CompositorFrameSinkSupport::Create( |
121 &support_client_, &surface_manager_, kChildFrameSink1, kIsChildRoot, | 121 &support_client_, &surface_manager_, kChildFrameSink1, kIsChildRoot, |
122 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); | 122 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
123 supports_.push_back(CompositorFrameSinkSupport::Create( | 123 supports_.push_back(CompositorFrameSinkSupport::Create( |
124 &support_client_, &surface_manager_, kChildFrameSink2, kIsChildRoot, | 124 &support_client_, &surface_manager_, kChildFrameSink2, kIsChildRoot, |
125 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); | 125 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints)); |
126 | 126 |
127 // Normally, the BeginFrameSource would be registered by the Display. We | 127 // Normally, the BeginFrameSource would be registered by the Display. We |
128 // register it here so that BeginFrames are received by the display support, | 128 // register it here so that BeginFrames are received by the display support, |
129 // for use in the PassesOnBeginFrameAcks test. Other supports do not receive | 129 // for use in the PassesOnBeginFrameAcks test. Other supports do not receive |
130 // BeginFrames, since the frame sink hierarchy is not set up in this test. | 130 // BeginFrames, since the frame sink hierarchy is not set up in this test. |
131 surface_manager_.RegisterBeginFrameSource(begin_frame_source_.get(), | 131 surface_manager_.RegisterBeginFrameSource(begin_frame_source_.get(), |
132 kDisplayFrameSink); | 132 kDisplayFrameSink); |
133 } | 133 } |
134 | 134 |
135 void TearDown() override { | 135 void TearDown() override { |
136 surface_manager_.RemoveObserver(this); | 136 surface_manager_.RemoveObserver(this); |
137 surface_manager_.SetDependencyTracker(nullptr); | 137 surface_manager_.SetDependencyTracker(nullptr); |
138 surface_manager_.UnregisterBeginFrameSource(begin_frame_source_.get()); | 138 surface_manager_.UnregisterBeginFrameSource(begin_frame_source_.get()); |
139 | 139 |
| 140 dependency_tracker_.reset(); |
| 141 |
140 // SurfaceDependencyTracker depends on this BeginFrameSource and so it must | 142 // SurfaceDependencyTracker depends on this BeginFrameSource and so it must |
141 // be destroyed AFTER the dependency tracker is destroyed. | 143 // be destroyed AFTER the dependency tracker is destroyed. |
142 begin_frame_source_.reset(); | 144 begin_frame_source_.reset(); |
143 | 145 |
144 supports_.clear(); | 146 supports_.clear(); |
145 | 147 |
146 damaged_surfaces_.clear(); | 148 damaged_surfaces_.clear(); |
147 } | 149 } |
148 | 150 |
149 bool IsSurfaceDamaged(const SurfaceId& surface_id) const { | 151 bool IsSurfaceDamaged(const SurfaceId& surface_id) const { |
150 return damaged_surfaces_.count(surface_id) > 0; | 152 return damaged_surfaces_.count(surface_id) > 0; |
151 } | 153 } |
152 | 154 |
153 // SurfaceObserver implementation: | 155 // SurfaceObserver implementation: |
154 void OnSurfaceCreated(const SurfaceInfo& surface_info) override {} | 156 void OnSurfaceCreated(const SurfaceInfo& surface_info) override {} |
155 void OnSurfaceDamaged(const SurfaceId& surface_id, bool* changed) override { | 157 void OnSurfaceDamaged(const SurfaceId& surface_id, bool* changed) override { |
156 damaged_surfaces_.insert(surface_id); | 158 damaged_surfaces_.insert(surface_id); |
157 } | 159 } |
158 | 160 |
159 protected: | 161 protected: |
160 testing::NiceMock<MockCompositorFrameSinkSupportClient> support_client_; | 162 testing::NiceMock<MockCompositorFrameSinkSupportClient> support_client_; |
161 | 163 |
162 private: | 164 private: |
163 base::flat_set<SurfaceId> damaged_surfaces_; | 165 base::flat_set<SurfaceId> damaged_surfaces_; |
164 SurfaceManager surface_manager_; | 166 SurfaceManager surface_manager_; |
165 std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; | 167 std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; |
| 168 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; |
166 std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; | 169 std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; |
167 | 170 |
168 DISALLOW_COPY_AND_ASSIGN(SurfaceSynchronizationTest); | 171 DISALLOW_COPY_AND_ASSIGN(SurfaceSynchronizationTest); |
169 }; | 172 }; |
170 | 173 |
171 // The display root surface should have a surface reference from the top-level | 174 // The display root surface should have a surface reference from the top-level |
172 // root added/removed when a CompositorFrame is submitted with a new SurfaceId. | 175 // root added/removed when a CompositorFrame is submitted with a new SurfaceId. |
173 TEST_F(SurfaceSynchronizationTest, RootSurfaceReceivesReferences) { | 176 TEST_F(SurfaceSynchronizationTest, RootSurfaceReceivesReferences) { |
174 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); | 177 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); |
175 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); | 178 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 DidReceiveCompositorFrameAck(Eq(returned_resources2))); | 1384 DidReceiveCompositorFrameAck(Eq(returned_resources2))); |
1382 child_support1().SubmitCompositorFrame( | 1385 child_support1().SubmitCompositorFrame( |
1383 child_id1.local_surface_id(), | 1386 child_id1.local_surface_id(), |
1384 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), | 1387 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
1385 {resource2})); | 1388 {resource2})); |
1386 testing::Mock::VerifyAndClearExpectations(&support_client_); | 1389 testing::Mock::VerifyAndClearExpectations(&support_client_); |
1387 } | 1390 } |
1388 | 1391 |
1389 } // namespace test | 1392 } // namespace test |
1390 } // namespace cc | 1393 } // namespace cc |
OLD | NEW |