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

Side by Side Diff: services/ui/common/gpu_service.cc

Issue 2096843002: mus+ash: Enable Chrome HW rendering in mus+ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a compile error Created 4 years, 5 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
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/common/gpu_service.h" 5 #include "services/ui/common/gpu_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return g_gpu_service; 82 return g_gpu_service;
83 } 83 }
84 84
85 void GpuService::EstablishGpuChannel(const base::Closure& callback) { 85 void GpuService::EstablishGpuChannel(const base::Closure& callback) {
86 base::AutoLock auto_lock(lock_); 86 base::AutoLock auto_lock(lock_);
87 auto runner = base::ThreadTaskRunnerHandle::Get(); 87 auto runner = base::ThreadTaskRunnerHandle::Get();
88 if (GetGpuChannelLocked()) { 88 if (GetGpuChannelLocked()) {
89 runner->PostTask(FROM_HERE, callback); 89 runner->PostTask(FROM_HERE, callback);
90 return; 90 return;
91 } 91 }
92 92 establish_callbacks_.push_back(
93 base::Closure wrapper_callback = 93 base::Bind(PostTask, runner, FROM_HERE, callback));
94 IsMainThread() ? callback
95 : base::Bind(PostTask, runner, FROM_HERE, callback);
96 establish_callbacks_.push_back(wrapper_callback);
97
98 if (!is_establishing_) { 94 if (!is_establishing_) {
99 is_establishing_ = true; 95 is_establishing_ = true;
100 main_task_runner_->PostTask( 96 main_task_runner_->PostTask(
101 FROM_HERE, base::Bind(&GpuService::EstablishGpuChannelOnMainThread, 97 FROM_HERE, base::Bind(&GpuService::EstablishGpuChannelOnMainThread,
102 base::Unretained(this))); 98 base::Unretained(this)));
103 } 99 }
104 } 100 }
105 101
106 scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() { 102 scoped_refptr<gpu::GpuChannelHost> GpuService::EstablishGpuChannelSync() {
107 base::AutoLock auto_lock(lock_); 103 base::AutoLock auto_lock(lock_);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 208 }
213 209
214 auto auto_lock = base::WrapUnique<base::AutoLock>( 210 auto auto_lock = base::WrapUnique<base::AutoLock>(
215 locked ? nullptr : new base::AutoLock(lock_)); 211 locked ? nullptr : new base::AutoLock(lock_));
216 DCHECK(is_establishing_); 212 DCHECK(is_establishing_);
217 DCHECK(!gpu_channel_); 213 DCHECK(!gpu_channel_);
218 214
219 is_establishing_ = false; 215 is_establishing_ = false;
220 gpu_channel_ = gpu_channel; 216 gpu_channel_ = gpu_channel;
221 establishing_condition_.Broadcast(); 217 establishing_condition_.Broadcast();
218 gpu_service_.reset();
222 219
223 for (const auto& i : establish_callbacks_) 220 for (const auto& i : establish_callbacks_)
224 i.Run(); 221 i.Run();
225 establish_callbacks_.clear(); 222 establish_callbacks_.clear();
226 gpu_service_.reset();
227 } 223 }
228 224
229 bool GpuService::IsMainThread() { 225 bool GpuService::IsMainThread() {
230 return main_task_runner_->BelongsToCurrentThread(); 226 return main_task_runner_->BelongsToCurrentThread();
231 } 227 }
232 228
233 scoped_refptr<base::SingleThreadTaskRunner> 229 scoped_refptr<base::SingleThreadTaskRunner>
234 GpuService::GetIOThreadTaskRunner() { 230 GpuService::GetIOThreadTaskRunner() {
235 return io_thread_.task_runner(); 231 return io_thread_.task_runner();
236 } 232 }
(...skipping 11 matching lines...) Expand all
248 MojoResult result = mojo::UnwrapSharedMemoryHandle( 244 MojoResult result = mojo::UnwrapSharedMemoryHandle(
249 std::move(handle), &platform_handle, &shared_memory_size, &readonly); 245 std::move(handle), &platform_handle, &shared_memory_size, &readonly);
250 if (result != MOJO_RESULT_OK) 246 if (result != MOJO_RESULT_OK)
251 return nullptr; 247 return nullptr;
252 DCHECK_EQ(shared_memory_size, size); 248 DCHECK_EQ(shared_memory_size, size);
253 249
254 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly); 250 return base::MakeUnique<base::SharedMemory>(platform_handle, readonly);
255 } 251 }
256 252
257 } // namespace ui 253 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698