| 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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "content/common/gpu/gpu_channel.h" | 9 #include "content/common/gpu/gpu_channel.h" |
| 10 | 10 |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 | 820 |
| 821 uint64 GpuChannel::GetMemoryUsage() { | 821 uint64 GpuChannel::GetMemoryUsage() { |
| 822 uint64 size = 0; | 822 uint64 size = 0; |
| 823 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); | 823 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); |
| 824 !it.IsAtEnd(); it.Advance()) { | 824 !it.IsAtEnd(); it.Advance()) { |
| 825 size += it.GetCurrentValue()->GetMemoryUsage(); | 825 size += it.GetCurrentValue()->GetMemoryUsage(); |
| 826 } | 826 } |
| 827 return size; | 827 return size; |
| 828 } | 828 } |
| 829 | 829 |
| 830 scoped_refptr<gfx::GLImage> GpuChannel::CreateImageForGpuMemoryBuffer( | 830 scoped_refptr<gfx::GLImage> GpuChannel::CreateImageForGpuMemoryBuffers( |
| 831 const gfx::GpuMemoryBufferHandle& handle, | 831 const std::vector<gfx::GpuMemoryBufferHandle>& handles, |
| 832 const gfx::Size& size, | 832 const gfx::Size& size, |
| 833 gfx::GpuMemoryBuffer::Format format, | 833 const std::vector<gfx::GpuMemoryBuffer::Format>& formats, |
| 834 uint32 internalformat) { | 834 uint32 internalformat) { |
| 835 switch (handle.type) { | 835 size_t num_buffers = |
| 836 gpu::ImageFactory::NumberOfPlanesForImageFormat(internalformat); |
| 837 |
| 838 // Make sure that the gives vectors have the correct size. |
| 839 DCHECK_EQ(handles.size(), num_buffers); |
| 840 DCHECK_EQ(formats.size(), num_buffers); |
| 841 |
| 842 // Check if all the handle types are equal, and if they aren't, return an |
| 843 // empty image. |
| 844 gfx::GpuMemoryBufferType handle_type = handles[0].type; |
| 845 for (size_t i = 1; i < num_buffers; ++i) { |
| 846 if (handles[i].type != handle_type) |
| 847 return scoped_refptr<gfx::GLImage>(); |
| 848 } |
| 849 |
| 850 switch (handle_type) { |
| 836 case gfx::SHARED_MEMORY_BUFFER: { | 851 case gfx::SHARED_MEMORY_BUFFER: { |
| 852 if (num_buffers != 1) { |
| 853 DLOG(ERROR) |
| 854 << "SHARED_MEMORY_BUFFER doesn't support multi-plane formats."; |
| 855 return scoped_refptr<gfx::GLImage>(); |
| 856 } |
| 857 |
| 837 scoped_refptr<gfx::GLImageSharedMemory> image( | 858 scoped_refptr<gfx::GLImageSharedMemory> image( |
| 838 new gfx::GLImageSharedMemory(size, internalformat)); | 859 new gfx::GLImageSharedMemory(size, internalformat)); |
| 839 if (!image->Initialize(handle, format)) | 860 if (!image->Initialize(handles[0], formats[0])) |
| 840 return scoped_refptr<gfx::GLImage>(); | 861 return scoped_refptr<gfx::GLImage>(); |
| 841 | |
| 842 return image; | 862 return image; |
| 843 } | 863 } |
| 844 default: { | 864 default: { |
| 845 GpuChannelManager* manager = gpu_channel_manager(); | 865 GpuChannelManager* manager = gpu_channel_manager(); |
| 846 if (!manager->gpu_memory_buffer_factory()) | 866 if (!manager->gpu_memory_buffer_factory()) |
| 847 return scoped_refptr<gfx::GLImage>(); | 867 return scoped_refptr<gfx::GLImage>(); |
| 848 | 868 |
| 849 return manager->gpu_memory_buffer_factory() | 869 return manager->gpu_memory_buffer_factory() |
| 850 ->AsImageFactory() | 870 ->AsImageFactory() |
| 851 ->CreateImageForGpuMemoryBuffer(handle, | 871 ->CreateImageForGpuMemoryBuffers(handles, size, formats, |
| 852 size, | 872 internalformat, client_id_); |
| 853 format, | |
| 854 internalformat, | |
| 855 client_id_); | |
| 856 } | 873 } |
| 857 } | 874 } |
| 858 } | 875 } |
| 859 | 876 |
| 860 void GpuChannel::HandleUpdateValueState( | 877 void GpuChannel::HandleUpdateValueState( |
| 861 unsigned int target, const gpu::ValueState& state) { | 878 unsigned int target, const gpu::ValueState& state) { |
| 862 pending_valuebuffer_state_->UpdateState(target, state); | 879 pending_valuebuffer_state_->UpdateState(target, state); |
| 863 } | 880 } |
| 864 | 881 |
| 865 } // namespace content | 882 } // namespace content |
| OLD | NEW |