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