Chromium Code Reviews| 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 "components/mus/gpu/gpu_service_mus.h" | 5 #include "components/mus/gpu/gpu_service_mus.h" |
| 6 | 6 |
| 7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "components/mus/common/mojo_gpu_memory_buffer_manager.h" | 11 #include "build/build_config.h" |
| 12 #include "components/mus/gpu/mus_gpu_memory_buffer_manager.h" | |
| 12 #include "gpu/command_buffer/service/gpu_switches.h" | 13 #include "gpu/command_buffer/service/gpu_switches.h" |
| 13 #include "gpu/command_buffer/service/sync_point_manager.h" | 14 #include "gpu/command_buffer/service/sync_point_manager.h" |
| 14 #include "gpu/config/gpu_info_collector.h" | 15 #include "gpu/config/gpu_info_collector.h" |
| 15 #include "gpu/config/gpu_switches.h" | 16 #include "gpu/config/gpu_switches.h" |
| 16 #include "gpu/config/gpu_util.h" | 17 #include "gpu/config/gpu_util.h" |
| 17 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 18 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
| 18 #include "gpu/ipc/common/memory_stats.h" | 19 #include "gpu/ipc/common/memory_stats.h" |
| 19 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 20 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
| 20 #include "ipc/ipc_channel_handle.h" | 21 #include "ipc/ipc_channel_handle.h" |
| 21 #include "ipc/ipc_sync_message_filter.h" | 22 #include "ipc/ipc_sync_message_filter.h" |
| 22 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" | 23 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" |
| 23 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" | 24 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" |
| 24 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" | 25 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" |
| 25 #include "media/gpu/ipc/service/media_service.h" | 26 #include "media/gpu/ipc/service/media_service.h" |
| 26 #include "ui/gl/gl_implementation.h" | 27 #include "ui/gl/gl_implementation.h" |
| 27 #include "ui/gl/gl_switches.h" | 28 #include "ui/gl/gl_switches.h" |
| 28 #include "ui/gl/gpu_switching_manager.h" | 29 #include "ui/gl/gpu_switching_manager.h" |
| 29 #include "ui/gl/init/gl_factory.h" | 30 #include "ui/gl/init/gl_factory.h" |
| 30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 31 | 32 |
| 33 #if defined(USE_OZONE) | |
| 34 #include "ui/ozone/public/ozone_platform.h" | |
| 35 #endif | |
| 36 | |
| 32 namespace mus { | 37 namespace mus { |
| 33 namespace { | 38 namespace { |
| 34 | 39 |
| 35 const int kLocalGpuChannelClientId = 1; | 40 const int kLocalGpuChannelClientId = 1; |
| 36 const uint64_t kLocalGpuChannelClientTracingId = 1; | 41 const uint64_t kLocalGpuChannelClientTracingId = 1; |
| 37 | 42 |
| 38 void EstablishGpuChannelDone( | 43 void EstablishGpuChannelDone( |
| 39 int client_id, | 44 int client_id, |
| 40 const IPC::ChannelHandle* channel_handle, | 45 const IPC::ChannelHandle* channel_handle, |
| 41 const GpuServiceMus::EstablishGpuChannelCallback& callback) { | 46 const GpuServiceMus::EstablishGpuChannelCallback& callback) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 | 183 |
| 179 IPC::ChannelHandle channel_handle; | 184 IPC::ChannelHandle channel_handle; |
| 180 bool manual_reset = true; | 185 bool manual_reset = true; |
| 181 bool initially_signaled = false; | 186 bool initially_signaled = false; |
| 182 base::WaitableEvent event(manual_reset, initially_signaled); | 187 base::WaitableEvent event(manual_reset, initially_signaled); |
| 183 gpu_thread_.task_runner()->PostTask( | 188 gpu_thread_.task_runner()->PostTask( |
| 184 FROM_HERE, base::Bind(&GpuServiceMus::InitializeOnGpuThread, | 189 FROM_HERE, base::Bind(&GpuServiceMus::InitializeOnGpuThread, |
| 185 base::Unretained(this), &channel_handle, &event)); | 190 base::Unretained(this), &channel_handle, &event)); |
| 186 event.Wait(); | 191 event.Wait(); |
| 187 | 192 |
| 188 gpu_memory_buffer_manager_local_.reset(new MojoGpuMemoryBufferManager); | 193 gpu_memory_buffer_manager_local_.reset( |
| 194 new MusGpuMemoryBufferManager(kLocalGpuChannelClientId)); | |
| 189 gpu_channel_local_ = gpu::GpuChannelHost::Create( | 195 gpu_channel_local_ = gpu::GpuChannelHost::Create( |
| 190 this, kLocalGpuChannelClientId, gpu_info_, channel_handle, | 196 this, kLocalGpuChannelClientId, gpu_info_, channel_handle, |
| 191 &shutdown_event_, gpu_memory_buffer_manager_local_.get()); | 197 &shutdown_event_, gpu_memory_buffer_manager_local_.get()); |
| 192 } | 198 } |
| 193 | 199 |
| 194 void GpuServiceMus::InitializeOnGpuThread(IPC::ChannelHandle* channel_handle, | 200 void GpuServiceMus::InitializeOnGpuThread(IPC::ChannelHandle* channel_handle, |
| 195 base::WaitableEvent* event) { | 201 base::WaitableEvent* event) { |
| 196 gpu_info_.video_decode_accelerator_capabilities = | 202 gpu_info_.video_decode_accelerator_capabilities = |
| 197 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); | 203 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); |
| 198 gpu_info_.video_encode_accelerator_supported_profiles = | 204 gpu_info_.video_encode_accelerator_supported_profiles = |
| 199 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences_); | 205 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences_); |
| 200 gpu_info_.jpeg_decode_accelerator_supported = | 206 gpu_info_.jpeg_decode_accelerator_supported = |
| 201 media::GpuJpegDecodeAccelerator::IsSupported(); | 207 media::GpuJpegDecodeAccelerator::IsSupported(); |
| 202 | 208 |
| 203 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) { | 209 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) { |
| 204 gpu_memory_buffer_factory_ = | 210 gpu_memory_buffer_factory_ = |
| 205 gpu::GpuMemoryBufferFactory::CreateNativeType(); | 211 gpu::GpuMemoryBufferFactory::CreateNativeType(); |
| 206 } | 212 } |
| 207 | 213 |
| 214 #if defined(USE_OZONE) | |
|
rjkroege
2016/06/08 21:16:43
It should probably be at the top. The CreateNative
Peng
2016/06/08 21:40:36
Done.
| |
| 215 ui::OzonePlatform::InitializeForGPU(); | |
| 216 #endif | |
| 217 | |
| 208 if (!gl::init::InitializeGLOneOff()) | 218 if (!gl::init::InitializeGLOneOff()) |
| 209 VLOG(1) << "gl::init::InitializeGLOneOff failed"; | 219 VLOG(1) << "gl::init::InitializeGLOneOff failed"; |
| 210 | 220 |
| 211 DCHECK(!owned_sync_point_manager_); | 221 DCHECK(!owned_sync_point_manager_); |
| 212 const bool allow_threaded_wait = false; | 222 const bool allow_threaded_wait = false; |
| 213 owned_sync_point_manager_.reset( | 223 owned_sync_point_manager_.reset( |
| 214 new gpu::SyncPointManager(allow_threaded_wait)); | 224 new gpu::SyncPointManager(allow_threaded_wait)); |
| 215 | 225 |
| 216 // Defer creation of the render thread. This is to prevent it from handling | 226 // Defer creation of the render thread. This is to prevent it from handling |
| 217 // IPC messages before the sandbox has been enabled and all other necessary | 227 // IPC messages before the sandbox has been enabled and all other necessary |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 return shm; | 277 return shm; |
| 268 } | 278 } |
| 269 | 279 |
| 270 // static | 280 // static |
| 271 GpuServiceMus* GpuServiceMus::GetInstance() { | 281 GpuServiceMus* GpuServiceMus::GetInstance() { |
| 272 return base::Singleton<GpuServiceMus, | 282 return base::Singleton<GpuServiceMus, |
| 273 base::LeakySingletonTraits<GpuServiceMus>>::get(); | 283 base::LeakySingletonTraits<GpuServiceMus>>::get(); |
| 274 } | 284 } |
| 275 | 285 |
| 276 } // namespace mus | 286 } // namespace mus |
| OLD | NEW |