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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
49 #include <windows.h> | 49 #include <windows.h> |
50 #include "base/process/process_handle.h" | 50 #include "base/process/process_handle.h" |
51 #endif | 51 #endif |
52 | 52 |
53 namespace gpu { | 53 namespace gpu { |
54 | 54 |
55 namespace { | 55 namespace { |
56 | 56 |
| 57 base::StaticAtomicSequenceNumber g_next_command_buffer_id; |
| 58 |
57 template <typename T> | 59 template <typename T> |
58 static void RunTaskWithResult(base::Callback<T(void)> task, | 60 static void RunTaskWithResult(base::Callback<T(void)> task, |
59 T* result, | 61 T* result, |
60 base::WaitableEvent* completion) { | 62 base::WaitableEvent* completion) { |
61 *result = task.Run(); | 63 *result = task.Run(); |
62 completion->Signal(); | 64 completion->Signal(); |
63 } | 65 } |
64 | 66 |
65 struct GpuInProcessThreadHolder { | 67 struct GpuInProcessThreadHolder { |
66 GpuInProcessThreadHolder() | 68 GpuInProcessThreadHolder() |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && | 169 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && |
168 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 170 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
169 switches::kDisableGpuProgramCache)) { | 171 switches::kDisableGpuProgramCache)) { |
170 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); | 172 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); |
171 } | 173 } |
172 return program_cache_.get(); | 174 return program_cache_.get(); |
173 } | 175 } |
174 | 176 |
175 InProcessCommandBuffer::InProcessCommandBuffer( | 177 InProcessCommandBuffer::InProcessCommandBuffer( |
176 const scoped_refptr<Service>& service) | 178 const scoped_refptr<Service>& service) |
177 : context_lost_(false), | 179 : CommandBuffer(kCommandBufferNamespace_InProcess, |
| 180 g_next_command_buffer_id.GetNext()), |
| 181 context_lost_(false), |
178 idle_work_pending_(false), | 182 idle_work_pending_(false), |
179 image_factory_(nullptr), | 183 image_factory_(nullptr), |
180 last_put_offset_(-1), | 184 last_put_offset_(-1), |
181 gpu_memory_buffer_manager_(nullptr), | 185 gpu_memory_buffer_manager_(nullptr), |
182 flush_event_(false, false), | 186 flush_event_(false, false), |
183 service_(GetInitialService(service)), | 187 service_(GetInitialService(service)), |
184 gpu_thread_weak_ptr_factory_(this) { | 188 gpu_thread_weak_ptr_factory_(this) { |
185 DCHECK(service_.get()); | 189 DCHECK(service_.get()); |
186 next_image_id_.GetNext(); | 190 next_image_id_.GetNext(); |
187 } | 191 } |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 CheckSequencedThread(); | 286 CheckSequencedThread(); |
283 gpu_thread_weak_ptr_ = gpu_thread_weak_ptr_factory_.GetWeakPtr(); | 287 gpu_thread_weak_ptr_ = gpu_thread_weak_ptr_factory_.GetWeakPtr(); |
284 | 288 |
285 DCHECK(params.size.width() >= 0 && params.size.height() >= 0); | 289 DCHECK(params.size.width() >= 0 && params.size.height() >= 0); |
286 | 290 |
287 TransferBufferManager* manager = new TransferBufferManager(nullptr); | 291 TransferBufferManager* manager = new TransferBufferManager(nullptr); |
288 transfer_buffer_manager_ = manager; | 292 transfer_buffer_manager_ = manager; |
289 manager->Initialize(); | 293 manager->Initialize(); |
290 | 294 |
291 scoped_ptr<CommandBufferService> command_buffer( | 295 scoped_ptr<CommandBufferService> command_buffer( |
292 new CommandBufferService(transfer_buffer_manager_.get())); | 296 new CommandBufferService(transfer_buffer_manager_.get(), |
| 297 namespace_id(), |
| 298 command_buffer_id())); |
293 command_buffer->SetPutOffsetChangeCallback(base::Bind( | 299 command_buffer->SetPutOffsetChangeCallback(base::Bind( |
294 &InProcessCommandBuffer::PumpCommands, gpu_thread_weak_ptr_)); | 300 &InProcessCommandBuffer::PumpCommands, gpu_thread_weak_ptr_)); |
295 command_buffer->SetParseErrorCallback(base::Bind( | 301 command_buffer->SetParseErrorCallback(base::Bind( |
296 &InProcessCommandBuffer::OnContextLost, gpu_thread_weak_ptr_)); | 302 &InProcessCommandBuffer::OnContextLost, gpu_thread_weak_ptr_)); |
297 | 303 |
298 if (!command_buffer->Initialize()) { | 304 if (!command_buffer->Initialize()) { |
299 LOG(ERROR) << "Could not initialize command buffer."; | 305 LOG(ERROR) << "Could not initialize command buffer."; |
300 DestroyOnGpuThread(); | 306 DestroyOnGpuThread(); |
301 return false; | 307 return false; |
302 } | 308 } |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 framebuffer_completeness_cache_ = | 958 framebuffer_completeness_cache_ = |
953 new gpu::gles2::FramebufferCompletenessCache; | 959 new gpu::gles2::FramebufferCompletenessCache; |
954 return framebuffer_completeness_cache_; | 960 return framebuffer_completeness_cache_; |
955 } | 961 } |
956 | 962 |
957 SyncPointManager* GpuInProcessThread::sync_point_manager() { | 963 SyncPointManager* GpuInProcessThread::sync_point_manager() { |
958 return sync_point_manager_; | 964 return sync_point_manager_; |
959 } | 965 } |
960 | 966 |
961 } // namespace gpu | 967 } // namespace gpu |
OLD | NEW |