| 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/command_buffer_proxy_impl.h" | 5 #include "content/common/gpu/client/command_buffer_proxy_impl.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 | 126 |
| 127 void CommandBufferProxyImpl::SetChannelErrorCallback( | 127 void CommandBufferProxyImpl::SetChannelErrorCallback( |
| 128 const base::Closure& callback) { | 128 const base::Closure& callback) { |
| 129 channel_error_callback_ = callback; | 129 channel_error_callback_ = callback; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool CommandBufferProxyImpl::Initialize() { | 132 bool CommandBufferProxyImpl::Initialize() { |
| 133 shared_state_shm_.reset(channel_->factory()->AllocateSharedMemory( | 133 shared_state_shm_.reset(channel_->factory()->AllocateSharedMemory( |
| 134 sizeof(*shared_state())).release()); | 134 sizeof(*shared_state())).release()); |
| 135 if (!shared_state_shm_.get()) | 135 if (!shared_state_shm_) |
| 136 return false; | 136 return false; |
| 137 | 137 |
| 138 if (!shared_state_shm_->Map(sizeof(*shared_state()))) | 138 if (!shared_state_shm_->Map(sizeof(*shared_state()))) |
| 139 return false; | 139 return false; |
| 140 | 140 |
| 141 shared_state()->Initialize(); | 141 shared_state()->Initialize(); |
| 142 | 142 |
| 143 // This handle is owned by the GPU process and must be passed to it or it | 143 // This handle is owned by the GPU process and must be passed to it or it |
| 144 // will leak. In otherwords, do not early out on error between here and the | 144 // will leak. In otherwords, do not early out on error between here and the |
| 145 // sending of the Initialize IPC below. | 145 // sending of the Initialize IPC below. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 *id = -1; | 248 *id = -1; |
| 249 | 249 |
| 250 if (last_state_.error != gpu::error::kNoError) | 250 if (last_state_.error != gpu::error::kNoError) |
| 251 return gpu::Buffer(); | 251 return gpu::Buffer(); |
| 252 | 252 |
| 253 int32 new_id = channel_->ReserveTransferBufferId(); | 253 int32 new_id = channel_->ReserveTransferBufferId(); |
| 254 DCHECK(transfer_buffers_.find(new_id) == transfer_buffers_.end()); | 254 DCHECK(transfer_buffers_.find(new_id) == transfer_buffers_.end()); |
| 255 | 255 |
| 256 scoped_ptr<base::SharedMemory> shared_memory( | 256 scoped_ptr<base::SharedMemory> shared_memory( |
| 257 channel_->factory()->AllocateSharedMemory(size)); | 257 channel_->factory()->AllocateSharedMemory(size)); |
| 258 if (!shared_memory.get()) | 258 if (!shared_memory) |
| 259 return gpu::Buffer(); | 259 return gpu::Buffer(); |
| 260 | 260 |
| 261 DCHECK(!shared_memory->memory()); | 261 DCHECK(!shared_memory->memory()); |
| 262 if (!shared_memory->Map(size)) | 262 if (!shared_memory->Map(size)) |
| 263 return gpu::Buffer(); | 263 return gpu::Buffer(); |
| 264 | 264 |
| 265 // This handle is owned by the GPU process and must be passed to it or it | 265 // This handle is owned by the GPU process and must be passed to it or it |
| 266 // will leak. In otherwords, do not early out on error between here and the | 266 // will leak. In otherwords, do not early out on error between here and the |
| 267 // sending of the RegisterTransferBuffer IPC below. | 267 // sending of the RegisterTransferBuffer IPC below. |
| 268 base::SharedMemoryHandle handle = | 268 base::SharedMemoryHandle handle = |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 void CommandBufferProxyImpl::SendManagedMemoryStats( | 532 void CommandBufferProxyImpl::SendManagedMemoryStats( |
| 533 const GpuManagedMemoryStats& stats) { | 533 const GpuManagedMemoryStats& stats) { |
| 534 if (last_state_.error != gpu::error::kNoError) | 534 if (last_state_.error != gpu::error::kNoError) |
| 535 return; | 535 return; |
| 536 | 536 |
| 537 Send(new GpuCommandBufferMsg_SendClientManagedMemoryStats(route_id_, | 537 Send(new GpuCommandBufferMsg_SendClientManagedMemoryStats(route_id_, |
| 538 stats)); | 538 stats)); |
| 539 } | 539 } |
| 540 | 540 |
| 541 } // namespace content | 541 } // namespace content |
| OLD | NEW |