| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer, | 302 int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer, |
| 303 size_t width, | 303 size_t width, |
| 304 size_t height, | 304 size_t height, |
| 305 unsigned internalformat) { | 305 unsigned internalformat) { |
| 306 if (last_state_.error != gpu::error::kNoError) | 306 if (last_state_.error != gpu::error::kNoError) |
| 307 return -1; | 307 return -1; |
| 308 | 308 |
| 309 int32 new_id = channel_->ReserveImageId(); | 309 int32 new_id = channel_->ReserveImageId(); |
| 310 | 310 |
| 311 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
| 312 channel_->gpu_memory_buffer_manager(); |
| 311 gfx::GpuMemoryBuffer* gpu_memory_buffer = | 313 gfx::GpuMemoryBuffer* gpu_memory_buffer = |
| 312 channel_->gpu_memory_buffer_manager()->GpuMemoryBufferFromClientBuffer( | 314 gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffer); |
| 313 buffer); | |
| 314 DCHECK(gpu_memory_buffer); | 315 DCHECK(gpu_memory_buffer); |
| 315 | 316 |
| 316 // This handle is owned by the GPU process and must be passed to it or it | 317 // This handle is owned by the GPU process and must be passed to it or it |
| 317 // will leak. In otherwords, do not early out on error between here and the | 318 // will leak. In otherwords, do not early out on error between here and the |
| 318 // sending of the CreateImage IPC below. | 319 // sending of the CreateImage IPC below. |
| 320 bool requires_sync_point = false; |
| 319 gfx::GpuMemoryBufferHandle handle = | 321 gfx::GpuMemoryBufferHandle handle = |
| 320 channel_->ShareGpuMemoryBufferToGpuProcess( | 322 channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(), |
| 321 gpu_memory_buffer->GetHandle()); | 323 &requires_sync_point); |
| 322 | 324 |
| 323 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 325 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
| 324 internalformat, gpu_memory_buffer->GetFormat())); | 326 internalformat, gpu_memory_buffer->GetFormat())); |
| 325 if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, | 327 if (!Send(new GpuCommandBufferMsg_CreateImage(route_id_, |
| 326 new_id, | 328 new_id, |
| 327 handle, | 329 handle, |
| 328 gfx::Size(width, height), | 330 gfx::Size(width, height), |
| 329 gpu_memory_buffer->GetFormat(), | 331 gpu_memory_buffer->GetFormat(), |
| 330 internalformat))) { | 332 internalformat))) { |
| 331 return -1; | 333 return -1; |
| 332 } | 334 } |
| 333 | 335 |
| 336 if (requires_sync_point) { |
| 337 gpu_memory_buffer_manager->SetDestructionSyncPoint(gpu_memory_buffer, |
| 338 InsertSyncPoint()); |
| 339 } |
| 340 |
| 334 return new_id; | 341 return new_id; |
| 335 } | 342 } |
| 336 | 343 |
| 337 void CommandBufferProxyImpl::DestroyImage(int32 id) { | 344 void CommandBufferProxyImpl::DestroyImage(int32 id) { |
| 338 if (last_state_.error != gpu::error::kNoError) | 345 if (last_state_.error != gpu::error::kNoError) |
| 339 return; | 346 return; |
| 340 | 347 |
| 341 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); | 348 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); |
| 342 } | 349 } |
| 343 | 350 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 if (!ui::LatencyInfo::Verify( | 532 if (!ui::LatencyInfo::Verify( |
| 526 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) { | 533 latency_info, "CommandBufferProxyImpl::OnSwapBuffersCompleted")) { |
| 527 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>()); | 534 swap_buffers_completion_callback_.Run(std::vector<ui::LatencyInfo>()); |
| 528 return; | 535 return; |
| 529 } | 536 } |
| 530 swap_buffers_completion_callback_.Run(latency_info); | 537 swap_buffers_completion_callback_.Run(latency_info); |
| 531 } | 538 } |
| 532 } | 539 } |
| 533 | 540 |
| 534 } // namespace content | 541 } // namespace content |
| OLD | NEW |