| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/gles2/gpu_state.h" | 5 #include "components/mus/gles2/gpu_state.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 11 #include "gpu/config/gpu_info_collector.h" | 11 #include "gpu/config/gpu_info_collector.h" |
| 12 #include "ui/gl/gl_implementation.h" | 12 #include "ui/gl/gl_implementation.h" |
| 13 #include "ui/gl/gl_surface.h" | 13 #include "ui/gl/gl_surface.h" |
| 14 | 14 |
| 15 #if defined(USE_OZONE) | 15 #if defined(USE_OZONE) |
| 16 #include "ui/ozone/public/ozone_platform.h" | 16 #include "ui/ozone/public/ozone_platform.h" |
| 17 #endif | 17 #endif |
| 18 | 18 |
| 19 namespace mus { | 19 namespace mus { |
| 20 | 20 |
| 21 GpuState::GpuState() | 21 GpuState::GpuState() |
| 22 : gpu_thread_("gpu_thread"), | 22 : gpu_thread_("gpu_thread"), |
| 23 control_thread_("gpu_command_buffer_control"), | 23 control_thread_("gpu_command_buffer_control"), |
| 24 hardware_rendering_available_(false) { | 24 hardware_rendering_available_(false) { |
| 25 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 25 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 26 gpu_thread_.Start(); | 26 gpu_thread_.Start(); |
| 27 control_thread_.Start(); | 27 control_thread_.Start(); |
| 28 control_thread_task_runner_ = control_thread_.task_runner(); |
| 28 base::WaitableEvent event(true, false); | 29 base::WaitableEvent event(true, false); |
| 29 gpu_thread_.task_runner()->PostTask( | 30 gpu_thread_.task_runner()->PostTask( |
| 30 FROM_HERE, base::Bind(&GpuState::InitializeOnGpuThread, | 31 FROM_HERE, base::Bind(&GpuState::InitializeOnGpuThread, |
| 31 base::Unretained(this), &event)); | 32 base::Unretained(this), &event)); |
| 32 event.Wait(); | 33 event.Wait(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 GpuState::~GpuState() {} | 36 GpuState::~GpuState() {} |
| 36 | 37 |
| 37 void GpuState::StopThreads() { | 38 void GpuState::StopThreads() { |
| 38 control_thread_.Stop(); | 39 control_thread_.Stop(); |
| 40 gpu_thread_.task_runner()->PostTask( |
| 41 FROM_HERE, |
| 42 base::Bind(&GpuState::DestroyGpuSpecificStateOnGpuThread, this)); |
| 39 gpu_thread_.Stop(); | 43 gpu_thread_.Stop(); |
| 40 } | 44 } |
| 41 | 45 |
| 42 void GpuState::InitializeOnGpuThread(base::WaitableEvent* event) { | 46 void GpuState::InitializeOnGpuThread(base::WaitableEvent* event) { |
| 43 hardware_rendering_available_ = gfx::GLSurface::InitializeOneOff(); | 47 hardware_rendering_available_ = gfx::GLSurface::InitializeOneOff(); |
| 44 command_buffer_task_runner_ = new CommandBufferTaskRunner; | 48 command_buffer_task_runner_ = new CommandBufferTaskRunner; |
| 45 driver_manager_.reset(new CommandBufferDriverManager); | 49 driver_manager_.reset(new CommandBufferDriverManager); |
| 46 sync_point_manager_.reset(new gpu::SyncPointManager(true)); | 50 sync_point_manager_.reset(new gpu::SyncPointManager(true)); |
| 47 share_group_ = new gfx::GLShareGroup; | 51 share_group_ = new gfx::GLShareGroup; |
| 48 mailbox_manager_ = new gpu::gles2::MailboxManagerImpl; | 52 mailbox_manager_ = new gpu::gles2::MailboxManagerImpl; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 62 LOG_IF(ERROR, result != gpu::kCollectInfoSuccess) | 66 LOG_IF(ERROR, result != gpu::kCollectInfoSuccess) |
| 63 << "Collect context graphics info failed!"; | 67 << "Collect context graphics info failed!"; |
| 64 } | 68 } |
| 65 event->Signal(); | 69 event->Signal(); |
| 66 | 70 |
| 67 #if defined(USE_OZONE) | 71 #if defined(USE_OZONE) |
| 68 ui::OzonePlatform::InitializeForGPU(); | 72 ui::OzonePlatform::InitializeForGPU(); |
| 69 #endif | 73 #endif |
| 70 } | 74 } |
| 71 | 75 |
| 76 void GpuState::DestroyGpuSpecificStateOnGpuThread() { |
| 77 driver_manager_.reset(); |
| 78 } |
| 79 |
| 72 } // namespace mus | 80 } // namespace mus |
| OLD | NEW |