OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 8209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8220 UIResourceId ui_resource_id = 1; | 8220 UIResourceId ui_resource_id = 1; |
8221 host_impl_->CreateUIResource(ui_resource_id, bitmap); | 8221 host_impl_->CreateUIResource(ui_resource_id, bitmap); |
8222 EXPECT_EQ(1u, context3d->NumTextures()); | 8222 EXPECT_EQ(1u, context3d->NumTextures()); |
8223 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); | 8223 ResourceId id1 = host_impl_->ResourceIdForUIResource(ui_resource_id); |
8224 EXPECT_NE(0u, id1); | 8224 EXPECT_NE(0u, id1); |
8225 } | 8225 } |
8226 | 8226 |
8227 void ShutdownReleasesContext_Callback( | 8227 void ShutdownReleasesContext_Callback( |
8228 std::unique_ptr<CopyOutputResult> result) {} | 8228 std::unique_ptr<CopyOutputResult> result) {} |
8229 | 8229 |
| 8230 class FrameSinkClient : public TestCompositorFrameSinkClient { |
| 8231 public: |
| 8232 explicit FrameSinkClient( |
| 8233 scoped_refptr<ContextProvider> display_context_provider) |
| 8234 : display_context_provider_(std::move(display_context_provider)) {} |
| 8235 |
| 8236 std::unique_ptr<OutputSurface> CreateDisplayOutputSurface( |
| 8237 scoped_refptr<ContextProvider> compositor_context_provider) override { |
| 8238 return FakeOutputSurface::Create3d(std::move(display_context_provider_)); |
| 8239 } |
| 8240 |
| 8241 void DisplayReceivedCompositorFrame(const CompositorFrame& frame) override {} |
| 8242 void DisplayWillDrawAndSwap(bool will_draw_and_swap, |
| 8243 const RenderPassList& render_passes) override {} |
| 8244 void DisplayDidDrawAndSwap() override {} |
| 8245 |
| 8246 private: |
| 8247 scoped_refptr<ContextProvider> display_context_provider_; |
| 8248 }; |
| 8249 |
8230 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { | 8250 TEST_F(LayerTreeHostImplTest, ShutdownReleasesContext) { |
8231 scoped_refptr<TestContextProvider> context_provider = | 8251 scoped_refptr<TestContextProvider> context_provider = |
8232 TestContextProvider::Create(); | 8252 TestContextProvider::Create(); |
| 8253 FrameSinkClient test_client_(context_provider); |
8233 | 8254 |
8234 CreateHostImpl( | 8255 auto compositor_frame_sink = base::MakeUnique<TestCompositorFrameSink>( |
8235 DefaultSettings(), | 8256 context_provider, TestContextProvider::CreateWorker(), nullptr, nullptr, |
8236 base::MakeUnique<TestCompositorFrameSink>( | 8257 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), |
8237 context_provider, TestContextProvider::CreateWorker(), | 8258 true /* synchronous_composite */, |
8238 FakeOutputSurface::Create3d(context_provider), nullptr, nullptr, | 8259 false /* force_disable_reclaim_resources */); |
8239 RendererSettings(), base::ThreadTaskRunnerHandle::Get().get(), | 8260 compositor_frame_sink->SetClient(&test_client_); |
8240 true /* synchronous_composite */, | 8261 |
8241 false /* force_disable_reclaim_resources */)); | 8262 CreateHostImpl(DefaultSettings(), std::move(compositor_frame_sink)); |
8242 | 8263 |
8243 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); | 8264 SetupRootLayerImpl(LayerImpl::Create(host_impl_->active_tree(), 1)); |
8244 | 8265 |
8245 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); | 8266 LayerImpl* root = host_impl_->active_tree()->root_layer_for_testing(); |
8246 root->test_properties()->copy_requests.push_back( | 8267 root->test_properties()->copy_requests.push_back( |
8247 CopyOutputRequest::CreateRequest( | 8268 CopyOutputRequest::CreateRequest( |
8248 base::Bind(&ShutdownReleasesContext_Callback))); | 8269 base::Bind(&ShutdownReleasesContext_Callback))); |
8249 host_impl_->active_tree()->BuildPropertyTreesForTesting(); | 8270 host_impl_->active_tree()->BuildPropertyTreesForTesting(); |
8250 | 8271 |
8251 LayerTreeHostImpl::FrameData frame; | 8272 LayerTreeHostImpl::FrameData frame; |
(...skipping 3221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11473 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 11494 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
11474 | 11495 |
11475 // Re-initialize with a software output surface. | 11496 // Re-initialize with a software output surface. |
11476 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); | 11497 compositor_frame_sink_ = FakeCompositorFrameSink::CreateSoftware(); |
11477 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); | 11498 host_impl_->InitializeRenderer(compositor_frame_sink_.get()); |
11478 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); | 11499 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); |
11479 } | 11500 } |
11480 | 11501 |
11481 } // namespace | 11502 } // namespace |
11482 } // namespace cc | 11503 } // namespace cc |
OLD | NEW |