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