| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // We are going to set up the SurfaceLayers and LayerTreeHosts. Each layer | 101 // We are going to set up the SurfaceLayers and LayerTreeHosts. Each layer |
| 102 // will require a sequence and no sequence should be satisfied for now. | 102 // will require a sequence and no sequence should be satisfied for now. |
| 103 EXPECT_CALL(*ref_factory, RequireSequence(Eq(expected_id), Eq(expected_seq1))) | 103 EXPECT_CALL(*ref_factory, RequireSequence(Eq(expected_id), Eq(expected_seq1))) |
| 104 .Times(1); | 104 .Times(1); |
| 105 EXPECT_CALL(*ref_factory, RequireSequence(Eq(expected_id), Eq(expected_seq2))) | 105 EXPECT_CALL(*ref_factory, RequireSequence(Eq(expected_id), Eq(expected_seq2))) |
| 106 .Times(1); | 106 .Times(1); |
| 107 EXPECT_CALL(*ref_factory, SatisfySequence(_)).Times(0); | 107 EXPECT_CALL(*ref_factory, SatisfySequence(_)).Times(0); |
| 108 | 108 |
| 109 auto layer = SurfaceLayer::Create(ref_factory); | 109 auto layer = SurfaceLayer::Create(ref_factory); |
| 110 layer->SetPrimarySurfaceInfo(info); | 110 layer->SetPrimarySurfaceInfo(info); |
| 111 layer->SetFallbackSurfaceInfo(info); |
| 111 layer_tree_host_->GetSurfaceSequenceGenerator()->set_frame_sink_id( | 112 layer_tree_host_->GetSurfaceSequenceGenerator()->set_frame_sink_id( |
| 112 FrameSinkId(1, 1)); | 113 FrameSinkId(1, 1)); |
| 113 layer_tree_host_->SetRootLayer(layer); | 114 layer_tree_host_->SetRootLayer(layer); |
| 114 | 115 |
| 115 auto animation_host2 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); | 116 auto animation_host2 = AnimationHost::CreateForTesting(ThreadInstance::MAIN); |
| 116 std::unique_ptr<FakeLayerTreeHost> layer_tree_host2 = | 117 std::unique_ptr<FakeLayerTreeHost> layer_tree_host2 = |
| 117 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_, | 118 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_, |
| 118 animation_host2.get()); | 119 animation_host2.get()); |
| 119 auto layer2 = SurfaceLayer::Create(ref_factory); | 120 auto layer2 = SurfaceLayer::Create(ref_factory); |
| 120 layer2->SetPrimarySurfaceInfo(info); | 121 layer2->SetPrimarySurfaceInfo(info); |
| 122 layer2->SetFallbackSurfaceInfo(info); |
| 121 layer_tree_host2->GetSurfaceSequenceGenerator()->set_frame_sink_id( | 123 layer_tree_host2->GetSurfaceSequenceGenerator()->set_frame_sink_id( |
| 122 FrameSinkId(2, 2)); | 124 FrameSinkId(2, 2)); |
| 123 layer_tree_host2->SetRootLayer(layer2); | 125 layer_tree_host2->SetRootLayer(layer2); |
| 124 | 126 |
| 125 testing::Mock::VerifyAndClearExpectations(ref_factory.get()); | 127 testing::Mock::VerifyAndClearExpectations(ref_factory.get()); |
| 126 | 128 |
| 127 // Destroy the second LayerTreeHost. The sequence generated by its | 129 // Destroy the second LayerTreeHost. The sequence generated by its |
| 128 // SurfaceLayer must be satisfied and no new sequences must be required. | 130 // SurfaceLayer must be satisfied and no new sequences must be required. |
| 129 EXPECT_CALL(*ref_factory, SatisfySequence(Eq(expected_seq2))).Times(1); | 131 EXPECT_CALL(*ref_factory, SatisfySequence(Eq(expected_seq2))).Times(1); |
| 130 layer_tree_host2->SetRootLayer(nullptr); | 132 layer_tree_host2->SetRootLayer(nullptr); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 151 scoped_refptr<SurfaceReferenceFactory> ref_factory = | 153 scoped_refptr<SurfaceReferenceFactory> ref_factory = |
| 152 new testing::NiceMock<MockSurfaceReferenceFactory>(); | 154 new testing::NiceMock<MockSurfaceReferenceFactory>(); |
| 153 | 155 |
| 154 scoped_refptr<SurfaceLayer> layer = SurfaceLayer::Create(ref_factory); | 156 scoped_refptr<SurfaceLayer> layer = SurfaceLayer::Create(ref_factory); |
| 155 layer_tree_host_->SetRootLayer(layer); | 157 layer_tree_host_->SetRootLayer(layer); |
| 156 SurfaceInfo primary_info( | 158 SurfaceInfo primary_info( |
| 157 SurfaceId(kArbitraryFrameSinkId, | 159 SurfaceId(kArbitraryFrameSinkId, |
| 158 LocalSurfaceId(1, base::UnguessableToken::Create())), | 160 LocalSurfaceId(1, base::UnguessableToken::Create())), |
| 159 1.f, gfx::Size(1, 1)); | 161 1.f, gfx::Size(1, 1)); |
| 160 layer->SetPrimarySurfaceInfo(primary_info); | 162 layer->SetPrimarySurfaceInfo(primary_info); |
| 163 layer->SetFallbackSurfaceInfo(primary_info); |
| 161 | 164 |
| 162 // As surface synchronization is not enabled, the primary surface id should | |
| 163 // be recorded on the layer tree host. | |
| 164 EXPECT_FALSE(layer_tree_host_->GetSettings().enable_surface_synchronization); | |
| 165 EXPECT_TRUE(layer_tree_host_->needs_surface_ids_sync()); | 165 EXPECT_TRUE(layer_tree_host_->needs_surface_ids_sync()); |
| 166 EXPECT_EQ(layer_tree_host_->SurfaceLayerIds().size(), 1u); | 166 EXPECT_EQ(layer_tree_host_->SurfaceLayerIds().size(), 1u); |
| 167 | 167 |
| 168 // Verify that pending tree has no surface ids already. | 168 // Verify that pending tree has no surface ids already. |
| 169 EXPECT_FALSE(host_impl_.pending_tree()->needs_surface_ids_sync()); | 169 EXPECT_FALSE(host_impl_.pending_tree()->needs_surface_ids_sync()); |
| 170 EXPECT_EQ(host_impl_.pending_tree()->SurfaceLayerIds().size(), 0u); | 170 EXPECT_EQ(host_impl_.pending_tree()->SurfaceLayerIds().size(), 0u); |
| 171 | 171 |
| 172 std::unique_ptr<SurfaceLayerImpl> layer_impl = | 172 std::unique_ptr<SurfaceLayerImpl> layer_impl = |
| 173 SurfaceLayerImpl::Create(host_impl_.pending_tree(), layer->id()); | 173 SurfaceLayerImpl::Create(host_impl_.pending_tree(), layer->id()); |
| 174 TreeSynchronizer::PushLayerProperties(layer_tree_host_.get(), | 174 TreeSynchronizer::PushLayerProperties(layer_tree_host_.get(), |
| 175 host_impl_.pending_tree()); | 175 host_impl_.pending_tree()); |
| 176 layer_tree_host_->PushSurfaceIdsTo(host_impl_.pending_tree()); | 176 layer_tree_host_->PushSurfaceIdsTo(host_impl_.pending_tree()); |
| 177 | 177 |
| 178 // Verify that pending tree received the surface id and also has | 178 // Verify that pending tree received the surface id and also has |
| 179 // needs_surface_ids_sync set to true as it needs to sync with active tree. | 179 // needs_surface_ids_sync set to true as it needs to sync with active tree. |
| 180 EXPECT_TRUE(host_impl_.pending_tree()->needs_surface_ids_sync()); | 180 EXPECT_TRUE(host_impl_.pending_tree()->needs_surface_ids_sync()); |
| 181 EXPECT_EQ(host_impl_.pending_tree()->SurfaceLayerIds().size(), 1u); | 181 EXPECT_EQ(host_impl_.pending_tree()->SurfaceLayerIds().size(), 1u); |
| 182 | 182 |
| 183 // Verify we have reset the state on layer tree host. | 183 // Verify we have reset the state on layer tree host. |
| 184 EXPECT_FALSE(layer_tree_host_->needs_surface_ids_sync()); | 184 EXPECT_FALSE(layer_tree_host_->needs_surface_ids_sync()); |
| 185 | 185 |
| 186 // Verify that the primary SurfaceInfo is pushed through and that there is | 186 // Verify that the primary and fallback SurfaceInfos are pushed through. |
| 187 // no valid fallback SurfaceInfo. | |
| 188 EXPECT_EQ(primary_info, layer_impl->primary_surface_info()); | 187 EXPECT_EQ(primary_info, layer_impl->primary_surface_info()); |
| 189 EXPECT_EQ(SurfaceInfo(), layer_impl->fallback_surface_info()); | 188 EXPECT_EQ(primary_info, layer_impl->fallback_surface_info()); |
| 190 | 189 |
| 191 SurfaceInfo fallback_info( | 190 SurfaceInfo fallback_info( |
| 192 SurfaceId(kArbitraryFrameSinkId, | 191 SurfaceId(kArbitraryFrameSinkId, |
| 193 LocalSurfaceId(2, base::UnguessableToken::Create())), | 192 LocalSurfaceId(2, base::UnguessableToken::Create())), |
| 194 2.f, gfx::Size(10, 10)); | 193 2.f, gfx::Size(10, 10)); |
| 195 layer->SetFallbackSurfaceInfo(fallback_info); | 194 layer->SetFallbackSurfaceInfo(fallback_info); |
| 196 | 195 |
| 197 // Verify that fallback surface id is not recorded on the layer tree host as | 196 // Verify that fallback surface id is not recorded on the layer tree host as |
| 198 // surface synchronization is not enabled. | 197 // surface synchronization is not enabled. |
| 199 EXPECT_FALSE(layer_tree_host_->needs_surface_ids_sync()); | 198 EXPECT_TRUE(layer_tree_host_->needs_surface_ids_sync()); |
| 200 EXPECT_EQ(layer_tree_host_->SurfaceLayerIds().size(), 1u); | 199 EXPECT_EQ(layer_tree_host_->SurfaceLayerIds().size(), 1u); |
| 201 | 200 |
| 202 TreeSynchronizer::PushLayerProperties(layer_tree_host_.get(), | 201 TreeSynchronizer::PushLayerProperties(layer_tree_host_.get(), |
| 203 host_impl_.pending_tree()); | 202 host_impl_.pending_tree()); |
| 204 layer_tree_host_->PushSurfaceIdsTo(host_impl_.pending_tree()); | 203 layer_tree_host_->PushSurfaceIdsTo(host_impl_.pending_tree()); |
| 205 | 204 |
| 206 EXPECT_EQ(host_impl_.pending_tree()->SurfaceLayerIds().size(), 1u); | 205 EXPECT_EQ(host_impl_.pending_tree()->SurfaceLayerIds().size(), 1u); |
| 207 | 206 |
| 208 // Verify that the primary SurfaceInfo stays the same and the new fallback | 207 // Verify that the primary SurfaceInfo stays the same and the new fallback |
| 209 // SurfaceInfo is pushed through. | 208 // SurfaceInfo is pushed through. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 224 | 223 |
| 225 // Create a SurfaceLayer but don't add it to the tree yet. No sequence | 224 // Create a SurfaceLayer but don't add it to the tree yet. No sequence |
| 226 // should be required / satisfied. | 225 // should be required / satisfied. |
| 227 EXPECT_CALL(*ref_factory_, SatisfySequence(_)).Times(0); | 226 EXPECT_CALL(*ref_factory_, SatisfySequence(_)).Times(0); |
| 228 EXPECT_CALL(*ref_factory_, RequireSequence(_, _)).Times(0); | 227 EXPECT_CALL(*ref_factory_, RequireSequence(_, _)).Times(0); |
| 229 layer_ = SurfaceLayer::Create(ref_factory_); | 228 layer_ = SurfaceLayer::Create(ref_factory_); |
| 230 SurfaceInfo info( | 229 SurfaceInfo info( |
| 231 SurfaceId(kArbitraryFrameSinkId, LocalSurfaceId(1, kArbitraryToken)), | 230 SurfaceId(kArbitraryFrameSinkId, LocalSurfaceId(1, kArbitraryToken)), |
| 232 1.f, gfx::Size(1, 1)); | 231 1.f, gfx::Size(1, 1)); |
| 233 layer_->SetPrimarySurfaceInfo(info); | 232 layer_->SetPrimarySurfaceInfo(info); |
| 233 layer_->SetFallbackSurfaceInfo(info); |
| 234 testing::Mock::VerifyAndClearExpectations(ref_factory_.get()); | 234 testing::Mock::VerifyAndClearExpectations(ref_factory_.get()); |
| 235 | 235 |
| 236 // Add the layer to the tree. A sequence must be required. | 236 // Add the layer to the tree. A sequence must be required. |
| 237 SurfaceSequence expected_seq(kArbitraryFrameSinkId, 1u); | 237 SurfaceSequence expected_seq(kArbitraryFrameSinkId, 1u); |
| 238 SurfaceId expected_id(kArbitraryFrameSinkId, | 238 SurfaceId expected_id(kArbitraryFrameSinkId, |
| 239 LocalSurfaceId(1, kArbitraryToken)); | 239 LocalSurfaceId(1, kArbitraryToken)); |
| 240 EXPECT_CALL(*ref_factory_, SatisfySequence(_)).Times(0); | 240 EXPECT_CALL(*ref_factory_, SatisfySequence(_)).Times(0); |
| 241 EXPECT_CALL(*ref_factory_, | 241 EXPECT_CALL(*ref_factory_, |
| 242 RequireSequence(Eq(expected_id), Eq(expected_seq))) | 242 RequireSequence(Eq(expected_id), Eq(expected_seq))) |
| 243 .Times(1); | 243 .Times(1); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 EndTest(); | 328 EndTest(); |
| 329 break; | 329 break; |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 }; | 332 }; |
| 333 | 333 |
| 334 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); | 334 MULTI_THREAD_TEST_F(SurfaceLayerSwapPromiseWithoutDraw); |
| 335 | 335 |
| 336 } // namespace | 336 } // namespace |
| 337 } // namespace cc | 337 } // namespace cc |
| OLD | NEW |