Chromium Code Reviews| 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 if (last_state_.error != gpu::error::kNoError) | 340 if (last_state_.error != gpu::error::kNoError) |
| 341 return; | 341 return; |
| 342 | 342 |
| 343 Send(new GpuCommandBufferMsg_DestroyTransferBuffer(route_id_, id)); | 343 Send(new GpuCommandBufferMsg_DestroyTransferBuffer(route_id_, id)); |
| 344 } | 344 } |
| 345 | 345 |
| 346 gpu::Capabilities CommandBufferProxyImpl::GetCapabilities() { | 346 gpu::Capabilities CommandBufferProxyImpl::GetCapabilities() { |
| 347 return capabilities_; | 347 return capabilities_; |
| 348 } | 348 } |
| 349 | 349 |
| 350 int32_t CommandBufferProxyImpl::CreateImage(ClientBuffer buffer, | 350 int32_t CommandBufferProxyImpl::CreateImage(const ClientBuffer* const buffers, |
| 351 size_t width, | 351 size_t width, |
| 352 size_t height, | 352 size_t height, |
| 353 unsigned internalformat) { | 353 unsigned internalformat) { |
| 354 CheckLock(); | 354 CheckLock(); |
| 355 if (last_state_.error != gpu::error::kNoError) | 355 if (last_state_.error != gpu::error::kNoError) |
| 356 return -1; | 356 return -1; |
| 357 | 357 |
| 358 int32 new_id = channel_->ReserveImageId(); | 358 int32 new_id = channel_->ReserveImageId(); |
| 359 | 359 |
| 360 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = | 360 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
| 361 channel_->gpu_memory_buffer_manager(); | 361 channel_->gpu_memory_buffer_manager(); |
| 362 // TODO(emircan): See http://crbug.com/439520; support passing multiple | |
| 363 // buffers when new multi-planar formats are added. | |
| 362 gfx::GpuMemoryBuffer* gpu_memory_buffer = | 364 gfx::GpuMemoryBuffer* gpu_memory_buffer = |
|
reveman
2015/03/03 05:30:13
Please don't stop here. Go as far as you need to f
emircan
2015/03/04 03:03:16
Sure, I was just trying to keep CL smaller.
I add
| |
| 363 gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffer); | 365 gpu_memory_buffer_manager->GpuMemoryBufferFromClientBuffer(buffers[0]); |
| 364 DCHECK(gpu_memory_buffer); | 366 DCHECK(gpu_memory_buffer); |
| 365 | 367 |
| 366 // This handle is owned by the GPU process and must be passed to it or it | 368 // This handle is owned by the GPU process and must be passed to it or it |
| 367 // will leak. In otherwords, do not early out on error between here and the | 369 // will leak. In otherwords, do not early out on error between here and the |
| 368 // sending of the CreateImage IPC below. | 370 // sending of the CreateImage IPC below. |
| 369 bool requires_sync_point = false; | 371 bool requires_sync_point = false; |
| 370 gfx::GpuMemoryBufferHandle handle = | 372 gfx::GpuMemoryBufferHandle handle = |
| 371 channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(), | 373 channel_->ShareGpuMemoryBufferToGpuProcess(gpu_memory_buffer->GetHandle(), |
| 372 &requires_sync_point); | 374 &requires_sync_point); |
| 373 | 375 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 391 } | 393 } |
| 392 | 394 |
| 393 void CommandBufferProxyImpl::DestroyImage(int32 id) { | 395 void CommandBufferProxyImpl::DestroyImage(int32 id) { |
| 394 CheckLock(); | 396 CheckLock(); |
| 395 if (last_state_.error != gpu::error::kNoError) | 397 if (last_state_.error != gpu::error::kNoError) |
| 396 return; | 398 return; |
| 397 | 399 |
| 398 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); | 400 Send(new GpuCommandBufferMsg_DestroyImage(route_id_, id)); |
| 399 } | 401 } |
| 400 | 402 |
| 401 int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( | 403 int32_t CommandBufferProxyImpl::CreateGpuMemoryBufferImage( |
|
reveman
2015/03/03 05:30:13
hm, how do we handle support for multi-plane forma
emircan
2015/03/04 03:03:16
Agreed. In addition to the number of buffers, we n
reveman
2015/03/04 05:55:59
How about
static gfx::GpuMemoryBuffer::Format Imag
emircan
2015/03/04 23:31:50
In case of GL_RGB_YUV420, I thought we want to ret
reveman
2015/03/05 19:35:31
The idea is that it would be the format of |buffer
emircan
2015/03/09 21:07:22
I now understand your suggestion, sorry for the co
reveman
2015/03/10 04:27:20
Multi buffer formats would need a different intern
emircan
2015/03/11 18:36:35
Sure. The current function should be sufficient th
| |
| 402 size_t width, | 404 size_t width, |
| 403 size_t height, | 405 size_t height, |
| 404 unsigned internalformat, | 406 unsigned internalformat, |
| 405 unsigned usage) { | 407 unsigned usage) { |
| 406 CheckLock(); | 408 CheckLock(); |
| 407 scoped_ptr<gfx::GpuMemoryBuffer> buffer( | 409 scoped_ptr<gfx::GpuMemoryBuffer> buffer( |
| 408 channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( | 410 channel_->gpu_memory_buffer_manager()->AllocateGpuMemoryBuffer( |
| 409 gfx::Size(width, height), | 411 gfx::Size(width, height), |
| 410 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat), | 412 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat), |
| 411 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); | 413 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); |
| 412 if (!buffer) | 414 if (!buffer) |
| 413 return -1; | 415 return -1; |
| 414 | 416 |
| 415 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | 417 const ClientBuffer& client_buffer = buffer->AsClientBuffer(); |
| 418 return CreateImage(const_cast<const ClientBuffer* const>(&client_buffer), | |
| 419 width, height, internalformat); | |
| 416 } | 420 } |
| 417 | 421 |
| 418 int CommandBufferProxyImpl::GetRouteID() const { | 422 int CommandBufferProxyImpl::GetRouteID() const { |
| 419 return route_id_; | 423 return route_id_; |
| 420 } | 424 } |
| 421 | 425 |
| 422 uint32 CommandBufferProxyImpl::CreateStreamTexture(uint32 texture_id) { | 426 uint32 CommandBufferProxyImpl::CreateStreamTexture(uint32 texture_id) { |
| 423 CheckLock(); | 427 CheckLock(); |
| 424 if (last_state_.error != gpu::error::kNoError) | 428 if (last_state_.error != gpu::error::kNoError) |
| 425 return 0; | 429 return 0; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 } | 606 } |
| 603 } | 607 } |
| 604 | 608 |
| 605 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, | 609 void CommandBufferProxyImpl::OnUpdateVSyncParameters(base::TimeTicks timebase, |
| 606 base::TimeDelta interval) { | 610 base::TimeDelta interval) { |
| 607 if (!update_vsync_parameters_completion_callback_.is_null()) | 611 if (!update_vsync_parameters_completion_callback_.is_null()) |
| 608 update_vsync_parameters_completion_callback_.Run(timebase, interval); | 612 update_vsync_parameters_completion_callback_.Run(timebase, interval); |
| 609 } | 613 } |
| 610 | 614 |
| 611 } // namespace content | 615 } // namespace content |
| OLD | NEW |