| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/common/gpu/client/context_provider_command_buffer.h" | 5 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <utility> | 11 #include <utility> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/thread_task_runner_handle.h" |
| 17 #include "cc/output/managed_memory_policy.h" | 18 #include "cc/output/managed_memory_policy.h" |
| 18 #include "content/common/gpu/client/command_buffer_metrics.h" | 19 #include "content/common/gpu/client/command_buffer_metrics.h" |
| 19 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 20 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 20 #include "gpu/command_buffer/client/gles2_implementation.h" | 21 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 21 #include "gpu/command_buffer/client/gles2_trace_implementation.h" | 22 #include "gpu/command_buffer/client/gles2_trace_implementation.h" |
| 22 #include "gpu/command_buffer/client/gpu_switches.h" | 23 #include "gpu/command_buffer/client/gpu_switches.h" |
| 23 #include "gpu/command_buffer/client/transfer_buffer.h" | 24 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 24 #include "gpu/command_buffer/common/constants.h" | 25 #include "gpu/command_buffer/common/constants.h" |
| 25 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 26 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 26 #include "gpu/ipc/client/gpu_channel_host.h" | 27 #include "gpu/ipc/client/gpu_channel_host.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 share_group = shared_context_provider->gles2_impl_->share_group(); | 139 share_group = shared_context_provider->gles2_impl_->share_group(); |
| 139 DCHECK_EQ(!!shared_command_buffer, !!share_group); | 140 DCHECK_EQ(!!shared_command_buffer, !!share_group); |
| 140 } | 141 } |
| 141 | 142 |
| 142 DCHECK(attributes_.buffer_preserved); | 143 DCHECK(attributes_.buffer_preserved); |
| 143 std::vector<int32_t> serialized_attributes; | 144 std::vector<int32_t> serialized_attributes; |
| 144 attributes_.Serialize(&serialized_attributes); | 145 attributes_.Serialize(&serialized_attributes); |
| 145 | 146 |
| 146 // This command buffer is a client-side proxy to the command buffer in the | 147 // This command buffer is a client-side proxy to the command buffer in the |
| 147 // GPU process. | 148 // GPU process. |
| 149 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 150 default_task_runner_; |
| 151 if (!task_runner) |
| 152 task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 148 command_buffer_ = channel_->CreateCommandBuffer( | 153 command_buffer_ = channel_->CreateCommandBuffer( |
| 149 surface_handle_, gfx::Size(), shared_command_buffer, stream_id_, | 154 surface_handle_, gfx::Size(), shared_command_buffer, stream_id_, |
| 150 stream_priority_, serialized_attributes, active_url_, gpu_preference_); | 155 stream_priority_, serialized_attributes, active_url_, gpu_preference_, |
| 156 std::move(task_runner)); |
| 151 // The command buffer takes ownership of the |channel_|, so no need to keep | 157 // The command buffer takes ownership of the |channel_|, so no need to keep |
| 152 // a reference around here. | 158 // a reference around here. |
| 153 channel_ = nullptr; | 159 channel_ = nullptr; |
| 154 if (!command_buffer_) { | 160 if (!command_buffer_) { |
| 155 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; | 161 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; |
| 156 command_buffer_metrics::UmaRecordContextInitFailed(context_type_); | 162 command_buffer_metrics::UmaRecordContextInitFailed(context_type_); |
| 157 return false; | 163 return false; |
| 158 } | 164 } |
| 159 | 165 |
| 160 // The GLES2 helper writes the command buffer protocol. | 166 // The GLES2 helper writes the command buffer protocol. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 gr_context_->ResetContext(state); | 282 gr_context_->ResetContext(state); |
| 277 } | 283 } |
| 278 } | 284 } |
| 279 | 285 |
| 280 void ContextProviderCommandBuffer::SetupLock() { | 286 void ContextProviderCommandBuffer::SetupLock() { |
| 281 DCHECK(bind_succeeded_); | 287 DCHECK(bind_succeeded_); |
| 282 DCHECK(context_thread_checker_.CalledOnValidThread()); | 288 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 283 command_buffer_->SetLock(&context_lock_); | 289 command_buffer_->SetLock(&context_lock_); |
| 284 } | 290 } |
| 285 | 291 |
| 292 void ContextProviderCommandBuffer::SetDefaultTaskRunner( |
| 293 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner) { |
| 294 DCHECK(!bind_succeeded_); |
| 295 default_task_runner_ = std::move(default_task_runner); |
| 296 } |
| 297 |
| 286 base::Lock* ContextProviderCommandBuffer::GetLock() { | 298 base::Lock* ContextProviderCommandBuffer::GetLock() { |
| 287 return &context_lock_; | 299 return &context_lock_; |
| 288 } | 300 } |
| 289 | 301 |
| 290 gpu::Capabilities ContextProviderCommandBuffer::ContextCapabilities() { | 302 gpu::Capabilities ContextProviderCommandBuffer::ContextCapabilities() { |
| 291 DCHECK(bind_succeeded_); | 303 DCHECK(bind_succeeded_); |
| 292 DCHECK(context_thread_checker_.CalledOnValidThread()); | 304 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 293 // Skips past the trace_impl_ as it doesn't have capabilities. | 305 // Skips past the trace_impl_ as it doesn't have capabilities. |
| 294 return gles2_impl_->capabilities(); | 306 return gles2_impl_->capabilities(); |
| 295 } | 307 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 316 | 328 |
| 317 void ContextProviderCommandBuffer::SetLostContextCallback( | 329 void ContextProviderCommandBuffer::SetLostContextCallback( |
| 318 const LostContextCallback& lost_context_callback) { | 330 const LostContextCallback& lost_context_callback) { |
| 319 DCHECK(context_thread_checker_.CalledOnValidThread()); | 331 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 320 DCHECK(lost_context_callback_.is_null() || | 332 DCHECK(lost_context_callback_.is_null() || |
| 321 lost_context_callback.is_null()); | 333 lost_context_callback.is_null()); |
| 322 lost_context_callback_ = lost_context_callback; | 334 lost_context_callback_ = lost_context_callback; |
| 323 } | 335 } |
| 324 | 336 |
| 325 } // namespace content | 337 } // namespace content |
| OLD | NEW |