| 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/child_process_host_impl.h" | 5 #include "content/common/child_process_host_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 if (delegate_->CanShutdown()) | 313 if (delegate_->CanShutdown()) |
| 314 Send(new ChildProcessMsg_Shutdown()); | 314 Send(new ChildProcessMsg_Shutdown()); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer( | 317 void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer( |
| 318 uint32 width, | 318 uint32 width, |
| 319 uint32 height, | 319 uint32 height, |
| 320 gfx::GpuMemoryBuffer::Format format, | 320 gfx::GpuMemoryBuffer::Format format, |
| 321 gfx::GpuMemoryBuffer::Usage usage, | 321 gfx::GpuMemoryBuffer::Usage usage, |
| 322 IPC::Message* reply) { | 322 IPC::Message* reply) { |
| 323 base::CheckedNumeric<int> size = width; | 323 // TODO(reveman): Add support for other types of GpuMemoryBuffers. |
| 324 size *= height; | 324 |
| 325 if (!size.IsValid()) { | 325 // AllocateForChildProcess() will check if |width| and |height| are valid |
| 326 // and handle failure in a controlled way when not. We just need to make |
| 327 // sure |format| and |usage| are supported here. |
| 328 if (!GpuMemoryBufferImplSharedMemory::IsFormatSupported(format) || |
| 329 !GpuMemoryBufferImplSharedMemory::IsUsageSupported(usage)) { |
| 326 GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle()); | 330 GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle()); |
| 327 return; | 331 return; |
| 328 } | 332 } |
| 329 | |
| 330 // TODO(reveman): Add support for other types of GpuMemoryBuffers. | |
| 331 if (!GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | |
| 332 gfx::Size(width, height), format, usage)) { | |
| 333 GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle()); | |
| 334 return; | |
| 335 } | |
| 336 | 333 |
| 337 // Note: It is safe to use base::Unretained here as the shared memory | 334 // Note: It is safe to use base::Unretained here as the shared memory |
| 338 // implementation of AllocateForChildProcess() calls this synchronously. | 335 // implementation of AllocateForChildProcess() calls this synchronously. |
| 339 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( | 336 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
| 340 g_next_gpu_memory_buffer_id.GetNext(), | 337 g_next_gpu_memory_buffer_id.GetNext(), |
| 341 gfx::Size(width, height), | 338 gfx::Size(width, height), |
| 342 format, | 339 format, |
| 343 peer_handle_, | 340 peer_handle_, |
| 344 base::Bind(&ChildProcessHostImpl::GpuMemoryBufferAllocated, | 341 base::Bind(&ChildProcessHostImpl::GpuMemoryBufferAllocated, |
| 345 base::Unretained(this), | 342 base::Unretained(this), |
| 346 reply)); | 343 reply)); |
| 347 } | 344 } |
| 348 | 345 |
| 349 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( | 346 void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer( |
| 350 gfx::GpuMemoryBufferId id, | 347 gfx::GpuMemoryBufferId id, |
| 351 uint32 sync_point) { | 348 uint32 sync_point) { |
| 352 // Note: Nothing to do here as ownership of shared memory backed | 349 // Note: Nothing to do here as ownership of shared memory backed |
| 353 // GpuMemoryBuffers is passed with IPC. | 350 // GpuMemoryBuffers is passed with IPC. |
| 354 } | 351 } |
| 355 | 352 |
| 356 void ChildProcessHostImpl::GpuMemoryBufferAllocated( | 353 void ChildProcessHostImpl::GpuMemoryBufferAllocated( |
| 357 IPC::Message* reply, | 354 IPC::Message* reply, |
| 358 const gfx::GpuMemoryBufferHandle& handle) { | 355 const gfx::GpuMemoryBufferHandle& handle) { |
| 359 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, | 356 ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
| 360 handle); | 357 handle); |
| 361 Send(reply); | 358 Send(reply); |
| 362 } | 359 } |
| 363 | 360 |
| 364 } // namespace content | 361 } // namespace content |
| OLD | NEW |