Chromium Code Reviews| 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(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. | |
|
reveman
2015/03/04 05:56:00
keep going.. :)
emircan
2015/03/04 23:31:50
I went ahead and modified the ImageFactory::Create
| |
| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 791 image_manager->RemoveImage(id); | 793 image_manager->RemoveImage(id); |
| 792 } | 794 } |
| 793 | 795 |
| 794 int32 InProcessCommandBuffer::CreateGpuMemoryBufferImage( | 796 int32 InProcessCommandBuffer::CreateGpuMemoryBufferImage( |
| 795 size_t width, | 797 size_t width, |
| 796 size_t height, | 798 size_t height, |
| 797 unsigned internalformat, | 799 unsigned internalformat, |
| 798 unsigned usage) { | 800 unsigned usage) { |
| 799 CheckSequencedThread(); | 801 CheckSequencedThread(); |
| 800 | 802 |
| 803 std::vector<gfx::GpuMemoryBuffer::Format> gpu_memory_buffer_formats; | |
| 804 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormats( | |
| 805 internalformat, &gpu_memory_buffer_formats); | |
| 806 int num_buffers = gpu_memory_buffer_formats.size(); | |
| 807 | |
| 808 DCHECK_GE(num_buffers, 1); | |
| 801 DCHECK(gpu_memory_buffer_manager_); | 809 DCHECK(gpu_memory_buffer_manager_); |
| 802 scoped_ptr<gfx::GpuMemoryBuffer> buffer( | |
| 803 gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | |
| 804 gfx::Size(width, height), | |
| 805 gpu::ImageFactory::ImageFormatToGpuMemoryBufferFormat(internalformat), | |
| 806 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); | |
| 807 if (!buffer) | |
| 808 return -1; | |
| 809 | 810 |
| 810 return CreateImage(buffer->AsClientBuffer(), width, height, internalformat); | 811 ScopedVector<gfx::GpuMemoryBuffer> buffers; |
| 812 ClientBuffer client_buffers[num_buffers]; | |
| 813 for (int i = 0; i < num_buffers; ++i) { | |
| 814 buffers.push_back(gpu_memory_buffer_manager_->AllocateGpuMemoryBuffer( | |
| 815 gfx::Size(width, height), gpu_memory_buffer_formats[i], | |
| 816 gpu::ImageFactory::ImageUsageToGpuMemoryBufferUsage(usage))); | |
| 817 | |
| 818 if (!buffers[i]) | |
| 819 return -1; | |
| 820 | |
| 821 client_buffers[i] = buffers[i]->AsClientBuffer(); | |
| 822 } | |
| 823 return CreateImage(client_buffers, width, height, internalformat); | |
| 811 } | 824 } |
| 812 | 825 |
| 813 uint32 InProcessCommandBuffer::InsertSyncPoint() { | 826 uint32 InProcessCommandBuffer::InsertSyncPoint() { |
| 814 uint32 sync_point = g_sync_point_manager.Get().GenerateSyncPoint(); | 827 uint32 sync_point = g_sync_point_manager.Get().GenerateSyncPoint(); |
| 815 QueueTask(base::Bind(&InProcessCommandBuffer::RetireSyncPointOnGpuThread, | 828 QueueTask(base::Bind(&InProcessCommandBuffer::RetireSyncPointOnGpuThread, |
| 816 base::Unretained(this), | 829 base::Unretained(this), |
| 817 sync_point)); | 830 sync_point)); |
| 818 return sync_point; | 831 return sync_point; |
| 819 } | 832 } |
| 820 | 833 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 961 | 974 |
| 962 #if defined(OS_ANDROID) | 975 #if defined(OS_ANDROID) |
| 963 scoped_refptr<gfx::SurfaceTexture> | 976 scoped_refptr<gfx::SurfaceTexture> |
| 964 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { | 977 InProcessCommandBuffer::GetSurfaceTexture(uint32 stream_id) { |
| 965 DCHECK(stream_texture_manager_); | 978 DCHECK(stream_texture_manager_); |
| 966 return stream_texture_manager_->GetSurfaceTexture(stream_id); | 979 return stream_texture_manager_->GetSurfaceTexture(stream_id); |
| 967 } | 980 } |
| 968 #endif | 981 #endif |
| 969 | 982 |
| 970 } // namespace gpu | 983 } // namespace gpu |
| OLD | NEW |