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