| 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/feature/compositor/blimp_compositor_manager.h" | 5 #include "blimp/client/feature/compositor/blimp_compositor_manager.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "blimp/client/feature/compositor/blimp_layer_tree_settings.h" | 9 #include "blimp/client/feature/compositor/blimp_layer_tree_settings.h" |
| 10 #include "blimp/common/compositor/blimp_image_serialization_processor.h" | 10 #include "blimp/common/compositor/blimp_image_serialization_processor.h" |
| 11 #include "blimp/common/compositor/blimp_task_graph_runner.h" | 11 #include "blimp/common/compositor/blimp_task_graph_runner.h" |
| 12 #include "cc/proto/compositor_message.pb.h" | 12 #include "cc/proto/compositor_message.pb.h" |
| 13 | 13 |
| 14 namespace blimp { | 14 namespace blimp { |
| 15 namespace client { | 15 namespace client { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 base::LazyInstance<blimp::BlimpTaskGraphRunner> g_task_graph_runner = | 18 base::LazyInstance<blimp::BlimpTaskGraphRunner> g_task_graph_runner = |
| 19 LAZY_INSTANCE_INITIALIZER; | 19 LAZY_INSTANCE_INITIALIZER; |
| 20 | 20 |
| 21 const int kDummyTabId = 0; | 21 const int kDummyTabId = 0; |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 BlimpCompositorManager::BlimpCompositorManager( | 24 BlimpCompositorManager::BlimpCompositorManager( |
| 25 RenderWidgetFeature* render_widget_feature, | 25 RenderWidgetFeature* render_widget_feature) |
| 26 BlimpCompositorManagerClient* client) | |
| 27 : visible_(false), | 26 : visible_(false), |
| 28 window_(gfx::kNullAcceleratedWidget), | 27 window_(gfx::kNullAcceleratedWidget), |
| 29 gpu_memory_buffer_manager_(new BlimpGpuMemoryBufferManager), | 28 gpu_memory_buffer_manager_(new BlimpGpuMemoryBufferManager), |
| 30 image_serialization_processor_(new BlimpImageSerializationProcessor( | 29 image_serialization_processor_( |
| 31 BlimpImageSerializationProcessor::Mode::DESERIALIZATION)), | 30 new BlimpImageSerializationProcessor( |
| 31 BlimpImageSerializationProcessor::Mode::DESERIALIZATION)), |
| 32 active_compositor_(nullptr), | 32 active_compositor_(nullptr), |
| 33 render_widget_feature_(render_widget_feature), | 33 render_widget_feature_(render_widget_feature) { |
| 34 client_(client) { | |
| 35 DCHECK(render_widget_feature_); | 34 DCHECK(render_widget_feature_); |
| 36 render_widget_feature_->SetDelegate(kDummyTabId, this); | 35 render_widget_feature_->SetDelegate(kDummyTabId, this); |
| 37 } | 36 } |
| 38 | 37 |
| 39 BlimpCompositorManager::~BlimpCompositorManager() { | 38 BlimpCompositorManager::~BlimpCompositorManager() { |
| 40 render_widget_feature_->RemoveDelegate(kDummyTabId); | 39 render_widget_feature_->RemoveDelegate(kDummyTabId); |
| 41 if (compositor_thread_) | 40 if (compositor_thread_) |
| 42 compositor_thread_->Stop(); | 41 compositor_thread_->Stop(); |
| 43 } | 42 } |
| 44 | 43 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // client. Since it currently overrides all settings, ignore them. | 132 // client. Since it currently overrides all settings, ignore them. |
| 134 // See crbug/577985. | 133 // See crbug/577985. |
| 135 GenerateLayerTreeSettings(settings_.get()); | 134 GenerateLayerTreeSettings(settings_.get()); |
| 136 settings_ | 135 settings_ |
| 137 ->abort_commit_before_output_surface_creation = false; | 136 ->abort_commit_before_output_surface_creation = false; |
| 138 } | 137 } |
| 139 | 138 |
| 140 return settings_.get(); | 139 return settings_.get(); |
| 141 } | 140 } |
| 142 | 141 |
| 143 void BlimpCompositorManager::DidCompleteSwapBuffers() { | |
| 144 DCHECK(client_); | |
| 145 client_->OnSwapBuffersCompleted(); | |
| 146 } | |
| 147 | |
| 148 scoped_refptr<base::SingleThreadTaskRunner> | 142 scoped_refptr<base::SingleThreadTaskRunner> |
| 149 BlimpCompositorManager::GetCompositorTaskRunner() { | 143 BlimpCompositorManager::GetCompositorTaskRunner() { |
| 150 if (compositor_thread_) | 144 if (compositor_thread_) |
| 151 return compositor_thread_->task_runner(); | 145 return compositor_thread_->task_runner(); |
| 152 | 146 |
| 153 base::Thread::Options thread_options; | 147 base::Thread::Options thread_options; |
| 154 #if defined(OS_ANDROID) | 148 #if defined(OS_ANDROID) |
| 155 thread_options.priority = base::ThreadPriority::DISPLAY; | 149 thread_options.priority = base::ThreadPriority::DISPLAY; |
| 156 #endif | 150 #endif |
| 157 compositor_thread_.reset(new base::Thread("Compositor")); | 151 compositor_thread_.reset(new base::Thread("Compositor")); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 194 |
| 201 BlimpCompositor* BlimpCompositorManager::GetCompositor(int render_widget_id) { | 195 BlimpCompositor* BlimpCompositorManager::GetCompositor(int render_widget_id) { |
| 202 CompositorMap::const_iterator it = compositors_.find(render_widget_id); | 196 CompositorMap::const_iterator it = compositors_.find(render_widget_id); |
| 203 if (it == compositors_.end()) | 197 if (it == compositors_.end()) |
| 204 return nullptr; | 198 return nullptr; |
| 205 return it->second.get(); | 199 return it->second.get(); |
| 206 } | 200 } |
| 207 | 201 |
| 208 } // namespace client | 202 } // namespace client |
| 209 } // namespace blimp | 203 } // namespace blimp |
| OLD | NEW |