Chromium Code Reviews| 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 if (!success || handle.is_null()) | 48 CHECK(success); |
| 49 return nullptr; | 49 CHECK(!handle.is_null()); |
| 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 if (!buffer) { | 54 CHECK(buffer); |
|
reveman
2015/12/04 01:47:04
nit: I don't think this should be able to fail unl
ccameron
2015/12/04 02:36:20
I could picture it failing if, for instance, IOSur
| |
| 55 sender_->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer( | |
| 56 handle.id, gpu::SyncToken())); | |
| 57 return nullptr; | |
| 58 } | |
| 59 | |
| 60 return buffer.Pass(); | 55 return buffer.Pass(); |
| 61 } | 56 } |
| 62 | 57 |
| 63 scoped_ptr<gfx::GpuMemoryBuffer> | 58 scoped_ptr<gfx::GpuMemoryBuffer> |
| 64 ChildGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle( | 59 ChildGpuMemoryBufferManager::CreateGpuMemoryBufferFromHandle( |
| 65 const gfx::GpuMemoryBufferHandle& handle, | 60 const gfx::GpuMemoryBufferHandle& handle, |
| 66 const gfx::Size& size, | 61 const gfx::Size& size, |
| 67 gfx::BufferFormat format) { | 62 gfx::BufferFormat format) { |
| 68 NOTIMPLEMENTED(); | 63 NOTIMPLEMENTED(); |
| 69 return nullptr; | 64 return nullptr; |
| 70 } | 65 } |
| 71 | 66 |
| 72 gfx::GpuMemoryBuffer* | 67 gfx::GpuMemoryBuffer* |
| 73 ChildGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( | 68 ChildGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer( |
| 74 ClientBuffer buffer) { | 69 ClientBuffer buffer) { |
| 75 return GpuMemoryBufferImpl::FromClientBuffer(buffer); | 70 return GpuMemoryBufferImpl::FromClientBuffer(buffer); |
| 76 } | 71 } |
| 77 | 72 |
| 78 void ChildGpuMemoryBufferManager::SetDestructionSyncToken( | 73 void ChildGpuMemoryBufferManager::SetDestructionSyncToken( |
| 79 gfx::GpuMemoryBuffer* buffer, | 74 gfx::GpuMemoryBuffer* buffer, |
| 80 const gpu::SyncToken& sync_token) { | 75 const gpu::SyncToken& sync_token) { |
| 81 static_cast<GpuMemoryBufferImpl*>(buffer) | 76 static_cast<GpuMemoryBufferImpl*>(buffer) |
| 82 ->set_destruction_sync_token(sync_token); | 77 ->set_destruction_sync_token(sync_token); |
| 83 } | 78 } |
| 84 | 79 |
| 85 } // namespace content | 80 } // namespace content |
| OLD | NEW |