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 dependency_tracker_ = base::MakeUnique<SurfaceDependencyTracker>( | 110 surface_manager_.SetDependencyTracker( |
111 &surface_manager_, begin_frame_source_.get()); | 111 base::MakeUnique<SurfaceDependencyTracker>(&surface_manager_, |
112 surface_manager_.SetDependencyTracker(dependency_tracker_.get()); | 112 begin_frame_source_.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 | |
142 // SurfaceDependencyTracker depends on this BeginFrameSource and so it must | 140 // SurfaceDependencyTracker depends on this BeginFrameSource and so it must |
143 // be destroyed AFTER the dependency tracker is destroyed. | 141 // be destroyed AFTER the dependency tracker is destroyed. |
144 begin_frame_source_.reset(); | 142 begin_frame_source_.reset(); |
145 | 143 |
146 supports_.clear(); | 144 supports_.clear(); |
147 | 145 |
148 damaged_surfaces_.clear(); | 146 damaged_surfaces_.clear(); |
149 } | 147 } |
150 | 148 |
151 bool IsSurfaceDamaged(const SurfaceId& surface_id) const { | 149 bool IsSurfaceDamaged(const SurfaceId& surface_id) const { |
152 return damaged_surfaces_.count(surface_id) > 0; | 150 return damaged_surfaces_.count(surface_id) > 0; |
153 } | 151 } |
154 | 152 |
155 // SurfaceObserver implementation: | 153 // SurfaceObserver implementation: |
156 void OnSurfaceCreated(const SurfaceInfo& surface_info) override {} | 154 void OnSurfaceCreated(const SurfaceInfo& surface_info) override {} |
157 void OnSurfaceDamaged(const SurfaceId& surface_id, bool* changed) override { | 155 void OnSurfaceDamaged(const SurfaceId& surface_id, bool* changed) override { |
158 damaged_surfaces_.insert(surface_id); | 156 damaged_surfaces_.insert(surface_id); |
159 } | 157 } |
160 | 158 |
161 protected: | 159 protected: |
162 testing::NiceMock<MockCompositorFrameSinkSupportClient> support_client_; | 160 testing::NiceMock<MockCompositorFrameSinkSupportClient> support_client_; |
163 | 161 |
164 private: | 162 private: |
165 base::flat_set<SurfaceId> damaged_surfaces_; | 163 base::flat_set<SurfaceId> damaged_surfaces_; |
166 SurfaceManager surface_manager_; | 164 SurfaceManager surface_manager_; |
167 std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; | 165 std::unique_ptr<FakeExternalBeginFrameSource> begin_frame_source_; |
168 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; | |
169 std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; | 166 std::vector<std::unique_ptr<CompositorFrameSinkSupport>> supports_; |
170 | 167 |
171 DISALLOW_COPY_AND_ASSIGN(SurfaceSynchronizationTest); | 168 DISALLOW_COPY_AND_ASSIGN(SurfaceSynchronizationTest); |
172 }; | 169 }; |
173 | 170 |
174 // The display root surface should have a surface reference from the top-level | 171 // The display root surface should have a surface reference from the top-level |
175 // root added/removed when a CompositorFrame is submitted with a new SurfaceId. | 172 // root added/removed when a CompositorFrame is submitted with a new SurfaceId. |
176 TEST_F(SurfaceSynchronizationTest, RootSurfaceReceivesReferences) { | 173 TEST_F(SurfaceSynchronizationTest, RootSurfaceReceivesReferences) { |
177 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); | 174 const SurfaceId display_id_first = MakeSurfaceId(kDisplayFrameSink, 1); |
178 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); | 175 const SurfaceId display_id_second = MakeSurfaceId(kDisplayFrameSink, 2); |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 DidReceiveCompositorFrameAck(Eq(returned_resources2))); | 1381 DidReceiveCompositorFrameAck(Eq(returned_resources2))); |
1385 child_support1().SubmitCompositorFrame( | 1382 child_support1().SubmitCompositorFrame( |
1386 child_id1.local_surface_id(), | 1383 child_id1.local_surface_id(), |
1387 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), | 1384 MakeCompositorFrame(empty_surface_ids(), empty_surface_ids(), |
1388 {resource2})); | 1385 {resource2})); |
1389 testing::Mock::VerifyAndClearExpectations(&support_client_); | 1386 testing::Mock::VerifyAndClearExpectations(&support_client_); |
1390 } | 1387 } |
1391 | 1388 |
1392 } // namespace test | 1389 } // namespace test |
1393 } // namespace cc | 1390 } // namespace cc |
OLD | NEW |