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/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 292 } |
293 | 293 |
294 gpu::Capabilities CommandBufferProxyImpl::GetCapabilities() { | 294 gpu::Capabilities CommandBufferProxyImpl::GetCapabilities() { |
295 return capabilities_; | 295 return capabilities_; |
296 } | 296 } |
297 | 297 |
298 gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer( | 298 gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer( |
299 size_t width, | 299 size_t width, |
300 size_t height, | 300 size_t height, |
301 unsigned internalformat, | 301 unsigned internalformat, |
| 302 unsigned usage, |
302 int32* id) { | 303 int32* id) { |
303 *id = -1; | 304 *id = -1; |
304 | 305 |
305 if (last_state_.error != gpu::error::kNoError) | 306 if (last_state_.error != gpu::error::kNoError) |
306 return NULL; | 307 return NULL; |
307 | 308 |
308 int32 new_id = channel_->ReserveGpuMemoryBufferId(); | 309 int32 new_id = channel_->ReserveGpuMemoryBufferId(); |
309 DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end()); | 310 DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end()); |
310 | 311 |
311 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer( | 312 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer( |
312 channel_->factory()->AllocateGpuMemoryBuffer(width, | 313 channel_->factory()->AllocateGpuMemoryBuffer( |
313 height, | 314 width, height, internalformat, usage)); |
314 internalformat)); | |
315 if (!gpu_memory_buffer) | 315 if (!gpu_memory_buffer) |
316 return NULL; | 316 return NULL; |
317 | 317 |
318 DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer( | 318 DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer( |
319 gpu_memory_buffer->GetHandle())); | 319 gpu_memory_buffer->GetHandle())); |
320 | 320 |
321 // This handle is owned by the GPU process and must be passed to it or it | 321 // This handle is owned by the GPU process and must be passed to it or it |
322 // will leak. In otherwords, do not early out on error between here and the | 322 // will leak. In otherwords, do not early out on error between here and the |
323 // sending of the RegisterGpuMemoryBuffer IPC below. | 323 // sending of the RegisterGpuMemoryBuffer IPC below. |
324 gfx::GpuMemoryBufferHandle handle = | 324 gfx::GpuMemoryBufferHandle handle = |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 if (last_state_.error == gpu::error::kNoError) | 512 if (last_state_.error == gpu::error::kNoError) |
513 shared_state()->Read(&last_state_); | 513 shared_state()->Read(&last_state_); |
514 } | 514 } |
515 | 515 |
516 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { | 516 gpu::CommandBufferSharedState* CommandBufferProxyImpl::shared_state() const { |
517 return reinterpret_cast<gpu::CommandBufferSharedState*>( | 517 return reinterpret_cast<gpu::CommandBufferSharedState*>( |
518 shared_state_shm_->memory()); | 518 shared_state_shm_->memory()); |
519 } | 519 } |
520 | 520 |
521 } // namespace content | 521 } // namespace content |
OLD | NEW |