| 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 namespace content { | 29 namespace content { |
| 30 | 30 |
| 31 GpuListenerInfo::GpuListenerInfo() {} | 31 GpuListenerInfo::GpuListenerInfo() {} |
| 32 | 32 |
| 33 GpuListenerInfo::~GpuListenerInfo() {} | 33 GpuListenerInfo::~GpuListenerInfo() {} |
| 34 | 34 |
| 35 // static | 35 // static |
| 36 scoped_refptr<GpuChannelHost> GpuChannelHost::Create( | 36 scoped_refptr<GpuChannelHost> GpuChannelHost::Create( |
| 37 GpuChannelHostFactory* factory, | 37 GpuChannelHostFactory* factory, |
| 38 int gpu_host_id, | |
| 39 const gpu::GPUInfo& gpu_info, | 38 const gpu::GPUInfo& gpu_info, |
| 40 const IPC::ChannelHandle& channel_handle) { | 39 const IPC::ChannelHandle& channel_handle) { |
| 41 DCHECK(factory->IsMainThread()); | 40 DCHECK(factory->IsMainThread()); |
| 42 scoped_refptr<GpuChannelHost> host = new GpuChannelHost( | 41 scoped_refptr<GpuChannelHost> host = new GpuChannelHost( |
| 43 factory, gpu_host_id, gpu_info); | 42 factory, gpu_info); |
| 44 host->Connect(channel_handle); | 43 host->Connect(channel_handle); |
| 45 return host; | 44 return host; |
| 46 } | 45 } |
| 47 | 46 |
| 48 // static | 47 // static |
| 49 bool GpuChannelHost::IsValidGpuMemoryBuffer( | 48 bool GpuChannelHost::IsValidGpuMemoryBuffer( |
| 50 gfx::GpuMemoryBufferHandle handle) { | 49 gfx::GpuMemoryBufferHandle handle) { |
| 51 switch (handle.type) { | 50 switch (handle.type) { |
| 52 case gfx::SHARED_MEMORY_BUFFER: | 51 case gfx::SHARED_MEMORY_BUFFER: |
| 53 #if defined(OS_MACOSX) | 52 #if defined(OS_MACOSX) |
| 54 case gfx::IO_SURFACE_BUFFER: | 53 case gfx::IO_SURFACE_BUFFER: |
| 55 #endif | 54 #endif |
| 56 return true; | 55 return true; |
| 57 default: | 56 default: |
| 58 return false; | 57 return false; |
| 59 } | 58 } |
| 60 } | 59 } |
| 61 | 60 |
| 62 GpuChannelHost::GpuChannelHost(GpuChannelHostFactory* factory, | 61 GpuChannelHost::GpuChannelHost(GpuChannelHostFactory* factory, |
| 63 int gpu_host_id, | |
| 64 const gpu::GPUInfo& gpu_info) | 62 const gpu::GPUInfo& gpu_info) |
| 65 : factory_(factory), | 63 : factory_(factory), |
| 66 gpu_host_id_(gpu_host_id), | |
| 67 gpu_info_(gpu_info) { | 64 gpu_info_(gpu_info) { |
| 68 next_transfer_buffer_id_.GetNext(); | 65 next_transfer_buffer_id_.GetNext(); |
| 69 next_gpu_memory_buffer_id_.GetNext(); | 66 next_gpu_memory_buffer_id_.GetNext(); |
| 70 } | 67 } |
| 71 | 68 |
| 72 void GpuChannelHost::Connect(const IPC::ChannelHandle& channel_handle) { | 69 void GpuChannelHost::Connect(const IPC::ChannelHandle& channel_handle) { |
| 73 // Open a channel to the GPU process. We pass NULL as the main listener here | 70 // 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. | 71 // since we need to filter everything to route it to the right thread. |
| 75 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); | 72 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); |
| 76 channel_.reset(new IPC::SyncChannel(channel_handle, | 73 channel_.reset(new IPC::SyncChannel(channel_handle, |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 AutoLock lock(lock_); | 440 AutoLock lock(lock_); |
| 444 DCHECK_LE(names.size(), requested_mailboxes_); | 441 DCHECK_LE(names.size(), requested_mailboxes_); |
| 445 requested_mailboxes_ -= names.size(); | 442 requested_mailboxes_ -= names.size(); |
| 446 mailbox_name_pool_.insert(mailbox_name_pool_.end(), | 443 mailbox_name_pool_.insert(mailbox_name_pool_.end(), |
| 447 names.begin(), | 444 names.begin(), |
| 448 names.end()); | 445 names.end()); |
| 449 } | 446 } |
| 450 | 447 |
| 451 | 448 |
| 452 } // namespace content | 449 } // namespace content |
| OLD | NEW |