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/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" | 9 #include "mojo/public/cpp/bindings/sync_call_restrictions.h" |
10 #include "mojo/public/cpp/system/platform_handle.h" | 10 #include "mojo/public/cpp/system/platform_handle.h" |
11 #include "services/service_manager/public/cpp/connector.h" | 11 #include "services/service_manager/public/cpp/connector.h" |
12 #include "services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.h" | 12 #include "services/ui/public/cpp/gpu/client_gpu_memory_buffer_manager.h" |
13 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | |
13 #include "services/ui/public/interfaces/constants.mojom.h" | 14 #include "services/ui/public/interfaces/constants.mojom.h" |
14 #include "services/ui/public/interfaces/gpu.mojom.h" | 15 #include "services/ui/public/interfaces/gpu.mojom.h" |
15 | 16 |
16 namespace ui { | 17 namespace ui { |
17 | 18 |
18 Gpu::Gpu(service_manager::Connector* connector, | 19 Gpu::Gpu(service_manager::Connector* connector, |
19 service_manager::InterfaceProvider* provider, | 20 service_manager::InterfaceProvider* provider, |
20 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 21 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
21 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 22 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
22 io_task_runner_(std::move(task_runner)), | 23 io_task_runner_(std::move(task_runner)), |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 58 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
58 return base::WrapUnique(new Gpu(connector, nullptr, std::move(task_runner))); | 59 return base::WrapUnique(new Gpu(connector, nullptr, std::move(task_runner))); |
59 } | 60 } |
60 | 61 |
61 std::unique_ptr<Gpu> Gpu::Create( | 62 std::unique_ptr<Gpu> Gpu::Create( |
62 service_manager::InterfaceProvider* provider, | 63 service_manager::InterfaceProvider* provider, |
63 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 64 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
64 return base::WrapUnique(new Gpu(nullptr, provider, std::move(task_runner))); | 65 return base::WrapUnique(new Gpu(nullptr, provider, std::move(task_runner))); |
65 } | 66 } |
66 | 67 |
68 scoped_refptr<cc::ContextProvider> Gpu::CreateContextProvider( | |
69 scoped_refptr<gpu::GpuChannelHost> gpu_channel) { | |
70 constexpr bool automatic_flushes = false; | |
71 constexpr bool support_locking = false; | |
72 constexpr ui::ContextProviderCommandBuffer* shared_context_provider = nullptr; | |
msw
2016/12/19 21:33:33
optional nit: reorder after attributes to match pa
sadrul
2016/12/20 03:53:20
Done.
| |
73 gpu::gles2::ContextCreationAttribHelper attributes; | |
74 attributes.alpha_size = -1; | |
msw
2016/12/19 21:33:33
nit: this is the default; explicit assignment is n
sadrul
2016/12/20 03:53:20
Good point. I have kept this for now though, since
| |
75 attributes.depth_size = 0; | |
76 attributes.stencil_size = 0; | |
77 attributes.samples = 0; | |
78 attributes.sample_buffers = 0; | |
79 attributes.bind_generates_resource = false; | |
80 attributes.lose_context_when_out_of_memory = true; | |
81 return make_scoped_refptr(new ui::ContextProviderCommandBuffer( | |
82 std::move(gpu_channel), gpu::GPU_STREAM_DEFAULT, | |
83 gpu::GpuStreamPriority::NORMAL, gpu::kNullSurfaceHandle, | |
84 GURL("chrome://gpu/MusContextFactory"), automatic_flushes, | |
85 support_locking, gpu::SharedMemoryLimits(), attributes, | |
86 shared_context_provider, ui::command_buffer_metrics::MUS_CLIENT_CONTEXT)); | |
87 } | |
88 | |
67 void Gpu::EstablishGpuChannel( | 89 void Gpu::EstablishGpuChannel( |
68 const gpu::GpuChannelEstablishedCallback& callback) { | 90 const gpu::GpuChannelEstablishedCallback& callback) { |
69 DCHECK(IsMainThread()); | 91 DCHECK(IsMainThread()); |
70 scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel(); | 92 scoped_refptr<gpu::GpuChannelHost> channel = GetGpuChannel(); |
71 if (channel) { | 93 if (channel) { |
72 main_task_runner_->PostTask(FROM_HERE, | 94 main_task_runner_->PostTask(FROM_HERE, |
73 base::Bind(callback, std::move(channel))); | 95 base::Bind(callback, std::move(channel))); |
74 return; | 96 return; |
75 } | 97 } |
76 establish_callbacks_.push_back(callback); | 98 establish_callbacks_.push_back(callback); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 MojoResult result = mojo::UnwrapSharedMemoryHandle( | 182 MojoResult result = mojo::UnwrapSharedMemoryHandle( |
161 std::move(handle), &platform_handle, &shared_memory_size, &readonly); | 183 std::move(handle), &platform_handle, &shared_memory_size, &readonly); |
162 if (result != MOJO_RESULT_OK) | 184 if (result != MOJO_RESULT_OK) |
163 return nullptr; | 185 return nullptr; |
164 DCHECK_EQ(shared_memory_size, size); | 186 DCHECK_EQ(shared_memory_size, size); |
165 | 187 |
166 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); | 188 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); |
167 } | 189 } |
168 | 190 |
169 } // namespace ui | 191 } // namespace ui |
OLD | NEW |