| 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 "gpu/ipc/client/gpu_channel_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/posix/eintr_wrapper.h" | 13 #include "base/posix/eintr_wrapper.h" |
| 14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
| 15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
| 20 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 20 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 21 #include "gpu/ipc/common/gpu_messages.h" | 21 #include "gpu/ipc/common/gpu_messages.h" |
| 22 #include "gpu/ipc/common/gpu_param_traits_macros.h" | 22 #include "gpu/ipc/common/gpu_param_traits_macros.h" |
| 23 #include "ipc/ipc_sync_message_filter.h" | 23 #include "ipc/ipc_sync_message_filter.h" |
| 24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 25 | 25 |
| 26 using base::AutoLock; | 26 using base::AutoLock; |
| 27 | 27 |
| 28 namespace content { | 28 namespace gpu { |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // Global atomic to generate unique transfer buffer IDs. | 31 // Global atomic to generate unique transfer buffer IDs. |
| 32 base::StaticAtomicSequenceNumber g_next_transfer_buffer_id; | 32 base::StaticAtomicSequenceNumber g_next_transfer_buffer_id; |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 GpuChannelHost::StreamFlushInfo::StreamFlushInfo() | 36 GpuChannelHost::StreamFlushInfo::StreamFlushInfo() |
| 37 : next_stream_flush_id(1), | 37 : next_stream_flush_id(1), |
| 38 flushed_stream_flush_id(0), | 38 flushed_stream_flush_id(0), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 // static | 51 // static |
| 52 scoped_refptr<GpuChannelHost> GpuChannelHost::Create( | 52 scoped_refptr<GpuChannelHost> GpuChannelHost::Create( |
| 53 GpuChannelHostFactory* factory, | 53 GpuChannelHostFactory* factory, |
| 54 int channel_id, | 54 int channel_id, |
| 55 const gpu::GPUInfo& gpu_info, | 55 const gpu::GPUInfo& gpu_info, |
| 56 const IPC::ChannelHandle& channel_handle, | 56 const IPC::ChannelHandle& channel_handle, |
| 57 base::WaitableEvent* shutdown_event, | 57 base::WaitableEvent* shutdown_event, |
| 58 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { | 58 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { |
| 59 DCHECK(factory->IsMainThread()); | 59 DCHECK(factory->IsMainThread()); |
| 60 scoped_refptr<GpuChannelHost> host = | 60 scoped_refptr<GpuChannelHost> host = new GpuChannelHost( |
| 61 new GpuChannelHost(factory, channel_id, gpu_info, | 61 factory, channel_id, gpu_info, gpu_memory_buffer_manager); |
| 62 gpu_memory_buffer_manager); | |
| 63 host->Connect(channel_handle, shutdown_event); | 62 host->Connect(channel_handle, shutdown_event); |
| 64 return host; | 63 return host; |
| 65 } | 64 } |
| 66 | 65 |
| 67 GpuChannelHost::GpuChannelHost( | 66 GpuChannelHost::GpuChannelHost( |
| 68 GpuChannelHostFactory* factory, | 67 GpuChannelHostFactory* factory, |
| 69 int channel_id, | 68 int channel_id, |
| 70 const gpu::GPUInfo& gpu_info, | 69 const gpu::GPUInfo& gpu_info, |
| 71 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) | 70 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) |
| 72 : factory_(factory), | 71 : factory_(factory), |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 if (flush_info.flush_pending && flush_info.route_id == route_id) | 255 if (flush_info.flush_pending && flush_info.route_id == route_id) |
| 257 flush_info.flush_pending = false; | 256 flush_info.flush_pending = false; |
| 258 } | 257 } |
| 259 | 258 |
| 260 void GpuChannelHost::DestroyChannel() { | 259 void GpuChannelHost::DestroyChannel() { |
| 261 DCHECK(factory_->IsMainThread()); | 260 DCHECK(factory_->IsMainThread()); |
| 262 AutoLock lock(context_lock_); | 261 AutoLock lock(context_lock_); |
| 263 channel_.reset(); | 262 channel_.reset(); |
| 264 } | 263 } |
| 265 | 264 |
| 266 void GpuChannelHost::AddRoute( | 265 void GpuChannelHost::AddRoute(int route_id, |
| 267 int route_id, base::WeakPtr<IPC::Listener> listener) { | 266 base::WeakPtr<IPC::Listener> listener) { |
| 268 AddRouteWithTaskRunner(route_id, listener, | 267 AddRouteWithTaskRunner(route_id, listener, |
| 269 base::ThreadTaskRunnerHandle::Get()); | 268 base::ThreadTaskRunnerHandle::Get()); |
| 270 } | 269 } |
| 271 | 270 |
| 272 void GpuChannelHost::AddRouteWithTaskRunner( | 271 void GpuChannelHost::AddRouteWithTaskRunner( |
| 273 int route_id, | 272 int route_id, |
| 274 base::WeakPtr<IPC::Listener> listener, | 273 base::WeakPtr<IPC::Listener> listener, |
| 275 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 274 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 276 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = | 275 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner = |
| 277 factory_->GetIOThreadTaskRunner(); | 276 factory_->GetIOThreadTaskRunner(); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 #endif | 405 #endif |
| 407 } | 406 } |
| 408 | 407 |
| 409 GpuChannelHost::MessageFilter::ListenerInfo::ListenerInfo() {} | 408 GpuChannelHost::MessageFilter::ListenerInfo::ListenerInfo() {} |
| 410 | 409 |
| 411 GpuChannelHost::MessageFilter::ListenerInfo::ListenerInfo( | 410 GpuChannelHost::MessageFilter::ListenerInfo::ListenerInfo( |
| 412 const ListenerInfo& other) = default; | 411 const ListenerInfo& other) = default; |
| 413 | 412 |
| 414 GpuChannelHost::MessageFilter::ListenerInfo::~ListenerInfo() {} | 413 GpuChannelHost::MessageFilter::ListenerInfo::~ListenerInfo() {} |
| 415 | 414 |
| 416 GpuChannelHost::MessageFilter::MessageFilter() | 415 GpuChannelHost::MessageFilter::MessageFilter() : lost_(false) {} |
| 417 : lost_(false) { | |
| 418 } | |
| 419 | 416 |
| 420 GpuChannelHost::MessageFilter::~MessageFilter() {} | 417 GpuChannelHost::MessageFilter::~MessageFilter() {} |
| 421 | 418 |
| 422 void GpuChannelHost::MessageFilter::AddRoute( | 419 void GpuChannelHost::MessageFilter::AddRoute( |
| 423 int32_t route_id, | 420 int32_t route_id, |
| 424 base::WeakPtr<IPC::Listener> listener, | 421 base::WeakPtr<IPC::Listener> listener, |
| 425 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 422 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 426 DCHECK(listeners_.find(route_id) == listeners_.end()); | 423 DCHECK(listeners_.find(route_id) == listeners_.end()); |
| 427 DCHECK(task_runner); | 424 DCHECK(task_runner); |
| 428 ListenerInfo info; | 425 ListenerInfo info; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 468 } |
| 472 | 469 |
| 473 listeners_.clear(); | 470 listeners_.clear(); |
| 474 } | 471 } |
| 475 | 472 |
| 476 bool GpuChannelHost::MessageFilter::IsLost() const { | 473 bool GpuChannelHost::MessageFilter::IsLost() const { |
| 477 AutoLock lock(lock_); | 474 AutoLock lock(lock_); |
| 478 return lost_; | 475 return lost_; |
| 479 } | 476 } |
| 480 | 477 |
| 481 } // namespace content | 478 } // namespace gpu |
| OLD | NEW |