Chromium Code Reviews| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 share_group = shared_context_provider->gles2_impl_->share_group(); | 135 share_group = shared_context_provider->gles2_impl_->share_group(); |
| 135 DCHECK_EQ(!!shared_command_buffer, !!share_group); | 136 DCHECK_EQ(!!shared_command_buffer, !!share_group); |
| 136 } | 137 } |
| 137 | 138 |
| 138 DCHECK(attributes_.buffer_preserved); | 139 DCHECK(attributes_.buffer_preserved); |
| 139 std::vector<int32_t> serialized_attributes; | 140 std::vector<int32_t> serialized_attributes; |
| 140 attributes_.Serialize(&serialized_attributes); | 141 attributes_.Serialize(&serialized_attributes); |
| 141 | 142 |
| 142 // This command buffer is a client-side proxy to the command buffer in the | 143 // This command buffer is a client-side proxy to the command buffer in the |
| 143 // GPU process. | 144 // GPU process. |
| 145 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | |
| 146 default_task_runner_; | |
| 147 if (!task_runner) | |
| 148 task_runner = base::ThreadTaskRunnerHandle::Get(); | |
| 144 command_buffer_ = channel_->CreateCommandBuffer( | 149 command_buffer_ = channel_->CreateCommandBuffer( |
| 145 surface_handle_, gfx::Size(), shared_command_buffer, | 150 surface_handle_, gfx::Size(), shared_command_buffer, |
| 146 gpu::GpuChannelHost::kDefaultStreamId, | 151 gpu::GpuChannelHost::kDefaultStreamId, |
| 147 gpu::GpuChannelHost::kDefaultStreamPriority, serialized_attributes, | 152 gpu::GpuChannelHost::kDefaultStreamPriority, serialized_attributes, |
| 148 active_url_, gpu_preference_); | 153 active_url_, gpu_preference_, task_runner); |
|
piman
2016/05/11 17:06:14
nit: std::move(task_runner)
| |
| 149 // The command buffer takes ownership of the |channel_|, so no need to keep | 154 // The command buffer takes ownership of the |channel_|, so no need to keep |
| 150 // a reference around here. | 155 // a reference around here. |
| 151 channel_ = nullptr; | 156 channel_ = nullptr; |
| 152 if (!command_buffer_) { | 157 if (!command_buffer_) { |
| 153 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; | 158 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; |
| 154 command_buffer_metrics::UmaRecordContextInitFailed(context_type_); | 159 command_buffer_metrics::UmaRecordContextInitFailed(context_type_); |
| 155 return false; | 160 return false; |
| 156 } | 161 } |
| 157 | 162 |
| 158 // The GLES2 helper writes the command buffer protocol. | 163 // The GLES2 helper writes the command buffer protocol. |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 gr_context_->ResetContext(state); | 279 gr_context_->ResetContext(state); |
| 275 } | 280 } |
| 276 } | 281 } |
| 277 | 282 |
| 278 void ContextProviderCommandBuffer::SetupLock() { | 283 void ContextProviderCommandBuffer::SetupLock() { |
| 279 DCHECK(bind_succeeded_); | 284 DCHECK(bind_succeeded_); |
| 280 DCHECK(context_thread_checker_.CalledOnValidThread()); | 285 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 281 command_buffer_->SetLock(&context_lock_); | 286 command_buffer_->SetLock(&context_lock_); |
| 282 } | 287 } |
| 283 | 288 |
| 289 void ContextProviderCommandBuffer::SetDefaultTaskRunner( | |
| 290 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner) { | |
| 291 DCHECK(!bind_succeeded_); | |
| 292 default_task_runner_ = default_task_runner; | |
|
piman
2016/05/11 17:06:14
nit: std::move(default_task_runner)
| |
| 293 } | |
| 294 | |
| 284 base::Lock* ContextProviderCommandBuffer::GetLock() { | 295 base::Lock* ContextProviderCommandBuffer::GetLock() { |
| 285 return &context_lock_; | 296 return &context_lock_; |
| 286 } | 297 } |
| 287 | 298 |
| 288 gpu::Capabilities ContextProviderCommandBuffer::ContextCapabilities() { | 299 gpu::Capabilities ContextProviderCommandBuffer::ContextCapabilities() { |
| 289 DCHECK(bind_succeeded_); | 300 DCHECK(bind_succeeded_); |
| 290 DCHECK(context_thread_checker_.CalledOnValidThread()); | 301 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 291 // Skips past the trace_impl_ as it doesn't have capabilities. | 302 // Skips past the trace_impl_ as it doesn't have capabilities. |
| 292 return gles2_impl_->capabilities(); | 303 return gles2_impl_->capabilities(); |
| 293 } | 304 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 314 | 325 |
| 315 void ContextProviderCommandBuffer::SetLostContextCallback( | 326 void ContextProviderCommandBuffer::SetLostContextCallback( |
| 316 const LostContextCallback& lost_context_callback) { | 327 const LostContextCallback& lost_context_callback) { |
| 317 DCHECK(context_thread_checker_.CalledOnValidThread()); | 328 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 318 DCHECK(lost_context_callback_.is_null() || | 329 DCHECK(lost_context_callback_.is_null() || |
| 319 lost_context_callback.is_null()); | 330 lost_context_callback.is_null()); |
| 320 lost_context_callback_ = lost_context_callback; | 331 lost_context_callback_ = lost_context_callback; |
| 321 } | 332 } |
| 322 | 333 |
| 323 } // namespace content | 334 } // namespace content |
| OLD | NEW |