| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/support/compositor/blimp_embedder_compositor.h" | 5 #include "blimp/client/support/compositor/blimp_embedder_compositor.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "blimp/client/public/compositor/compositor_dependencies.h" | 10 #include "blimp/client/public/compositor/compositor_dependencies.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 base::LazyInstance<SimpleTaskGraphRunner> g_task_graph_runner = | 80 base::LazyInstance<SimpleTaskGraphRunner> g_task_graph_runner = |
| 81 LAZY_INSTANCE_INITIALIZER; | 81 LAZY_INSTANCE_INITIALIZER; |
| 82 | 82 |
| 83 } // namespace | 83 } // namespace |
| 84 | 84 |
| 85 BlimpEmbedderCompositor::BlimpEmbedderCompositor( | 85 BlimpEmbedderCompositor::BlimpEmbedderCompositor( |
| 86 CompositorDependencies* compositor_dependencies) | 86 CompositorDependencies* compositor_dependencies) |
| 87 : compositor_dependencies_(compositor_dependencies), | 87 : compositor_dependencies_(compositor_dependencies), |
| 88 surface_id_allocator_(base::MakeUnique<cc::SurfaceIdAllocator>( | 88 surface_id_allocator_(base::MakeUnique<cc::SurfaceIdAllocator>( |
| 89 compositor_dependencies->AllocateSurfaceClientId())), | 89 compositor_dependencies->AllocateFrameSinkId())), |
| 90 compositor_frame_sink_request_pending_(false), | 90 compositor_frame_sink_request_pending_(false), |
| 91 root_layer_(cc::Layer::Create()) { | 91 root_layer_(cc::Layer::Create()) { |
| 92 compositor_dependencies_->GetSurfaceManager()->RegisterSurfaceClientId( | 92 compositor_dependencies_->GetSurfaceManager()->RegisterFrameSinkId( |
| 93 surface_id_allocator_->client_id()); | 93 surface_id_allocator_->frame_sink_id()); |
| 94 | 94 |
| 95 cc::LayerTreeHostInProcess::InitParams params; | 95 cc::LayerTreeHostInProcess::InitParams params; |
| 96 params.client = this; | 96 params.client = this; |
| 97 params.gpu_memory_buffer_manager = | 97 params.gpu_memory_buffer_manager = |
| 98 compositor_dependencies_->GetGpuMemoryBufferManager(); | 98 compositor_dependencies_->GetGpuMemoryBufferManager(); |
| 99 params.task_graph_runner = g_task_graph_runner.Pointer(); | 99 params.task_graph_runner = g_task_graph_runner.Pointer(); |
| 100 cc::LayerTreeSettings settings; | 100 cc::LayerTreeSettings settings; |
| 101 params.settings = &settings; | 101 params.settings = &settings; |
| 102 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); | 102 params.main_task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 103 params.animation_host = cc::AnimationHost::CreateMainInstance(); | 103 params.animation_host = cc::AnimationHost::CreateMainInstance(); |
| 104 host_ = cc::LayerTreeHostInProcess::CreateSingleThreaded(this, ¶ms); | 104 host_ = cc::LayerTreeHostInProcess::CreateSingleThreaded(this, ¶ms); |
| 105 | 105 |
| 106 root_layer_->SetBackgroundColor(SK_ColorWHITE); | 106 root_layer_->SetBackgroundColor(SK_ColorWHITE); |
| 107 host_->GetLayerTree()->SetRootLayer(root_layer_); | 107 host_->GetLayerTree()->SetRootLayer(root_layer_); |
| 108 host_->SetSurfaceClientId(surface_id_allocator_->client_id()); | 108 host_->SetFrameSinkId(surface_id_allocator_->frame_sink_id()); |
| 109 host_->SetVisible(true); | 109 host_->SetVisible(true); |
| 110 } | 110 } |
| 111 | 111 |
| 112 BlimpEmbedderCompositor::~BlimpEmbedderCompositor() { | 112 BlimpEmbedderCompositor::~BlimpEmbedderCompositor() { |
| 113 SetContextProvider(nullptr); | 113 SetContextProvider(nullptr); |
| 114 compositor_dependencies_->GetSurfaceManager()->InvalidateSurfaceClientId( | 114 compositor_dependencies_->GetSurfaceManager()->InvalidateFrameSinkId( |
| 115 surface_id_allocator_->client_id()); | 115 surface_id_allocator_->frame_sink_id()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void BlimpEmbedderCompositor::SetContentLayer( | 118 void BlimpEmbedderCompositor::SetContentLayer( |
| 119 scoped_refptr<cc::Layer> content_layer) { | 119 scoped_refptr<cc::Layer> content_layer) { |
| 120 root_layer_->RemoveAllChildren(); | 120 root_layer_->RemoveAllChildren(); |
| 121 root_layer_->AddChild(content_layer); | 121 root_layer_->AddChild(content_layer); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void BlimpEmbedderCompositor::SetSize(const gfx::Size& size_in_px) { | 124 void BlimpEmbedderCompositor::SetSize(const gfx::Size& size_in_px) { |
| 125 viewport_size_in_px_ = size_in_px; | 125 viewport_size_in_px_ = size_in_px; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 // The Browser compositor and display share the same context provider. | 202 // The Browser compositor and display share the same context provider. |
| 203 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( | 203 auto compositor_frame_sink = base::MakeUnique<cc::DirectCompositorFrameSink>( |
| 204 compositor_dependencies_->GetSurfaceManager(), | 204 compositor_dependencies_->GetSurfaceManager(), |
| 205 surface_id_allocator_.get(), display_.get(), context_provider_, nullptr); | 205 surface_id_allocator_.get(), display_.get(), context_provider_, nullptr); |
| 206 | 206 |
| 207 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); | 207 host_->SetCompositorFrameSink(std::move(compositor_frame_sink)); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace client | 210 } // namespace client |
| 211 } // namespace blimp | 211 } // namespace blimp |
| OLD | NEW |