| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/gpu/gpu_channel_manager.h" | 5 #include "content/common/gpu/gpu_channel_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "content/common/child_thread.h" | 8 #include "content/common/child_thread.h" |
| 9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
| 10 #include "content/common/gpu/gpu_memory_manager.h" | 10 #include "content/common/gpu/gpu_memory_manager.h" |
| 11 #include "content/common/gpu/gpu_messages.h" | 11 #include "content/common/gpu/gpu_messages.h" |
| 12 #include "content/common/gpu/sync_point_manager.h" | 12 #include "content/common/gpu/sync_point_manager.h" |
| 13 #include "gpu/command_buffer/service/mailbox_manager.h" | 13 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 14 #include "gpu/command_buffer/service/memory_shader_cache.h" |
| 14 #include "ui/gl/gl_share_group.h" | 15 #include "ui/gl/gl_share_group.h" |
| 15 | 16 |
| 17 using base::WeakPtr; |
| 18 |
| 16 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, | 19 GpuChannelManager::GpuChannelManager(ChildThread* gpu_child_thread, |
| 17 GpuWatchdog* watchdog, | 20 GpuWatchdog* watchdog, |
| 18 base::MessageLoopProxy* io_message_loop, | 21 base::MessageLoopProxy* io_message_loop, |
| 19 base::WaitableEvent* shutdown_event) | 22 base::WaitableEvent* shutdown_event) |
| 20 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 23 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| 21 io_message_loop_(io_message_loop), | 24 io_message_loop_(io_message_loop), |
| 22 shutdown_event_(shutdown_event), | 25 shutdown_event_(shutdown_event), |
| 23 gpu_child_thread_(gpu_child_thread), | 26 gpu_child_thread_(gpu_child_thread), |
| 24 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, | 27 ALLOW_THIS_IN_INITIALIZER_LIST(gpu_memory_manager_(this, |
| 25 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)), | 28 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit)), |
| 26 watchdog_(watchdog), | 29 watchdog_(watchdog), |
| 27 sync_point_manager_(new SyncPointManager) { | 30 sync_point_manager_(new SyncPointManager), |
| 31 shader_cache_(new gpu::MemoryShaderCache()){ |
| 28 DCHECK(gpu_child_thread); | 32 DCHECK(gpu_child_thread); |
| 29 DCHECK(io_message_loop); | 33 DCHECK(io_message_loop); |
| 30 DCHECK(shutdown_event); | 34 DCHECK(shutdown_event); |
| 31 } | 35 } |
| 32 | 36 |
| 33 GpuChannelManager::~GpuChannelManager() { | 37 GpuChannelManager::~GpuChannelManager() { |
| 34 gpu_channels_.clear(); | 38 gpu_channels_.clear(); |
| 35 } | 39 } |
| 36 | 40 |
| 37 void GpuChannelManager::RemoveChannel(int client_id) { | 41 void GpuChannelManager::RemoveChannel(int client_id) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 if (share_context) { | 98 if (share_context) { |
| 95 if (!share_group_) { | 99 if (!share_group_) { |
| 96 share_group_ = new gfx::GLShareGroup; | 100 share_group_ = new gfx::GLShareGroup; |
| 97 DCHECK(!mailbox_manager_); | 101 DCHECK(!mailbox_manager_); |
| 98 mailbox_manager_ = new gpu::gles2::MailboxManager; | 102 mailbox_manager_ = new gpu::gles2::MailboxManager; |
| 99 } | 103 } |
| 100 share_group = share_group_; | 104 share_group = share_group_; |
| 101 mailbox_manager = mailbox_manager_; | 105 mailbox_manager = mailbox_manager_; |
| 102 } | 106 } |
| 103 | 107 |
| 108 WeakPtr<gpu::ShaderCache> shader_cache_ptr = |
| 109 shader_cache_.get() == NULL ? |
| 110 shader_cache_ptr = WeakPtr<gpu::ShaderCache>() : |
| 111 shader_cache_ptr = shader_cache_->AsWeakPtr(); |
| 104 scoped_refptr<GpuChannel> channel = new GpuChannel(this, | 112 scoped_refptr<GpuChannel> channel = new GpuChannel(this, |
| 105 watchdog_, | 113 watchdog_, |
| 106 share_group, | 114 share_group, |
| 107 mailbox_manager, | 115 mailbox_manager, |
| 108 client_id, | 116 client_id, |
| 109 false); | 117 false, |
| 118 shader_cache_ptr); |
| 110 if (channel->Init(io_message_loop_, shutdown_event_)) { | 119 if (channel->Init(io_message_loop_, shutdown_event_)) { |
| 111 gpu_channels_[client_id] = channel; | 120 gpu_channels_[client_id] = channel; |
| 112 channel_handle.name = channel->GetChannelName(); | 121 channel_handle.name = channel->GetChannelName(); |
| 113 | 122 |
| 114 #if defined(OS_POSIX) | 123 #if defined(OS_POSIX) |
| 115 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so | 124 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so |
| 116 // that it gets closed after it has been sent. | 125 // that it gets closed after it has been sent. |
| 117 int renderer_fd = channel->TakeRendererFileDescriptor(); | 126 int renderer_fd = channel->TakeRendererFileDescriptor(); |
| 118 DCHECK_NE(-1, renderer_fd); | 127 DCHECK_NE(-1, renderer_fd); |
| 119 channel_handle.socket = base::FileDescriptor(renderer_fd, true); | 128 channel_handle.socket = base::FileDescriptor(renderer_fd, true); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 void GpuChannelManager::LoseAllContexts() { | 163 void GpuChannelManager::LoseAllContexts() { |
| 155 MessageLoop::current()->PostTask( | 164 MessageLoop::current()->PostTask( |
| 156 FROM_HERE, | 165 FROM_HERE, |
| 157 base::Bind(&GpuChannelManager::OnLoseAllContexts, | 166 base::Bind(&GpuChannelManager::OnLoseAllContexts, |
| 158 weak_factory_.GetWeakPtr())); | 167 weak_factory_.GetWeakPtr())); |
| 159 } | 168 } |
| 160 | 169 |
| 161 void GpuChannelManager::OnLoseAllContexts() { | 170 void GpuChannelManager::OnLoseAllContexts() { |
| 162 gpu_channels_.clear(); | 171 gpu_channels_.clear(); |
| 163 } | 172 } |
| OLD | NEW |