Chromium Code Reviews| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 host->Connect(channel_handle, shutdown_event); | 54 host->Connect(channel_handle, shutdown_event); |
| 55 return host; | 55 return host; |
| 56 } | 56 } |
| 57 | 57 |
| 58 GpuChannelHost::GpuChannelHost( | 58 GpuChannelHost::GpuChannelHost( |
| 59 GpuChannelHostFactory* factory, | 59 GpuChannelHostFactory* factory, |
| 60 const gpu::GPUInfo& gpu_info, | 60 const gpu::GPUInfo& gpu_info, |
| 61 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) | 61 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) |
| 62 : factory_(factory), | 62 : factory_(factory), |
| 63 gpu_info_(gpu_info), | 63 gpu_info_(gpu_info), |
| 64 gpu_memory_buffer_manager_(gpu_memory_buffer_manager) { | 64 gpu_memory_buffer_manager_(gpu_memory_buffer_manager), |
| 65 command_buffer_routing_id_(0) { | |
| 65 next_transfer_buffer_id_.GetNext(); | 66 next_transfer_buffer_id_.GetNext(); |
| 66 next_image_id_.GetNext(); | 67 next_image_id_.GetNext(); |
| 67 next_route_id_.GetNext(); | 68 next_route_id_.GetNext(); |
| 68 } | 69 } |
| 69 | 70 |
| 70 void GpuChannelHost::Connect(const IPC::ChannelHandle& channel_handle, | 71 void GpuChannelHost::Connect(const IPC::ChannelHandle& channel_handle, |
| 71 base::WaitableEvent* shutdown_event) { | 72 base::WaitableEvent* shutdown_event) { |
| 72 DCHECK(factory_->IsMainThread()); | 73 DCHECK(factory_->IsMainThread()); |
| 73 // Open a channel to the GPU process. We pass NULL as the main listener here | 74 // Open a channel to the GPU process. We pass NULL as the main listener here |
| 74 // since we need to filter everything to route it to the right thread. | 75 // since we need to filter everything to route it to the right thread. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 | 229 |
| 229 if (!succeeded) { | 230 if (!succeeded) { |
| 230 LOG(ERROR) | 231 LOG(ERROR) |
| 231 << "GpuChannelMsg_CreateOffscreenCommandBuffer returned failure."; | 232 << "GpuChannelMsg_CreateOffscreenCommandBuffer returned failure."; |
| 232 return NULL; | 233 return NULL; |
| 233 } | 234 } |
| 234 | 235 |
| 235 CommandBufferProxyImpl* command_buffer = | 236 CommandBufferProxyImpl* command_buffer = |
| 236 new CommandBufferProxyImpl(this, route_id); | 237 new CommandBufferProxyImpl(this, route_id); |
| 237 AddRoute(route_id, command_buffer->AsWeakPtr()); | 238 AddRoute(route_id, command_buffer->AsWeakPtr()); |
| 239 command_buffer_routing_id_ = route_id; | |
|
piman
2015/06/30 23:04:20
NAK. A channel has multiple command buffers, and t
sivag
2015/07/16 14:24:58
Done.
| |
| 238 | 240 |
| 239 AutoLock lock(context_lock_); | 241 AutoLock lock(context_lock_); |
| 240 proxies_[route_id] = command_buffer; | 242 proxies_[route_id] = command_buffer; |
| 241 return command_buffer; | 243 return command_buffer; |
| 242 } | 244 } |
| 243 | 245 |
| 244 scoped_ptr<media::VideoDecodeAccelerator> GpuChannelHost::CreateVideoDecoder( | 246 scoped_ptr<media::VideoDecodeAccelerator> GpuChannelHost::CreateVideoDecoder( |
| 245 int command_buffer_route_id) { | 247 int command_buffer_route_id) { |
| 246 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoDecoder"); | 248 TRACE_EVENT0("gpu", "GpuChannelHost::CreateVideoDecoder"); |
| 247 AutoLock lock(context_lock_); | 249 AutoLock lock(context_lock_); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 void GpuChannelHost::DestroyCommandBuffer( | 286 void GpuChannelHost::DestroyCommandBuffer( |
| 285 CommandBufferProxyImpl* command_buffer) { | 287 CommandBufferProxyImpl* command_buffer) { |
| 286 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); | 288 TRACE_EVENT0("gpu", "GpuChannelHost::DestroyCommandBuffer"); |
| 287 | 289 |
| 288 int route_id = command_buffer->GetRouteID(); | 290 int route_id = command_buffer->GetRouteID(); |
| 289 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); | 291 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); |
| 290 RemoveRoute(route_id); | 292 RemoveRoute(route_id); |
| 291 | 293 |
| 292 AutoLock lock(context_lock_); | 294 AutoLock lock(context_lock_); |
| 293 proxies_.erase(route_id); | 295 proxies_.erase(route_id); |
| 296 command_buffer_routing_id_ = 0; | |
| 294 if (flush_info_.flush_pending && flush_info_.route_id == route_id) | 297 if (flush_info_.flush_pending && flush_info_.route_id == route_id) |
| 295 flush_info_.flush_pending = false; | 298 flush_info_.flush_pending = false; |
| 296 | 299 |
| 297 delete command_buffer; | 300 delete command_buffer; |
| 298 } | 301 } |
| 299 | 302 |
| 300 void GpuChannelHost::DestroyChannel() { | 303 void GpuChannelHost::DestroyChannel() { |
| 301 DCHECK(factory_->IsMainThread()); | 304 DCHECK(factory_->IsMainThread()); |
| 302 AutoLock lock(context_lock_); | 305 AutoLock lock(context_lock_); |
| 303 channel_.reset(); | 306 channel_.reset(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 } | 392 } |
| 390 | 393 |
| 391 GpuChannelHost::~GpuChannelHost() { | 394 GpuChannelHost::~GpuChannelHost() { |
| 392 #if DCHECK_IS_ON() | 395 #if DCHECK_IS_ON() |
| 393 AutoLock lock(context_lock_); | 396 AutoLock lock(context_lock_); |
| 394 DCHECK(!channel_) | 397 DCHECK(!channel_) |
| 395 << "GpuChannelHost::DestroyChannel must be called before destruction."; | 398 << "GpuChannelHost::DestroyChannel must be called before destruction."; |
| 396 #endif | 399 #endif |
| 397 } | 400 } |
| 398 | 401 |
| 402 unsigned GpuChannelHost::CreateStreamTexture(int32 image_id) { | |
| 403 DCHECK(command_buffer_routing_id_); | |
| 404 int32 stream_id = GenerateRouteID(); | |
| 405 bool succeeded = factory_->CreateStreamTexture( | |
| 406 image_id, command_buffer_routing_id_, stream_id); | |
| 407 if (!succeeded) { | |
| 408 DLOG(ERROR) << "GpuCommandBufferMsg_CreateStreamTexture returned failure"; | |
| 409 return 0; | |
| 410 } | |
| 411 return stream_id; | |
| 412 } | |
| 413 | |
| 399 GpuChannelHost::MessageFilter::MessageFilter() | 414 GpuChannelHost::MessageFilter::MessageFilter() |
| 400 : lost_(false) { | 415 : lost_(false) { |
| 401 } | 416 } |
| 402 | 417 |
| 403 GpuChannelHost::MessageFilter::~MessageFilter() {} | 418 GpuChannelHost::MessageFilter::~MessageFilter() {} |
| 404 | 419 |
| 405 void GpuChannelHost::MessageFilter::AddRoute( | 420 void GpuChannelHost::MessageFilter::AddRoute( |
| 406 int route_id, | 421 int route_id, |
| 407 base::WeakPtr<IPC::Listener> listener, | 422 base::WeakPtr<IPC::Listener> listener, |
| 408 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 423 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 | 474 |
| 460 listeners_.clear(); | 475 listeners_.clear(); |
| 461 } | 476 } |
| 462 | 477 |
| 463 bool GpuChannelHost::MessageFilter::IsLost() const { | 478 bool GpuChannelHost::MessageFilter::IsLost() const { |
| 464 AutoLock lock(lock_); | 479 AutoLock lock(lock_); |
| 465 return lost_; | 480 return lost_; |
| 466 } | 481 } |
| 467 | 482 |
| 468 } // namespace content | 483 } // namespace content |
| OLD | NEW |