| 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> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 | 152 |
| 153 // This command buffer is a client-side proxy to the command buffer in the | 153 // This command buffer is a client-side proxy to the command buffer in the |
| 154 // GPU process. | 154 // GPU process. |
| 155 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 155 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 156 default_task_runner_; | 156 default_task_runner_; |
| 157 if (!task_runner) | 157 if (!task_runner) |
| 158 task_runner = base::ThreadTaskRunnerHandle::Get(); | 158 task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 159 command_buffer_ = gpu::CommandBufferProxyImpl::Create( | 159 command_buffer_ = gpu::CommandBufferProxyImpl::Create( |
| 160 std::move(channel_), surface_handle_, shared_command_buffer, stream_id_, | 160 std::move(channel_), surface_handle_, shared_command_buffer, stream_id_, |
| 161 stream_priority_, attributes_, active_url_, std::move(task_runner)); | 161 stream_priority_, attributes_, active_url_, task_runner); |
| 162 if (!command_buffer_) { | 162 if (!command_buffer_) { |
| 163 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; | 163 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; |
| 164 command_buffer_metrics::UmaRecordContextInitFailed(context_type_); | 164 command_buffer_metrics::UmaRecordContextInitFailed(context_type_); |
| 165 return false; | 165 return false; |
| 166 } | 166 } |
| 167 | 167 |
| 168 // The GLES2 helper writes the command buffer protocol. | 168 // The GLES2 helper writes the command buffer protocol. |
| 169 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_.get())); | 169 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_.get())); |
| 170 gles2_helper_->SetAutomaticFlushes(automatic_flushes_); | 170 gles2_helper_->SetAutomaticFlushes(automatic_flushes_); |
| 171 if (!gles2_helper_->Initialize(memory_limits_.command_buffer_size)) { | 171 if (!gles2_helper_->Initialize(memory_limits_.command_buffer_size)) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // GpuChannelHost. Once that has happened, the service knows we are in the | 209 // GpuChannelHost. Once that has happened, the service knows we are in the |
| 210 // share group and if a shared context is lost, our context will be informed | 210 // share group and if a shared context is lost, our context will be informed |
| 211 // also, and the lost context callback will occur for the owner of the | 211 // also, and the lost context callback will occur for the owner of the |
| 212 // context provider. If we check sooner, the shared context may be lost in | 212 // context provider. If we check sooner, the shared context may be lost in |
| 213 // between these two states and our context here would be left in an orphan | 213 // between these two states and our context here would be left in an orphan |
| 214 // share group. | 214 // share group. |
| 215 if (share_group && share_group->IsLost()) | 215 if (share_group && share_group->IsLost()) |
| 216 return false; | 216 return false; |
| 217 | 217 |
| 218 shared_providers_->list.push_back(this); | 218 shared_providers_->list.push_back(this); |
| 219 |
| 220 cache_controller_.reset(new cc::ContextCacheController( |
| 221 gles2_impl_.get(), std::move(task_runner))); |
| 219 } | 222 } |
| 220 set_bind_failed.Reset(); | 223 set_bind_failed.Reset(); |
| 221 bind_succeeded_ = true; | 224 bind_succeeded_ = true; |
| 222 | 225 |
| 223 gles2_impl_->SetLostContextCallback( | 226 gles2_impl_->SetLostContextCallback( |
| 224 base::Bind(&ContextProviderCommandBuffer::OnLostContext, | 227 base::Bind(&ContextProviderCommandBuffer::OnLostContext, |
| 225 // |this| owns the GLES2Implementation which holds the | 228 // |this| owns the GLES2Implementation which holds the |
| 226 // callback. | 229 // callback. |
| 227 base::Unretained(this))); | 230 base::Unretained(this))); |
| 228 | 231 |
| 229 cache_controller_.reset(new cc::ContextCacheController(gles2_impl_.get())); | |
| 230 | |
| 231 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 232 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 232 switches::kEnableGpuClientTracing)) { | 233 switches::kEnableGpuClientTracing)) { |
| 233 // This wraps the real GLES2Implementation and we should always use this | 234 // This wraps the real GLES2Implementation and we should always use this |
| 234 // instead when it's present. | 235 // instead when it's present. |
| 235 trace_impl_.reset( | 236 trace_impl_.reset( |
| 236 new gpu::gles2::GLES2TraceImplementation(gles2_impl_.get())); | 237 new gpu::gles2::GLES2TraceImplementation(gles2_impl_.get())); |
| 237 } | 238 } |
| 238 | 239 |
| 239 // Do this last once the context is set up. | 240 // Do this last once the context is set up. |
| 240 std::string type_name = | 241 std::string type_name = |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 334 |
| 334 void ContextProviderCommandBuffer::SetLostContextCallback( | 335 void ContextProviderCommandBuffer::SetLostContextCallback( |
| 335 const LostContextCallback& lost_context_callback) { | 336 const LostContextCallback& lost_context_callback) { |
| 336 DCHECK(context_thread_checker_.CalledOnValidThread()); | 337 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 337 DCHECK(lost_context_callback_.is_null() || | 338 DCHECK(lost_context_callback_.is_null() || |
| 338 lost_context_callback.is_null()); | 339 lost_context_callback.is_null()); |
| 339 lost_context_callback_ = lost_context_callback; | 340 lost_context_callback_ = lost_context_callback; |
| 340 } | 341 } |
| 341 | 342 |
| 342 } // namespace content | 343 } // namespace content |
| OLD | NEW |