| 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> |
| 11 | 11 |
| 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 13 #include "gpu/command_buffer/client/shared_memory_limits.h" | 13 #include "gpu/command_buffer/client/shared_memory_limits.h" |
| 14 #include "gpu/command_buffer/client/transfer_buffer.h" | 14 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 15 #include "gpu/ipc/client/command_buffer_proxy_impl.h" | 15 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 16 #include "gpu/ipc/client/gpu_channel_host.h" |
| 16 #include "mojo/public/cpp/system/core.h" | 17 #include "mojo/public/cpp/system/core.h" |
| 17 #include "services/ui/common/gpu_service.h" | 18 #include "services/ui/common/gpu_service.h" |
| 18 #include "services/ui/public/cpp/command_buffer_client_impl.h" | 19 #include "services/ui/public/cpp/command_buffer_client_impl.h" |
| 19 #include "services/ui/public/interfaces/command_buffer.mojom.h" | 20 #include "services/ui/public/interfaces/command_buffer.mojom.h" |
| 20 #include "services/ui/public/interfaces/gpu_service.mojom.h" | 21 #include "services/ui/public/interfaces/gpu_service.mojom.h" |
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 22 | 23 |
| 23 namespace ui { | 24 namespace ui { |
| 24 | 25 |
| 25 GLES2Context::GLES2Context() {} | 26 GLES2Context::GLES2Context() {} |
| 26 | 27 |
| 27 GLES2Context::~GLES2Context() {} | 28 GLES2Context::~GLES2Context() {} |
| 28 | 29 |
| 29 bool GLES2Context::Initialize(const std::vector<int32_t>& attribs) { | 30 bool GLES2Context::Initialize(GpuService* gpu_service) { |
| 30 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = | 31 scoped_refptr<gpu::GpuChannelHost> gpu_channel_host = |
| 31 GpuService::GetInstance()->EstablishGpuChannelSync(); | 32 gpu_service->EstablishGpuChannelSync(); |
| 32 if (!gpu_channel_host) | 33 if (!gpu_channel_host) |
| 33 return false; | 34 return false; |
| 34 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget; | 35 gpu::SurfaceHandle surface_handle = gfx::kNullAcceleratedWidget; |
| 35 // TODO(penghuang): support shared group. | 36 // TODO(penghuang): support shared group. |
| 36 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; | 37 gpu::CommandBufferProxyImpl* shared_command_buffer = nullptr; |
| 37 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; | 38 gpu::GpuStreamId stream_id = gpu::GpuStreamId::GPU_STREAM_DEFAULT; |
| 38 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; | 39 gpu::GpuStreamPriority stream_priority = gpu::GpuStreamPriority::NORMAL; |
| 39 gpu::gles2::ContextCreationAttribHelper attributes; | 40 gpu::gles2::ContextCreationAttribHelper attributes; |
| 40 // TODO(penghuang): figure a useful active_url. | 41 // TODO(penghuang): figure a useful active_url. |
| 41 GURL active_url; | 42 GURL active_url; |
| 42 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 43 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 43 base::ThreadTaskRunnerHandle::Get(); | 44 base::ThreadTaskRunnerHandle::Get(); |
| 44 if (!attributes.Parse(attribs)) | |
| 45 return false; | |
| 46 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( | 45 command_buffer_proxy_impl_ = gpu::CommandBufferProxyImpl::Create( |
| 47 std::move(gpu_channel_host), surface_handle, shared_command_buffer, | 46 std::move(gpu_channel_host), surface_handle, shared_command_buffer, |
| 48 stream_id, stream_priority, attributes, active_url, | 47 stream_id, stream_priority, attributes, active_url, |
| 49 std::move(task_runner)); | 48 std::move(task_runner)); |
| 50 if (!command_buffer_proxy_impl_) | 49 if (!command_buffer_proxy_impl_) |
| 51 return false; | 50 return false; |
| 52 gpu::CommandBuffer* command_buffer = command_buffer_proxy_impl_.get(); | 51 gpu::CommandBuffer* command_buffer = command_buffer_proxy_impl_.get(); |
| 53 gpu::GpuControl* gpu_control = command_buffer_proxy_impl_.get(); | 52 gpu::GpuControl* gpu_control = command_buffer_proxy_impl_.get(); |
| 54 | 53 |
| 55 constexpr gpu::SharedMemoryLimits default_limits; | 54 constexpr gpu::SharedMemoryLimits default_limits; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 72 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size, | 71 if (!implementation_->Initialize(default_limits.start_transfer_buffer_size, |
| 73 default_limits.min_transfer_buffer_size, | 72 default_limits.min_transfer_buffer_size, |
| 74 default_limits.max_transfer_buffer_size, | 73 default_limits.max_transfer_buffer_size, |
| 75 default_limits.mapped_memory_reclaim_limit)) | 74 default_limits.mapped_memory_reclaim_limit)) |
| 76 return false; | 75 return false; |
| 77 return true; | 76 return true; |
| 78 } | 77 } |
| 79 | 78 |
| 80 // static | 79 // static |
| 81 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( | 80 std::unique_ptr<GLES2Context> GLES2Context::CreateOffscreenContext( |
| 82 const std::vector<int32_t>& attribs) { | 81 GpuService* gpu_service) { |
| 83 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); | 82 std::unique_ptr<GLES2Context> gles2_context(new GLES2Context); |
| 84 if (!gles2_context->Initialize(attribs)) | 83 if (!gles2_context->Initialize(gpu_service)) |
| 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 |