| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/gpu/gpu_channel_host.h" | 5 #include "content/renderer/gpu/gpu_channel_host.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/message_loop_proxy.h" | 8 #include "base/message_loop_proxy.h" |
| 9 #include "content/common/child_process.h" | 9 #include "content/common/child_process.h" |
| 10 #include "content/common/gpu/gpu_messages.h" | 10 #include "content/common/gpu/gpu_messages.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // successful. See IPC::Message::Sender. | 198 // successful. See IPC::Message::Sender. |
| 199 delete message; | 199 delete message; |
| 200 return false; | 200 return false; |
| 201 } | 201 } |
| 202 | 202 |
| 203 CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( | 203 CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( |
| 204 int render_view_id, | 204 int render_view_id, |
| 205 CommandBufferProxy* share_group, | 205 CommandBufferProxy* share_group, |
| 206 const std::string& allowed_extensions, | 206 const std::string& allowed_extensions, |
| 207 const std::vector<int32>& attribs, | 207 const std::vector<int32>& attribs, |
| 208 const GURL& active_url) { | 208 const GURL& active_url, |
| 209 gfx::GpuPreference gpu_preference) { |
| 209 DCHECK(ChildThread::current()); | 210 DCHECK(ChildThread::current()); |
| 210 #if defined(ENABLE_GPU) | 211 #if defined(ENABLE_GPU) |
| 211 AutoLock lock(context_lock_); | 212 AutoLock lock(context_lock_); |
| 212 // An error occurred. Need to get the host again to reinitialize it. | 213 // An error occurred. Need to get the host again to reinitialize it. |
| 213 if (!channel_.get()) | 214 if (!channel_.get()) |
| 214 return NULL; | 215 return NULL; |
| 215 | 216 |
| 216 GPUCreateCommandBufferConfig init_params; | 217 GPUCreateCommandBufferConfig init_params; |
| 217 init_params.share_group_id = | 218 init_params.share_group_id = |
| 218 share_group ? share_group->route_id() : MSG_ROUTING_NONE; | 219 share_group ? share_group->route_id() : MSG_ROUTING_NONE; |
| 219 init_params.allowed_extensions = allowed_extensions; | 220 init_params.allowed_extensions = allowed_extensions; |
| 220 init_params.attribs = attribs; | 221 init_params.attribs = attribs; |
| 221 init_params.active_url = active_url; | 222 init_params.active_url = active_url; |
| 223 init_params.gpu_preference = gpu_preference; |
| 222 int32 route_id; | 224 int32 route_id; |
| 223 if (!ChildThread::current()->Send( | 225 if (!ChildThread::current()->Send( |
| 224 new GpuHostMsg_CreateViewCommandBuffer( | 226 new GpuHostMsg_CreateViewCommandBuffer( |
| 225 render_view_id, | 227 render_view_id, |
| 226 init_params, | 228 init_params, |
| 227 &route_id))) { | 229 &route_id))) { |
| 228 return NULL; | 230 return NULL; |
| 229 } | 231 } |
| 230 | 232 |
| 231 if (route_id == MSG_ROUTING_NONE) | 233 if (route_id == MSG_ROUTING_NONE) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 249 DCHECK(it != proxies_.end()); | 251 DCHECK(it != proxies_.end()); |
| 250 CommandBufferProxy* proxy = it->second; | 252 CommandBufferProxy* proxy = it->second; |
| 251 return proxy->CreateVideoDecoder(profile, client); | 253 return proxy->CreateVideoDecoder(profile, client); |
| 252 } | 254 } |
| 253 | 255 |
| 254 CommandBufferProxy* GpuChannelHost::CreateOffscreenCommandBuffer( | 256 CommandBufferProxy* GpuChannelHost::CreateOffscreenCommandBuffer( |
| 255 const gfx::Size& size, | 257 const gfx::Size& size, |
| 256 CommandBufferProxy* share_group, | 258 CommandBufferProxy* share_group, |
| 257 const std::string& allowed_extensions, | 259 const std::string& allowed_extensions, |
| 258 const std::vector<int32>& attribs, | 260 const std::vector<int32>& attribs, |
| 259 const GURL& active_url) { | 261 const GURL& active_url, |
| 262 gfx::GpuPreference gpu_preference) { |
| 260 #if defined(ENABLE_GPU) | 263 #if defined(ENABLE_GPU) |
| 261 AutoLock lock(context_lock_); | 264 AutoLock lock(context_lock_); |
| 262 // An error occurred. Need to get the host again to reinitialize it. | 265 // An error occurred. Need to get the host again to reinitialize it. |
| 263 if (!channel_.get()) | 266 if (!channel_.get()) |
| 264 return NULL; | 267 return NULL; |
| 265 | 268 |
| 266 GPUCreateCommandBufferConfig init_params; | 269 GPUCreateCommandBufferConfig init_params; |
| 267 init_params.share_group_id = | 270 init_params.share_group_id = |
| 268 share_group ? share_group->route_id() : MSG_ROUTING_NONE; | 271 share_group ? share_group->route_id() : MSG_ROUTING_NONE; |
| 269 init_params.allowed_extensions = allowed_extensions; | 272 init_params.allowed_extensions = allowed_extensions; |
| 270 init_params.attribs = attribs; | 273 init_params.attribs = attribs; |
| 271 init_params.active_url = active_url; | 274 init_params.active_url = active_url; |
| 275 init_params.gpu_preference = gpu_preference; |
| 272 int32 route_id; | 276 int32 route_id; |
| 273 if (!Send(new GpuChannelMsg_CreateOffscreenCommandBuffer(size, | 277 if (!Send(new GpuChannelMsg_CreateOffscreenCommandBuffer(size, |
| 274 init_params, | 278 init_params, |
| 275 &route_id))) { | 279 &route_id))) { |
| 276 return NULL; | 280 return NULL; |
| 277 } | 281 } |
| 278 | 282 |
| 279 if (route_id == MSG_ROUTING_NONE) | 283 if (route_id == MSG_ROUTING_NONE) |
| 280 return NULL; | 284 return NULL; |
| 281 | 285 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 } | 319 } |
| 316 | 320 |
| 317 void GpuChannelHost::RemoveRoute(int route_id) { | 321 void GpuChannelHost::RemoveRoute(int route_id) { |
| 318 MessageLoopProxy* io_loop = RenderProcess::current()->io_message_loop_proxy(); | 322 MessageLoopProxy* io_loop = RenderProcess::current()->io_message_loop_proxy(); |
| 319 io_loop->PostTask(FROM_HERE, | 323 io_loop->PostTask(FROM_HERE, |
| 320 NewRunnableMethod( | 324 NewRunnableMethod( |
| 321 channel_filter_.get(), | 325 channel_filter_.get(), |
| 322 &GpuChannelHost::MessageFilter::RemoveRoute, | 326 &GpuChannelHost::MessageFilter::RemoveRoute, |
| 323 route_id)); | 327 route_id)); |
| 324 } | 328 } |
| 329 |
| 330 bool GpuChannelHost::WillGpuSwitchOccur( |
| 331 bool is_creating_context, gfx::GpuPreference gpu_preference) { |
| 332 bool result = false; |
| 333 if (!Send(new GpuChannelMsg_WillGpuSwitchOccur(is_creating_context, |
| 334 gpu_preference, |
| 335 &result))) { |
| 336 return false; |
| 337 } |
| 338 return result; |
| 339 } |
| 340 |
| 341 void GpuChannelHost::ForciblyCloseChannel() { |
| 342 Send(new GpuChannelMsg_CloseChannel()); |
| 343 SetStateLost(); |
| 344 } |
| OLD | NEW |