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/gpu_channel.h" | 5 #include "content/common/gpu/gpu_channel.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <deque> | 12 #include <deque> |
13 #include <set> | 13 #include <set> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/atomicops.h" | 16 #include "base/atomicops.h" |
17 #include "base/bind.h" | 17 #include "base/bind.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/location.h" | 19 #include "base/location.h" |
20 #include "base/numerics/safe_conversions.h" | |
21 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
22 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
23 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
24 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
25 #include "base/thread_task_runner_handle.h" | 24 #include "base/thread_task_runner_handle.h" |
26 #include "base/timer/timer.h" | 25 #include "base/timer/timer.h" |
27 #include "base/trace_event/memory_dump_manager.h" | 26 #include "base/trace_event/memory_dump_manager.h" |
28 #include "base/trace_event/process_memory_dump.h" | 27 #include "base/trace_event/process_memory_dump.h" |
29 #include "base/trace_event/trace_event.h" | 28 #include "base/trace_event/trace_event.h" |
30 #include "content/common/gpu/gpu_channel_manager.h" | 29 #include "content/common/gpu/gpu_channel_manager.h" |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 return size; | 1033 return size; |
1035 } | 1034 } |
1036 | 1035 |
1037 scoped_refptr<gl::GLImage> GpuChannel::CreateImageForGpuMemoryBuffer( | 1036 scoped_refptr<gl::GLImage> GpuChannel::CreateImageForGpuMemoryBuffer( |
1038 const gfx::GpuMemoryBufferHandle& handle, | 1037 const gfx::GpuMemoryBufferHandle& handle, |
1039 const gfx::Size& size, | 1038 const gfx::Size& size, |
1040 gfx::BufferFormat format, | 1039 gfx::BufferFormat format, |
1041 uint32 internalformat) { | 1040 uint32 internalformat) { |
1042 switch (handle.type) { | 1041 switch (handle.type) { |
1043 case gfx::SHARED_MEMORY_BUFFER: { | 1042 case gfx::SHARED_MEMORY_BUFFER: { |
1044 if (!base::IsValueInRangeForNumericType<size_t>(handle.stride)) | |
1045 return nullptr; | |
1046 scoped_refptr<gl::GLImageSharedMemory> image( | 1043 scoped_refptr<gl::GLImageSharedMemory> image( |
1047 new gl::GLImageSharedMemory(size, internalformat)); | 1044 new gl::GLImageSharedMemory(size, internalformat)); |
1048 if (!image->Initialize(handle.handle, handle.id, format, handle.offset, | 1045 if (!image->Initialize(handle.handle, handle.id, format, handle.offset)) |
1049 handle.stride)) { | |
1050 return nullptr; | 1046 return nullptr; |
1051 } | |
1052 | 1047 |
1053 return image; | 1048 return image; |
1054 } | 1049 } |
1055 default: { | 1050 default: { |
1056 GpuChannelManager* manager = gpu_channel_manager(); | 1051 GpuChannelManager* manager = gpu_channel_manager(); |
1057 if (!manager->gpu_memory_buffer_factory()) | 1052 if (!manager->gpu_memory_buffer_factory()) |
1058 return nullptr; | 1053 return nullptr; |
1059 | 1054 |
1060 return manager->gpu_memory_buffer_factory() | 1055 return manager->gpu_memory_buffer_factory() |
1061 ->AsImageFactory() | 1056 ->AsImageFactory() |
1062 ->CreateImageForGpuMemoryBuffer(handle, | 1057 ->CreateImageForGpuMemoryBuffer(handle, |
1063 size, | 1058 size, |
1064 format, | 1059 format, |
1065 internalformat, | 1060 internalformat, |
1066 client_id_); | 1061 client_id_); |
1067 } | 1062 } |
1068 } | 1063 } |
1069 } | 1064 } |
1070 | 1065 |
1071 void GpuChannel::HandleUpdateValueState( | 1066 void GpuChannel::HandleUpdateValueState( |
1072 unsigned int target, const gpu::ValueState& state) { | 1067 unsigned int target, const gpu::ValueState& state) { |
1073 pending_valuebuffer_state_->UpdateState(target, state); | 1068 pending_valuebuffer_state_->UpdateState(target, state); |
1074 } | 1069 } |
1075 | 1070 |
1076 } // namespace content | 1071 } // namespace content |
OLD | NEW |