| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/ui/public/cpp/gles2_context.h" | 5 #include "services/ui/public/cpp/gles2_context.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; | 33 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; |
| 34 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; | 34 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; |
| 35 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; | 35 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; |
| 36 gpu::gles2::ContextCreationAttribHelper attributes; | 36 gpu::gles2::ContextCreationAttribHelper attributes; |
| 37 // TODO(penghuang): figure a useful active_url. | 37 // TODO(penghuang): figure a useful active_url. |
| 38 GURL active_url; | 38 GURL active_url; |
| 39 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 39 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 40 base::ThreadTaskRunnerHandle::Get(); | 40 base::ThreadTaskRunnerHandle::Get(); |
| 41 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( | 41 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( |
| 42 std::move(gpu_channel_host), surface_handle, shared_command_buffer, | 42 std::move(gpu_channel_host), surface_handle, shared_command_buffer, |
| 43 stream_id, stream_priority, attributes, active_url, | 43 stream_id, stream_priority, attributes, active_url, task_runner); |
| 44 std::move(task_runner)); | |
| 45 if (!command_buffer_proxy_impl_) | 44 if (!command_buffer_proxy_impl_) |
| 46 return false; | 45 return false; |
| 47 gpu::CommandBuffer* command_buffer = command_buffer_proxy_impl_.get(); | 46 gpu::CommandBuffer* command_buffer = command_buffer_proxy_impl_.get(); |
| 48 gpu::GpuControl* gpu_control = command_buffer_proxy_impl_.get(); | 47 gpu::GpuControl* gpu_control = command_buffer_proxy_impl_.get(); |
| 49 | 48 |
| 50 constexpr gpu::SharedMemoryLimits default_limits; | 49 constexpr gpu::SharedMemoryLimits default_limits; |
| 51 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); | 50 gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer)); |
| 52 if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) | 51 if (!gles2_helper_->Initialize(default_limits.command_buffer_size)) |
| 53 return false; | 52 return false; |
| 54 gles2_helper_->SetAutomaticFlushes(false); | 53 gles2_helper_->SetAutomaticFlushes(false); |
| 55 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); | 54 transfer_buffer_.reset(new gpu::TransferBuffer(gles2_helper_.get())); |
| 56 gpu::Capabilities capabilities = gpu_control->GetCapabilities(); | 55 gpu::Capabilities capabilities = gpu_control->GetCapabilities(); |
| 57 bool bind_generates_resource = | 56 bool bind_generates_resource = |
| 58 !!capabilities.bind_generates_resource_chromium; | 57 !!capabilities.bind_generates_resource_chromium; |
| 59 // TODO(piman): Some contexts (such as compositor) want this to be true, so | 58 // TODO(piman): Some contexts (such as compositor) want this to be true, so |
| 60 // this needs to be a public parameter. | 59 // this needs to be a public parameter. |
| 61 bool lose_context_when_out_of_memory = false; | 60 bool lose_context_when_out_of_memory = false; |
| 62 bool support_client_side_arrays = false; | 61 bool support_client_side_arrays = false; |
| 63 implementation_.reset(new gpu::gles2::GLES2Implementation( | 62 implementation_.reset(new gpu::gles2::GLES2Implementation( |
| 64 gles2_helper_.get(), NULL, transfer_buffer_.get(), | 63 gles2_helper_.get(), NULL, transfer_buffer_.get(), |
| 65 bind_generates_resource, lose_context_when_out_of_memory, | 64 bind_generates_resource, lose_context_when_out_of_memory, |
| 66 support_client_side_arrays, gpu_control)); | 65 support_client_side_arrays, gpu_control, std::move(task_runner))); |
| 67 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size, | 66 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size, |
| 68 default_limits.min_transfer_buffer_size, | 67 default_limits.min_transfer_buffer_size, |
| 69 default_limits.max_transfer_buffer_size, | 68 default_limits.max_transfer_buffer_size, |
| 70 default_limits.mapped_memory_reclaim_limit)) | 69 default_limits.mapped_memory_reclaim_limit)) |
| 71 return false; | 70 return false; |
| 72 return true; | 71 return true; |
| 73 } | 72 } |
| 74 | 73 |
| 75 // static | 74 // static |
| 76 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( | 75 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( |
| 77 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { | 76 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host) { |
| 78 if (!gpu_channel_host) | 77 if (!gpu_channel_host) |
| 79 return nullptr; | 78 return nullptr; |
| 80 | 79 |
| 81 // Return the GLES2Context only if it is successfully initialized. If | 80 // Return the GLES2Context only if it is successfully initialized. If |
| 82 // initialization fails, then return null. | 81 // initialization fails, then return null. |
| 83 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); | 82 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); |
| 84 if (!gles2_context->Initialize(std::move(gpu_channel_host))) | 83 if (!gles2_context->Initialize(std::move(gpu_channel_host))) |
| 85 gles2_context.reset(); | 84 gles2_context.reset(); |
| 86 return gles2_context; | 85 return gles2_context; |
| 87 } | 86 } |
| 88 | 87 |
| 89 } // namespace ui | 88 } // namespace ui |
| OLD | NEW |