Chromium Code Reviews| Index: content/common/gpu/client/command_buffer_proxy_impl.cc |
| diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc |
| index 02c6760359ceab7eff22be683b287a49bb08359c..f589010226e533f831bb150fabd6610d8062a2f0 100644 |
| --- a/content/common/gpu/client/command_buffer_proxy_impl.cc |
| +++ b/content/common/gpu/client/command_buffer_proxy_impl.cc |
| @@ -307,24 +307,22 @@ gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer( |
| if (last_state_.error != gpu::error::kNoError) |
| return NULL; |
| - int32 new_id = channel_->ReserveGpuMemoryBufferId(); |
| - DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end()); |
| - |
| - scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer( |
| + scoped_ptr<gfx::GpuMemoryBuffer> buffer( |
| channel_->factory()->AllocateGpuMemoryBuffer( |
| width, height, internalformat, usage)); |
| - if (!gpu_memory_buffer) |
| + if (!buffer) |
| return NULL; |
| - DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer( |
| - gpu_memory_buffer->GetHandle())); |
| + DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer(buffer->GetHandle())); |
| + |
| + int32 new_id = channel_->ReserveGpuMemoryBufferId(); |
| + DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end()); |
| // This handle is owned by the GPU process and must be passed to it or it |
| // will leak. In otherwords, do not early out on error between here and the |
| // sending of the RegisterGpuMemoryBuffer IPC below. |
| gfx::GpuMemoryBufferHandle handle = |
| - channel_->ShareGpuMemoryBufferToGpuProcess( |
| - gpu_memory_buffer->GetHandle()); |
| + channel_->ShareGpuMemoryBufferToGpuProcess(buffer->GetHandle()); |
| if (!Send(new GpuCommandBufferMsg_RegisterGpuMemoryBuffer( |
| route_id_, |
| @@ -337,22 +335,18 @@ gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer( |
| } |
| *id = new_id; |
| - gpu_memory_buffers_[new_id] = gpu_memory_buffer.release(); |
| - return gpu_memory_buffers_[new_id]; |
| + gpu_memory_buffers_.add(new_id, buffer.Pass()); |
| + return gpu_memory_buffers_.get(new_id); |
|
no sievers
2014/07/11 18:33:29
nit: can avoid the lookup here
reveman
2014/07/11 21:08:06
Done.
|
| } |
| void CommandBufferProxyImpl::DestroyGpuMemoryBuffer(int32 id) { |
| if (last_state_.error != gpu::error::kNoError) |
| return; |
| - // Remove the gpu memory buffer from the client side cache. |
| - GpuMemoryBufferMap::iterator it = gpu_memory_buffers_.find(id); |
| - if (it != gpu_memory_buffers_.end()) { |
| - delete it->second; |
| - gpu_memory_buffers_.erase(it); |
| - } |
| - |
| Send(new GpuCommandBufferMsg_DestroyGpuMemoryBuffer(route_id_, id)); |
| + |
| + // Remove the gpu memory buffer from the client side cache. |
| + gpu_memory_buffers_.erase(id); |
| } |
| int CommandBufferProxyImpl::GetRouteID() const { |