OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "gpu/command_buffer/service/in_process_command_buffer.h" | 5 #include "gpu/command_buffer/service/in_process_command_buffer.h" |
6 | 6 |
7 #include <queue> | 7 #include <queue> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 | 693 |
694 void InProcessCommandBuffer::DestroyTransferBufferOnGpuThread(int32 id) { | 694 void InProcessCommandBuffer::DestroyTransferBufferOnGpuThread(int32 id) { |
695 base::AutoLock lock(command_buffer_lock_); | 695 base::AutoLock lock(command_buffer_lock_); |
696 command_buffer_->DestroyTransferBuffer(id); | 696 command_buffer_->DestroyTransferBuffer(id); |
697 } | 697 } |
698 | 698 |
699 gpu::Capabilities InProcessCommandBuffer::GetCapabilities() { | 699 gpu::Capabilities InProcessCommandBuffer::GetCapabilities() { |
700 return capabilities_; | 700 return capabilities_; |
701 } | 701 } |
702 | 702 |
703 int32 InProcessCommandBuffer::CreateImage(ClientBuffer buffer, | 703 int32 InProcessCommandBuffer::CreateImage(const ClientBuffer* const buffers, |
704 size_t width, | 704 size_t width, |
705 size_t height, | 705 size_t height, |
706 unsigned internalformat) { | 706 unsigned internalformat) { |
707 CheckSequencedThread(); | 707 CheckSequencedThread(); |
708 | 708 |
709 DCHECK(gpu_memory_buffer_manager_); | 709 DCHECK(gpu_memory_buffer_manager_); |
| 710 // TODO(emircan): See http://crbug.com/439520; support passing multiple |
| 711 // buffers when new multi-planar formats are added. |
710 gfx::GpuMemoryBuffer* gpu_memory_buffer = | 712 gfx::GpuMemoryBuffer* gpu_memory_buffer = |
711 gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffer); | 713 gpu_memory_buffer_manager_->GpuMemoryBufferFromClientBuffer(buffers[0]); |
712 DCHECK(gpu_memory_buffer); | 714 DCHECK(gpu_memory_buffer); |
713 | 715 |
714 int32 new_id = next_image_id_.GetNext(); | 716 int32 new_id = next_image_id_.GetNext(); |
715 | 717 |
716 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( | 718 DCHECK(gpu::ImageFactory::IsImageFormatCompatibleWithGpuMemoryBufferFormat( |
717 internalformat, gpu_memory_buffer->GetFormat())); | 719 internalformat, gpu_memory_buffer->GetFormat())); |
718 | 720 |
719 // This handle is owned by the GPU thread and must be passed to it or it | 721 // This handle is owned by the GPU thread and must be passed to it or it |
720 // will leak. In otherwords, do not early out on error between here and the | 722 // will leak. In otherwords, do not early out on error between here and the |
721 // queuing of the CreateImage task below. | 723 // queuing of the CreateImage task below. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 | 802 |
801 DCHECK(gpu_memory_buffer_manager_); | 803 DCHECK(gpu_memory_buffer_manager_); |
802 scoped_ptr<gfx::GpuMemoryBuffer> buffer( | 804 scoped_ptr<gfx::GpuMemoryBuffer> buffer( |
803 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | 805 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( |
804 gfx::Size(width, height), | 806 gfx::Size(width, height), |
805 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat), | 807 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat), |
806 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); | 808 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); |
807 if (!buffer) | 809 if (!buffer) |
808 return -1; | 810 return -1; |
809 | 811 |
810 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | 812 const ClientBuffer& client_buffer = buffer->AsClientBuffer(); |
| 813 return CreateImage(const_cast<ClientBuffer* const>(&client_buffer), width, |
| 814 height, internalformat); |
811 } | 815 } |
812 | 816 |
813 uint32 InProcessCommandBuffer::InsertSyncPoint() { | 817 uint32 InProcessCommandBuffer::InsertSyncPoint() { |
814 uint32 sync_point = g_sync_point_manager.Get().GenerateSyncPoint(); | 818 uint32 sync_point = g_sync_point_manager.Get().GenerateSyncPoint(); |
815 QueueTask(base::Bind(&InProcessCommandBuffer::RetireSyncPointOnGpuThread, | 819 QueueTask(base::Bind(&InProcessCommandBuffer::RetireSyncPointOnGpuThread, |
816 base::Unretained(this), | 820 base::Unretained(this), |
817 sync_point)); | 821 sync_point)); |
818 return sync_point; | 822 return sync_point; |
819 } | 823 } |
820 | 824 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 | 965 |
962 #if defined(OS_ANDROID) | 966 #if defined(OS_ANDROID) |
963 scoped_refptr<gfx::SurfaceTexture> | 967 scoped_refptr<gfx::SurfaceTexture> |
964 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 968 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { |
965 DCHECK(stream_texture_manager_); | 969 DCHECK(stream_texture_manager_); |
966 return stream_texture_manager_->GetSurfaceTexture(stream_id); | 970 return stream_texture_manager_->GetSurfaceTexture(stream_id); |
967 } | 971 } |
968 #endif | 972 #endif |
969 | 973 |
970 } // namespace gpu | 974 } // namespace gpu |
OLD | NEW |