| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 150 } |
| 151 | 151 |
| 152 // This command buffer is a client-side proxy to the command buffer in the | 152 // This command buffer is a client-side proxy to the command buffer in the |
| 153 // GPU process. | 153 // GPU process. |
| 154 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 154 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 155 default_task_runner_; | 155 default_task_runner_; |
| 156 if (!task_runner) | 156 if (!task_runner) |
| 157 task_runner = base::ThreadTaskRunnerHandle::Get(); | 157 task_runner = base::ThreadTaskRunnerHandle::Get(); |
| 158 command_buffer_ = gpu::CommandBufferProxyImpl::Create( | 158 command_buffer_ = gpu::CommandBufferProxyImpl::Create( |
| 159 std::move(channel_), surface_handle_, shared_command_buffer, stream_id_, | 159 std::move(channel_), surface_handle_, shared_command_buffer, stream_id_, |
| 160 stream_priority_, attributes_, active_url_, std::move(task_runner)); | 160 stream_priority_, attributes_, active_url_, task_runner); |
| 161 if (!command_buffer_) { | 161 if (!command_buffer_) { |
| 162 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; | 162 DLOG(ERROR) << "GpuChannelHost failed to create command buffer."; |
| 163 command_buffer_metrics::UmaRecordContextInitFailed(context_type_); | 163 command_buffer_metrics::UmaRecordContextInitFailed(context_type_); |
| 164 return false; | 164 return false; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // The GLES2 helper writes the command buffer protocol. | 167 // The GLES2 helper writes the command buffer protocol. |
| 168 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_.get())); | 168 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_.get())); |
| 169 gles2_helper_->SetAutomaticFlushes(automatic_flushes_); | 169 gles2_helper_->SetAutomaticFlushes(automatic_flushes_); |
| 170 if (!gles2_helper_->Initialize(memory_limits_.command_buffer_size)) { | 170 if (!gles2_helper_->Initialize(memory_limits_.command_buffer_size)) { |
| 171 DLOG(ERROR) << "Failed to initialize GLES2CmdHelper."; | 171 DLOG(ERROR) << "Failed to initialize GLES2CmdHelper."; |
| 172 return false; | 172 return false; |
| 173 } | 173 } |
| 174 | 174 |
| 175 // The transfer buffer is used to copy resources between the client | 175 // The transfer buffer is used to copy resources between the client |
| 176 // process and the GPU process. | 176 // process and the GPU process. |
| 177 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); | 177 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); |
| 178 | 178 |
| 179 // The GLES2Implementation exposes the OpenGLES2 API, as well as the | 179 // The GLES2Implementation exposes the OpenGLES2 API, as well as the |
| 180 // gpu::ContextSupport interface. | 180 // gpu::ContextSupport interface. |
| 181 constexpr bool support_client_side_arrays = false; | 181 constexpr bool support_client_side_arrays = false; |
| 182 gles2_impl_.reset(new gpu::gles2::GLES2Implementation( | 182 gles2_impl_.reset(new gpu::gles2::GLES2Implementation( |
| 183 gles2_helper_.get(), share_group, transfer_buffer_.get(), | 183 gles2_helper_.get(), share_group, transfer_buffer_.get(), |
| 184 attributes_.bind_generates_resource, | 184 attributes_.bind_generates_resource, |
| 185 attributes_.lose_context_when_out_of_memory, support_client_side_arrays, | 185 attributes_.lose_context_when_out_of_memory, support_client_side_arrays, |
| 186 command_buffer_.get())); | 186 command_buffer_.get(), std::move(task_runner))); |
| 187 if (!gles2_impl_->Initialize(memory_limits_.start_transfer_buffer_size, | 187 if (!gles2_impl_->Initialize(memory_limits_.start_transfer_buffer_size, |
| 188 memory_limits_.min_transfer_buffer_size, | 188 memory_limits_.min_transfer_buffer_size, |
| 189 memory_limits_.max_transfer_buffer_size, | 189 memory_limits_.max_transfer_buffer_size, |
| 190 memory_limits_.mapped_memory_reclaim_limit)) { | 190 memory_limits_.mapped_memory_reclaim_limit)) { |
| 191 DLOG(ERROR) << "Failed to initialize GLES2Implementation."; | 191 DLOG(ERROR) << "Failed to initialize GLES2Implementation."; |
| 192 return false; | 192 return false; |
| 193 } | 193 } |
| 194 | 194 |
| 195 if (command_buffer_->GetLastError() != gpu::error::kNoError) { | 195 if (command_buffer_->GetLastError() != gpu::error::kNoError) { |
| 196 DLOG(ERROR) << "Context dead on arrival. Last error: " | 196 DLOG(ERROR) << "Context dead on arrival. Last error: " |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 void ContextProviderCommandBuffer::SetLostContextCallback( | 334 void ContextProviderCommandBuffer::SetLostContextCallback( |
| 335 const LostContextCallback& lost_context_callback) { | 335 const LostContextCallback& lost_context_callback) { |
| 336 DCHECK(context_thread_checker_.CalledOnValidThread()); | 336 DCHECK(context_thread_checker_.CalledOnValidThread()); |
| 337 DCHECK(lost_context_callback_.is_null() || | 337 DCHECK(lost_context_callback_.is_null() || |
| 338 lost_context_callback.is_null()); | 338 lost_context_callback.is_null()); |
| 339 lost_context_callback_ = lost_context_callback; | 339 lost_context_callback_ = lost_context_callback; |
| 340 } | 340 } |
| 341 | 341 |
| 342 } // namespace content | 342 } // namespace content |
| OLD | NEW |