| 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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 GpuListenerInfo::GpuListenerInfo() {} | 29 GpuListenerInfo::GpuListenerInfo() {} |
| 30 | 30 |
| 31 GpuListenerInfo::~GpuListenerInfo() {} | 31 GpuListenerInfo::~GpuListenerInfo() {} |
| 32 | 32 |
| 33 // static | 33 // static |
| 34 scoped_refptr<GpuChannelHost> GpuChannelHost::Create( | 34 scoped_refptr<GpuChannelHost> GpuChannelHost::Create( |
| 35 GpuChannelHostFactory* factory, | 35 GpuChannelHostFactory* factory, |
| 36 const gpu::GPUInfo& gpu_info, | 36 const gpu::GPUInfo& gpu_info, |
| 37 const IPC::ChannelHandle& channel_handle, | 37 const IPC::ChannelHandle& channel_handle, |
| 38 base::WaitableEvent* shutdown_event) { | 38 base::WaitableEvent* shutdown_event, |
| 39 cc::GpuMemoryBufferManager* gpu_memory_buffer_manager) { |
| 39 DCHECK(factory->IsMainThread()); | 40 DCHECK(factory->IsMainThread()); |
| 40 scoped_refptr<GpuChannelHost> host = new GpuChannelHost(factory, gpu_info); | 41 scoped_refptr<GpuChannelHost> host = |
| 42 new GpuChannelHost(factory, gpu_info, gpu_memory_buffer_manager); |
| 41 host->Connect(channel_handle, shutdown_event); | 43 host->Connect(channel_handle, shutdown_event); |
| 42 return host; | 44 return host; |
| 43 } | 45 } |
| 44 | 46 |
| 45 // static | 47 GpuChannelHost::GpuChannelHost( |
| 46 bool GpuChannelHost::IsValidGpuMemoryBuffer( | 48 GpuChannelHostFactory* factory, |
| 47 gfx::GpuMemoryBufferHandle handle) { | 49 const gpu::GPUInfo& gpu_info, |
| 48 switch (handle.type) { | 50 cc::GpuMemoryBufferManager* gpu_memory_buffer_manager) |
| 49 case gfx::SHARED_MEMORY_BUFFER: | |
| 50 #if defined(OS_MACOSX) | |
| 51 case gfx::IO_SURFACE_BUFFER: | |
| 52 #endif | |
| 53 #if defined(OS_ANDROID) | |
| 54 case gfx::SURFACE_TEXTURE_BUFFER: | |
| 55 #endif | |
| 56 #if defined(USE_X11) | |
| 57 case gfx::X11_PIXMAP_BUFFER: | |
| 58 #endif | |
| 59 return true; | |
| 60 default: | |
| 61 return false; | |
| 62 } | |
| 63 } | |
| 64 | |
| 65 GpuChannelHost::GpuChannelHost(GpuChannelHostFactory* factory, | |
| 66 const gpu::GPUInfo& gpu_info) | |
| 67 : factory_(factory), | 51 : factory_(factory), |
| 68 gpu_info_(gpu_info) { | 52 gpu_info_(gpu_info), |
| 53 gpu_memory_buffer_manager_(gpu_memory_buffer_manager) { |
| 69 next_transfer_buffer_id_.GetNext(); | 54 next_transfer_buffer_id_.GetNext(); |
| 70 next_gpu_memory_buffer_id_.GetNext(); | 55 next_image_id_.GetNext(); |
| 71 next_route_id_.GetNext(); | 56 next_route_id_.GetNext(); |
| 72 } | 57 } |
| 73 | 58 |
| 74 void GpuChannelHost::Connect(const IPC::ChannelHandle& channel_handle, | 59 void GpuChannelHost::Connect(const IPC::ChannelHandle& channel_handle, |
| 75 base::WaitableEvent* shutdown_event) { | 60 base::WaitableEvent* shutdown_event) { |
| 76 // Open a channel to the GPU process. We pass NULL as the main listener here | 61 // Open a channel to the GPU process. We pass NULL as the main listener here |
| 77 // since we need to filter everything to route it to the right thread. | 62 // since we need to filter everything to route it to the right thread. |
| 78 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); | 63 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); |
| 79 channel_ = IPC::SyncChannel::Create(channel_handle, | 64 channel_ = IPC::SyncChannel::Create(channel_handle, |
| 80 IPC::Channel::MODE_CLIENT, | 65 IPC::Channel::MODE_CLIENT, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 #if defined(USE_X11) | 304 #if defined(USE_X11) |
| 320 case gfx::X11_PIXMAP_BUFFER: | 305 case gfx::X11_PIXMAP_BUFFER: |
| 321 return source_handle; | 306 return source_handle; |
| 322 #endif | 307 #endif |
| 323 default: | 308 default: |
| 324 NOTREACHED(); | 309 NOTREACHED(); |
| 325 return gfx::GpuMemoryBufferHandle(); | 310 return gfx::GpuMemoryBufferHandle(); |
| 326 } | 311 } |
| 327 } | 312 } |
| 328 | 313 |
| 329 int32 GpuChannelHost::ReserveGpuMemoryBufferId() { | 314 int32 GpuChannelHost::ReserveImageId() { |
| 330 return next_gpu_memory_buffer_id_.GetNext(); | 315 return next_image_id_.GetNext(); |
| 331 } | 316 } |
| 332 | 317 |
| 333 int32 GpuChannelHost::GenerateRouteID() { | 318 int32 GpuChannelHost::GenerateRouteID() { |
| 334 return next_route_id_.GetNext(); | 319 return next_route_id_.GetNext(); |
| 335 } | 320 } |
| 336 | 321 |
| 337 GpuChannelHost::~GpuChannelHost() { | 322 GpuChannelHost::~GpuChannelHost() { |
| 338 // channel_ must be destroyed on the main thread. | 323 // channel_ must be destroyed on the main thread. |
| 339 if (!factory_->IsMainThread()) | 324 if (!factory_->IsMainThread()) |
| 340 factory_->GetMainLoop()->DeleteSoon(FROM_HERE, channel_.release()); | 325 factory_->GetMainLoop()->DeleteSoon(FROM_HERE, channel_.release()); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 | 391 |
| 407 listeners_.clear(); | 392 listeners_.clear(); |
| 408 } | 393 } |
| 409 | 394 |
| 410 bool GpuChannelHost::MessageFilter::IsLost() const { | 395 bool GpuChannelHost::MessageFilter::IsLost() const { |
| 411 AutoLock lock(lock_); | 396 AutoLock lock(lock_); |
| 412 return lost_; | 397 return lost_; |
| 413 } | 398 } |
| 414 | 399 |
| 415 } // namespace content | 400 } // namespace content |
| OLD | NEW |