| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/numerics/safe_conversions.h" |
| 18 #include "base/sequence_checker.h" | 19 #include "base/sequence_checker.h" |
| 19 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 20 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
| 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 22 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 22 #include "gpu/command_buffer/common/sync_token.h" | 23 #include "gpu/command_buffer/common/sync_token.h" |
| 23 #include "gpu/command_buffer/common/value_state.h" | 24 #include "gpu/command_buffer/common/value_state.h" |
| 24 #include "gpu/command_buffer/service/command_buffer_service.h" | 25 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 25 #include "gpu/command_buffer/service/context_group.h" | 26 #include "gpu/command_buffer/service/context_group.h" |
| 26 #include "gpu/command_buffer/service/gl_context_virtual.h" | 27 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 27 #include "gpu/command_buffer/service/gpu_scheduler.h" | 28 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 108 |
| 108 gfx::GpuMemoryBufferHandle ShareGpuMemoryBufferToGpuThread( | 109 gfx::GpuMemoryBufferHandle ShareGpuMemoryBufferToGpuThread( |
| 109 const gfx::GpuMemoryBufferHandle& source_handle, | 110 const gfx::GpuMemoryBufferHandle& source_handle, |
| 110 bool* requires_sync_point) { | 111 bool* requires_sync_point) { |
| 111 switch (source_handle.type) { | 112 switch (source_handle.type) { |
| 112 case gfx::SHARED_MEMORY_BUFFER: { | 113 case gfx::SHARED_MEMORY_BUFFER: { |
| 113 gfx::GpuMemoryBufferHandle handle; | 114 gfx::GpuMemoryBufferHandle handle; |
| 114 handle.type = gfx::SHARED_MEMORY_BUFFER; | 115 handle.type = gfx::SHARED_MEMORY_BUFFER; |
| 115 handle.handle = ShareToGpuThread(source_handle.handle); | 116 handle.handle = ShareToGpuThread(source_handle.handle); |
| 116 handle.offset = source_handle.offset; | 117 handle.offset = source_handle.offset; |
| 118 handle.stride = source_handle.stride; |
| 117 *requires_sync_point = false; | 119 *requires_sync_point = false; |
| 118 return handle; | 120 return handle; |
| 119 } | 121 } |
| 120 case gfx::IO_SURFACE_BUFFER: | 122 case gfx::IO_SURFACE_BUFFER: |
| 121 case gfx::SURFACE_TEXTURE_BUFFER: | 123 case gfx::SURFACE_TEXTURE_BUFFER: |
| 122 case gfx::OZONE_NATIVE_PIXMAP: | 124 case gfx::OZONE_NATIVE_PIXMAP: |
| 123 *requires_sync_point = true; | 125 *requires_sync_point = true; |
| 124 return source_handle; | 126 return source_handle; |
| 125 default: | 127 default: |
| 126 NOTREACHED(); | 128 NOTREACHED(); |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 | 730 |
| 729 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); | 731 gpu::gles2::ImageManager* image_manager = decoder_->GetImageManager(); |
| 730 DCHECK(image_manager); | 732 DCHECK(image_manager); |
| 731 if (image_manager->LookupImage(id)) { | 733 if (image_manager->LookupImage(id)) { |
| 732 LOG(ERROR) << "Image already exists with same ID."; | 734 LOG(ERROR) << "Image already exists with same ID."; |
| 733 return; | 735 return; |
| 734 } | 736 } |
| 735 | 737 |
| 736 switch (handle.type) { | 738 switch (handle.type) { |
| 737 case gfx::SHARED_MEMORY_BUFFER: { | 739 case gfx::SHARED_MEMORY_BUFFER: { |
| 740 if (!base::IsValueInRangeForNumericType<size_t>(handle.stride)) { |
| 741 LOG(ERROR) << "Invalid stride for image."; |
| 742 return; |
| 743 } |
| 738 scoped_refptr<gl::GLImageSharedMemory> image( | 744 scoped_refptr<gl::GLImageSharedMemory> image( |
| 739 new gl::GLImageSharedMemory(size, internalformat)); | 745 new gl::GLImageSharedMemory(size, internalformat)); |
| 740 if (!image->Initialize(handle.handle, handle.id, format, handle.offset)) { | 746 if (!image->Initialize(handle.handle, handle.id, format, handle.offset, |
| 747 handle.stride)) { |
| 741 LOG(ERROR) << "Failed to initialize image."; | 748 LOG(ERROR) << "Failed to initialize image."; |
| 742 return; | 749 return; |
| 743 } | 750 } |
| 744 | 751 |
| 745 image_manager->AddImage(image.get(), id); | 752 image_manager->AddImage(image.get(), id); |
| 746 break; | 753 break; |
| 747 } | 754 } |
| 748 default: { | 755 default: { |
| 749 if (!image_factory_) { | 756 if (!image_factory_) { |
| 750 LOG(ERROR) << "Image factory missing but required by buffer type."; | 757 LOG(ERROR) << "Image factory missing but required by buffer type."; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 framebuffer_completeness_cache_ = | 1127 framebuffer_completeness_cache_ = |
| 1121 new gpu::gles2::FramebufferCompletenessCache; | 1128 new gpu::gles2::FramebufferCompletenessCache; |
| 1122 return framebuffer_completeness_cache_; | 1129 return framebuffer_completeness_cache_; |
| 1123 } | 1130 } |
| 1124 | 1131 |
| 1125 SyncPointManager* GpuInProcessThread::sync_point_manager() { | 1132 SyncPointManager* GpuInProcessThread::sync_point_manager() { |
| 1126 return sync_point_manager_; | 1133 return sync_point_manager_; |
| 1127 } | 1134 } |
| 1128 | 1135 |
| 1129 } // namespace gpu | 1136 } // namespace gpu |
| OLD | NEW |