Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: services/ui/public/cpp/gpu/gpu.cc

Issue 2586323002: mus: Use ui::ContextProviderCommandBuffer. (Closed)
Patch Set: . Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/public/cpp/gpu/gpu.h ('k') | ui/aura/mus/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 gpu::gles2::ContextCreationAttribHelper attributes;
73 attributes.alpha_size = -1;
74 attributes.depth_size = 0;
75 attributes.stencil_size = 0;
76 attributes.samples = 0;
77 attributes.sample_buffers = 0;
78 attributes.bind_generates_resource = false;
79 attributes.lose_context_when_out_of_memory = true;
80 constexpr ui::ContextProviderCommandBuffer* shared_context_provider = nullptr;
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
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
OLDNEW
« no previous file with comments | « services/ui/public/cpp/gpu/gpu.h ('k') | ui/aura/mus/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698