| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 bool GpuChannelHost::IsValidGpuMemoryBuffer( | 46 bool GpuChannelHost::IsValidGpuMemoryBuffer( |
| 47 gfx::GpuMemoryBufferHandle handle) { | 47 gfx::GpuMemoryBufferHandle handle) { |
| 48 switch (handle.type) { | 48 switch (handle.type) { |
| 49 case gfx::SHARED_MEMORY_BUFFER: | 49 case gfx::SHARED_MEMORY_BUFFER: |
| 50 #if defined(OS_MACOSX) | 50 #if defined(OS_MACOSX) |
| 51 case gfx::IO_SURFACE_BUFFER: | 51 case gfx::IO_SURFACE_BUFFER: |
| 52 #endif | 52 #endif |
| 53 #if defined(OS_ANDROID) | 53 #if defined(OS_ANDROID) |
| 54 case gfx::SURFACE_TEXTURE_BUFFER: | 54 case gfx::SURFACE_TEXTURE_BUFFER: |
| 55 #endif | 55 #endif |
| 56 #if defined(OS_LINUX) |
| 57 case gfx::DMA_BUFFER: |
| 58 #endif |
| 56 return true; | 59 return true; |
| 57 default: | 60 default: |
| 58 return false; | 61 return false; |
| 59 } | 62 } |
| 60 } | 63 } |
| 61 | 64 |
| 62 GpuChannelHost::GpuChannelHost(GpuChannelHostFactory* factory, | 65 GpuChannelHost::GpuChannelHost(GpuChannelHostFactory* factory, |
| 63 const gpu::GPUInfo& gpu_info) | 66 const gpu::GPUInfo& gpu_info) |
| 64 : factory_(factory), | 67 : factory_(factory), |
| 65 gpu_info_(gpu_info) { | 68 gpu_info_(gpu_info) { |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 channel_->GetPeerPID(), | 272 channel_->GetPeerPID(), |
| 270 &target_handle, | 273 &target_handle, |
| 271 FILE_GENERIC_READ | FILE_GENERIC_WRITE, | 274 FILE_GENERIC_READ | FILE_GENERIC_WRITE, |
| 272 0)) { | 275 0)) { |
| 273 return base::SharedMemory::NULLHandle(); | 276 return base::SharedMemory::NULLHandle(); |
| 274 } | 277 } |
| 275 | 278 |
| 276 return target_handle; | 279 return target_handle; |
| 277 #else | 280 #else |
| 278 int duped_handle = HANDLE_EINTR(dup(source_handle.fd)); | 281 int duped_handle = HANDLE_EINTR(dup(source_handle.fd)); |
| 282 //int duped_handle = source_handle.fd; |
| 279 if (duped_handle < 0) | 283 if (duped_handle < 0) |
| 280 return base::SharedMemory::NULLHandle(); | 284 return base::SharedMemory::NULLHandle(); |
| 281 | 285 |
| 282 return base::FileDescriptor(duped_handle, true); | 286 return base::FileDescriptor(duped_handle, true); |
| 283 #endif | 287 #endif |
| 284 } | 288 } |
| 285 | 289 |
| 286 int32 GpuChannelHost::ReserveTransferBufferId() { | 290 int32 GpuChannelHost::ReserveTransferBufferId() { |
| 287 return next_transfer_buffer_id_.GetNext(); | 291 return next_transfer_buffer_id_.GetNext(); |
| 288 } | 292 } |
| 289 | 293 |
| 290 gfx::GpuMemoryBufferHandle GpuChannelHost::ShareGpuMemoryBufferToGpuProcess( | 294 gfx::GpuMemoryBufferHandle GpuChannelHost::ShareGpuMemoryBufferToGpuProcess( |
| 291 gfx::GpuMemoryBufferHandle source_handle) { | 295 gfx::GpuMemoryBufferHandle source_handle) { |
| 292 switch (source_handle.type) { | 296 switch (source_handle.type) { |
| 297 #if defined(OS_LINUX) |
| 298 case gfx::DMA_BUFFER: |
| 299 #endif |
| 293 case gfx::SHARED_MEMORY_BUFFER: { | 300 case gfx::SHARED_MEMORY_BUFFER: { |
| 294 gfx::GpuMemoryBufferHandle handle; | 301 gfx::GpuMemoryBufferHandle handle; |
| 295 handle.type = gfx::SHARED_MEMORY_BUFFER; | 302 handle.type = source_handle.type; |
| 296 handle.handle = ShareToGpuProcess(source_handle.handle); | 303 handle.handle = ShareToGpuProcess(source_handle.handle); |
| 304 //fprintf(stderr, "(%d -> %d)\n", source_handle.handle.fd, handle.handle.f
d); |
| 305 handle.card_handle = ShareToGpuProcess(source_handle.card_handle); |
| 306 handle.stride = source_handle.stride; |
| 297 return handle; | 307 return handle; |
| 298 } | 308 } |
| 299 #if defined(OS_MACOSX) | 309 #if defined(OS_MACOSX) |
| 300 case gfx::IO_SURFACE_BUFFER: | 310 case gfx::IO_SURFACE_BUFFER: |
| 301 return source_handle; | 311 return source_handle; |
| 302 #endif | 312 #endif |
| 303 #if defined(OS_ANDROID) | 313 #if defined(OS_ANDROID) |
| 304 case gfx::SURFACE_TEXTURE_BUFFER: | 314 case gfx::SURFACE_TEXTURE_BUFFER: |
| 305 return source_handle; | 315 return source_handle; |
| 306 #endif | 316 #endif |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 400 |
| 391 listeners_.clear(); | 401 listeners_.clear(); |
| 392 } | 402 } |
| 393 | 403 |
| 394 bool GpuChannelHost::MessageFilter::IsLost() const { | 404 bool GpuChannelHost::MessageFilter::IsLost() const { |
| 395 AutoLock lock(lock_); | 405 AutoLock lock(lock_); |
| 396 return lost_; | 406 return lost_; |
| 397 } | 407 } |
| 398 | 408 |
| 399 } // namespace content | 409 } // namespace content |
| OLD | NEW |