| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/child/child_gpu_memory_buffer_manager.h" | 5 #include "content/child/child_gpu_memory_buffer_manager.h" |
| 6 | 6 |
| 7 #include "content/common/child_process_messages.h" | 7 #include "content/common/child_process_messages.h" |
| 8 #include "content/common/generic_shared_memory_id_generator.h" | 8 #include "content/common/generic_shared_memory_id_generator.h" |
| 9 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 9 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 10 | 10 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 "width", | 38 "width", |
| 39 size.width(), | 39 size.width(), |
| 40 "height", | 40 "height", |
| 41 size.height()); | 41 size.height()); |
| 42 | 42 |
| 43 gfx::GpuMemoryBufferHandle handle; | 43 gfx::GpuMemoryBufferHandle handle; |
| 44 IPC::Message* message = new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer( | 44 IPC::Message* message = new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer( |
| 45 content::GetNextGenericSharedMemoryId(), size.width(), size.height(), | 45 content::GetNextGenericSharedMemoryId(), size.width(), size.height(), |
| 46 format, usage, &handle); | 46 format, usage, &handle); |
| 47 bool success = sender_->Send(message); | 47 bool success = sender_->Send(message); |
| 48 CHECK(success); | 48 if (!success || handle.is_null()) |
| 49 CHECK(!handle.is_null()); | 49 return nullptr; |
| 50 | 50 |
| 51 scoped_ptr<GpuMemoryBufferImpl> buffer(GpuMemoryBufferImpl::CreateFromHandle( | 51 scoped_ptr<GpuMemoryBufferImpl> buffer(GpuMemoryBufferImpl::CreateFromHandle( |
| 52 handle, size, format, usage, | 52 handle, size, format, usage, |
| 53 base::Bind(&DeletedGpuMemoryBuffer, sender_, handle.id))); | 53 base::Bind(&DeletedGpuMemoryBuffer, sender_, handle.id))); |
| 54 CHECK(buffer); | 54 if (!buffer) { |
| 55 sender_->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer( |
| 56 handle.id, gpu::SyncToken())); |
| 57 return nullptr; |
| 58 } |
| 59 |
| 55 return buffer.Pass(); | 60 return buffer.Pass(); |
| 56 } | 61 } |
| 57 | 62 |
| 58 scoped_ptr<gfx::GpuMemoryBuffer> | 63 scoped_ptr<gfx::GpuMemoryBuffer> |
| 59 ChildGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle( | 64 ChildGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle( |
| 60 const gfx::GpuMemoryBufferHandle& handle, | 65 const gfx::GpuMemoryBufferHandle& handle, |
| 61 const gfx::Size& size, | 66 const gfx::Size& size, |
| 62 gfx::BufferFormat format) { | 67 gfx::BufferFormat format) { |
| 63 NOTIMPLEMENTED(); | 68 NOTIMPLEMENTED(); |
| 64 return nullptr; | 69 return nullptr; |
| 65 } | 70 } |
| 66 | 71 |
| 67 gfx::GpuMemoryBuffer* | 72 gfx::GpuMemoryBuffer* |
| 68 ChildGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( | 73 ChildGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( |
| 69 ClientBuffer buffer) { | 74 ClientBuffer buffer) { |
| 70 return GpuMemoryBufferImpl::FromClientBuffer(buffer); | 75 return GpuMemoryBufferImpl::FromClientBuffer(buffer); |
| 71 } | 76 } |
| 72 | 77 |
| 73 void ChildGpuMemoryBufferManager::SetDestructionSyncToken( | 78 void ChildGpuMemoryBufferManager::SetDestructionSyncToken( |
| 74 gfx::GpuMemoryBuffer* buffer, | 79 gfx::GpuMemoryBuffer* buffer, |
| 75 const gpu::SyncToken& sync_token) { | 80 const gpu::SyncToken& sync_token) { |
| 76 static_cast<GpuMemoryBufferImpl*>(buffer) | 81 static_cast<GpuMemoryBufferImpl*>(buffer) |
| 77 ->set_destruction_sync_token(sync_token); | 82 ->set_destruction_sync_token(sync_token); |
| 78 } | 83 } |
| 79 | 84 |
| 80 } // namespace content | 85 } // namespace content |
| OLD | NEW |