| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/gpu/gpu.h" | 5 #include "services/ui/public/cpp/gpu/gpu.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "gpu/command_buffer/common/scheduling_priority.h" |
| 10 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" | 11 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" |
| 11 #include "mojo/public/cpp/system/platform_handle.h" | 12 #include "mojo/public/cpp/system/platform_handle.h" |
| 12 #include "services/service_manager/public/cpp/connector.h" | 13 #include "services/service_manager/public/cpp/connector.h" |
| 13 #include "services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.h" | 14 #include "services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.h" |
| 14 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 15 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
| 15 #include "services/ui/public/interfaces/constants.mojom.h" | 16 #include "services/ui/public/interfaces/constants.mojom.h" |
| 16 #include "services/ui/public/interfaces/gpu.mojom.h" | 17 #include "services/ui/public/interfaces/gpu.mojom.h" |
| 17 | 18 |
| 18 namespace ui { | 19 namespace ui { |
| 19 | 20 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 std::unique_ptr<Gpu> Gpu::Create( | 53 std::unique_ptr<Gpu> Gpu::Create( |
| 53 service_manager::Connector* connector, | 54 service_manager::Connector* connector, |
| 54 const std::string& service_name, | 55 const std::string& service_name, |
| 55 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 56 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 56 return base::WrapUnique( | 57 return base::WrapUnique( |
| 57 new Gpu(connector, service_name, std::move(task_runner))); | 58 new Gpu(connector, service_name, std::move(task_runner))); |
| 58 } | 59 } |
| 59 | 60 |
| 60 scoped_refptr<cc::ContextProvider> Gpu::CreateContextProvider( | 61 scoped_refptr<cc::ContextProvider> Gpu::CreateContextProvider( |
| 61 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | 62 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { |
| 63 int32_t stream_id = 0; |
| 64 gpu::SchedulingPriority stream_priority = gpu::SchedulingPriority::kNormal; |
| 65 |
| 62 constexpr bool automatic_flushes = false; | 66 constexpr bool automatic_flushes = false; |
| 63 constexpr bool support_locking = false; | 67 constexpr bool support_locking = false; |
| 68 |
| 64 gpu::gles2::ContextCreationAttribHelper attributes; | 69 gpu::gles2::ContextCreationAttribHelper attributes; |
| 65 attributes.alpha_size = -1; | 70 attributes.alpha_size = -1; |
| 66 attributes.depth_size = 0; | 71 attributes.depth_size = 0; |
| 67 attributes.stencil_size = 0; | 72 attributes.stencil_size = 0; |
| 68 attributes.samples = 0; | 73 attributes.samples = 0; |
| 69 attributes.sample_buffers = 0; | 74 attributes.sample_buffers = 0; |
| 70 attributes.bind_generates_resource = false; | 75 attributes.bind_generates_resource = false; |
| 71 attributes.lose_context_when_out_of_memory = true; | 76 attributes.lose_context_when_out_of_memory = true; |
| 72 constexpr ui::ContextProviderCommandBuffer* shared_context_provider = nullptr; | 77 ui::ContextProviderCommandBuffer* shared_context_provider = nullptr; |
| 73 return make_scoped_refptr(new ui::ContextProviderCommandBuffer( | 78 return make_scoped_refptr(new ui::ContextProviderCommandBuffer( |
| 74 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT, | 79 std::move(gpu_channel), stream_id, stream_priority, |
| 75 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, | 80 gpu::kNullSurfaceHandle, GURL("chrome://gpu/MusContextFactory"), |
| 76 GURL("chrome://gpu/MusContextFactory"), automatic_flushes, | 81 automatic_flushes, support_locking, gpu::SharedMemoryLimits(), attributes, |
| 77 support_locking, gpu::SharedMemoryLimits(), attributes, | |
| 78 shared_context_provider, ui::command_buffer_metrics::MUS_CLIENT_CONTEXT)); | 82 shared_context_provider, ui::command_buffer_metrics::MUS_CLIENT_CONTEXT)); |
| 79 } | 83 } |
| 80 | 84 |
| 81 void Gpu::EstablishGpuChannel( | 85 void Gpu::EstablishGpuChannel( |
| 82 const gpu::GpuChannelEstablishedCallback& callback) { | 86 const gpu::GpuChannelEstablishedCallback& callback) { |
| 83 DCHECK(IsMainThread()); | 87 DCHECK(IsMainThread()); |
| 84 scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel(); | 88 scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel(); |
| 85 if (channel) { | 89 if (channel) { |
| 86 main_task_runner_->PostTask(FROM_HERE, | 90 main_task_runner_->PostTask(FROM_HERE, |
| 87 base::Bind(callback, std::move(channel))); | 91 base::Bind(callback, std::move(channel))); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 MojoResult result = mojo::UnwrapSharedMemoryHandle( | 172 MojoResult result = mojo::UnwrapSharedMemoryHandle( |
| 169 std::move(handle), &platform_handle, &shared_memory_size, &readonly); | 173 std::move(handle), &platform_handle, &shared_memory_size, &readonly); |
| 170 if (result != MOJO_RESULT_OK) | 174 if (result != MOJO_RESULT_OK) |
| 171 return nullptr; | 175 return nullptr; |
| 172 DCHECK_EQ(shared_memory_size, size); | 176 DCHECK_EQ(shared_memory_size, size); |
| 173 | 177 |
| 174 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); | 178 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); |
| 175 } | 179 } |
| 176 | 180 |
| 177 } // namespace ui | 181 } // namespace ui |
| OLD | NEW |