| 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/client/gpu_channel_host.h" | 5 #include "content/common/gpu/client/gpu_channel_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" |
| 8 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 10 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
| 11 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 12 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 12 #include "content/common/gpu/gpu_messages.h" | 13 #include "content/common/gpu/gpu_messages.h" |
| 13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 14 #include "ipc/ipc_sync_message_filter.h" | 15 #include "ipc/ipc_sync_message_filter.h" |
| 15 | 16 |
| 16 using base::AutoLock; | 17 using base::AutoLock; |
| 17 using base::MessageLoopProxy; | 18 using base::MessageLoopProxy; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 return false; | 106 return false; |
| 106 } | 107 } |
| 107 | 108 |
| 108 CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( | 109 CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( |
| 109 int32 surface_id, | 110 int32 surface_id, |
| 110 CommandBufferProxy* share_group, | 111 CommandBufferProxy* share_group, |
| 111 const std::string& allowed_extensions, | 112 const std::string& allowed_extensions, |
| 112 const std::vector<int32>& attribs, | 113 const std::vector<int32>& attribs, |
| 113 const GURL& active_url, | 114 const GURL& active_url, |
| 114 gfx::GpuPreference gpu_preference) { | 115 gfx::GpuPreference gpu_preference) { |
| 116 TRACE_EVENT1("gpu", |
| 117 "GpuChannelHost::CreateViewCommandBuffer", |
| 118 "surface_id", |
| 119 surface_id); |
| 120 |
| 115 #if defined(ENABLE_GPU) | 121 #if defined(ENABLE_GPU) |
| 116 AutoLock lock(context_lock_); | 122 AutoLock lock(context_lock_); |
| 117 // An error occurred. Need to get the host again to reinitialize it. | 123 // An error occurred. Need to get the host again to reinitialize it. |
| 118 if (!channel_.get()) | 124 if (!channel_.get()) |
| 119 return NULL; | 125 return NULL; |
| 120 | 126 |
| 121 GPUCreateCommandBufferConfig init_params; | 127 GPUCreateCommandBufferConfig init_params; |
| 122 init_params.share_group_id = | 128 init_params.share_group_id = |
| 123 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; | 129 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; |
| 124 init_params.allowed_extensions = allowed_extensions; | 130 init_params.allowed_extensions = allowed_extensions; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 139 #endif | 145 #endif |
| 140 } | 146 } |
| 141 | 147 |
| 142 CommandBufferProxy* GpuChannelHost::CreateOffscreenCommandBuffer( | 148 CommandBufferProxy* GpuChannelHost::CreateOffscreenCommandBuffer( |
| 143 const gfx::Size& size, | 149 const gfx::Size& size, |
| 144 CommandBufferProxy* share_group, | 150 CommandBufferProxy* share_group, |
| 145 const std::string& allowed_extensions, | 151 const std::string& allowed_extensions, |
| 146 const std::vector<int32>& attribs, | 152 const std::vector<int32>& attribs, |
| 147 const GURL& active_url, | 153 const GURL& active_url, |
| 148 gfx::GpuPreference gpu_preference) { | 154 gfx::GpuPreference gpu_preference) { |
| 155 TRACE_EVENT0("gpu", "GpuChannelHost::CreateOffscreenCommandBuffer"); |
| 156 |
| 149 #if defined(ENABLE_GPU) | 157 #if defined(ENABLE_GPU) |
| 150 AutoLock lock(context_lock_); | 158 AutoLock lock(context_lock_); |
| 151 // An error occurred. Need to get the host again to reinitialize it. | 159 // An error occurred. Need to get the host again to reinitialize it. |
| 152 if (!channel_.get()) | 160 if (!channel_.get()) |
| 153 return NULL; | 161 return NULL; |
| 154 | 162 |
| 155 GPUCreateCommandBufferConfig init_params; | 163 GPUCreateCommandBufferConfig init_params; |
| 156 init_params.share_group_id = | 164 init_params.share_group_id = |
| 157 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; | 165 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; |
| 158 init_params.allowed_extensions = allowed_extensions; | 166 init_params.allowed_extensions = allowed_extensions; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 185 media::VideoDecodeAccelerator::Client* client) { | 193 media::VideoDecodeAccelerator::Client* client) { |
| 186 AutoLock lock(context_lock_); | 194 AutoLock lock(context_lock_); |
| 187 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); | 195 ProxyMap::iterator it = proxies_.find(command_buffer_route_id); |
| 188 DCHECK(it != proxies_.end()); | 196 DCHECK(it != proxies_.end()); |
| 189 CommandBufferProxyImpl* proxy = it->second; | 197 CommandBufferProxyImpl* proxy = it->second; |
| 190 return proxy->CreateVideoDecoder(profile, client); | 198 return proxy->CreateVideoDecoder(profile, client); |
| 191 } | 199 } |
| 192 | 200 |
| 193 void GpuChannelHost::DestroyCommandBuffer( | 201 void GpuChannelHost::DestroyCommandBuffer( |
| 194 CommandBufferProxy* command_buffer) { | 202 CommandBufferProxy* command_buffer) { |
| 203 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
| 204 |
| 195 #if defined(ENABLE_GPU) | 205 #if defined(ENABLE_GPU) |
| 196 AutoLock lock(context_lock_); | 206 AutoLock lock(context_lock_); |
| 197 int route_id = command_buffer->GetRouteID(); | 207 int route_id = command_buffer->GetRouteID(); |
| 198 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 208 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
| 199 // Check the proxy has not already been removed after a channel error. | 209 // Check the proxy has not already been removed after a channel error. |
| 200 if (proxies_.find(route_id) != proxies_.end()) | 210 if (proxies_.find(route_id) != proxies_.end()) |
| 201 proxies_.erase(route_id); | 211 proxies_.erase(route_id); |
| 202 RemoveRoute(route_id); | 212 RemoveRoute(route_id); |
| 203 delete command_buffer; | 213 delete command_buffer; |
| 204 #endif | 214 #endif |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 314 } |
| 305 | 315 |
| 306 listeners_.clear(); | 316 listeners_.clear(); |
| 307 | 317 |
| 308 MessageLoop* main_loop = parent_->factory_->GetMainLoop(); | 318 MessageLoop* main_loop = parent_->factory_->GetMainLoop(); |
| 309 main_loop->PostTask(FROM_HERE, | 319 main_loop->PostTask(FROM_HERE, |
| 310 base::Bind(&GpuChannelHost::OnChannelError, parent_)); | 320 base::Bind(&GpuChannelHost::OnChannelError, parent_)); |
| 311 } | 321 } |
| 312 | 322 |
| 313 | 323 |
| OLD | NEW |