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

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

Issue 2781293003: gpu: Have GpuService create and own GpuMemoryBufferFactory. (Closed)
Patch Set: tot merge. Created 3 years, 8 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/gpu/gpu_service.h ('k') | services/ui/ws/gpu_host_unittest.cc » ('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/gpu/gpu_service.h" 5 #include "services/ui/gpu/gpu_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 void DestroyBinding( 79 void DestroyBinding(
80 std::unique_ptr<mojo::BindingSet<mojom::GpuService>> binding) { 80 std::unique_ptr<mojo::BindingSet<mojom::GpuService>> binding) {
81 binding->CloseAllBindings(); 81 binding->CloseAllBindings();
82 } 82 }
83 83
84 } // namespace 84 } // namespace
85 85
86 GpuService::GpuService(const gpu::GPUInfo& gpu_info, 86 GpuService::GpuService(const gpu::GPUInfo& gpu_info,
87 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, 87 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread,
88 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory,
89 scoped_refptr<base::SingleThreadTaskRunner> io_runner, 88 scoped_refptr<base::SingleThreadTaskRunner> io_runner,
90 const gpu::GpuFeatureInfo& gpu_feature_info) 89 const gpu::GpuFeatureInfo& gpu_feature_info)
91 : main_runner_(base::ThreadTaskRunnerHandle::Get()), 90 : main_runner_(base::ThreadTaskRunnerHandle::Get()),
92 io_runner_(std::move(io_runner)), 91 io_runner_(std::move(io_runner)),
93 watchdog_thread_(std::move(watchdog_thread)), 92 watchdog_thread_(std::move(watchdog_thread)),
94 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), 93 gpu_memory_buffer_factory_(
94 gpu::GpuMemoryBufferFactory::CreateNativeType()),
95 gpu_info_(gpu_info), 95 gpu_info_(gpu_info),
96 gpu_feature_info_(gpu_feature_info), 96 gpu_feature_info_(gpu_feature_info),
97 sync_point_manager_(nullptr), 97 sync_point_manager_(nullptr),
98 bindings_(base::MakeUnique<mojo::BindingSet<mojom::GpuService>>()), 98 bindings_(base::MakeUnique<mojo::BindingSet<mojom::GpuService>>()),
99 weak_ptr_factory_(this) { 99 weak_ptr_factory_(this) {
100 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); 100 weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
101 } 101 }
102 102
103 GpuService::~GpuService() { 103 GpuService::~GpuService() {
104 DCHECK(main_runner_->BelongsToCurrentThread()); 104 DCHECK(main_runner_->BelongsToCurrentThread());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 base::WaitableEvent::InitialState::NOT_SIGNALED); 167 base::WaitableEvent::InitialState::NOT_SIGNALED);
168 shutdown_event_ = owned_shutdown_event_.get(); 168 shutdown_event_ = owned_shutdown_event_.get();
169 } 169 }
170 170
171 // Defer creation of the render thread. This is to prevent it from handling 171 // Defer creation of the render thread. This is to prevent it from handling
172 // IPC messages before the sandbox has been enabled and all other necessary 172 // IPC messages before the sandbox has been enabled and all other necessary
173 // initialization has succeeded. 173 // initialization has succeeded.
174 gpu_channel_manager_.reset(new gpu::GpuChannelManager( 174 gpu_channel_manager_.reset(new gpu::GpuChannelManager(
175 gpu_preferences_, this, watchdog_thread_.get(), 175 gpu_preferences_, this, watchdog_thread_.get(),
176 base::ThreadTaskRunnerHandle::Get(), io_runner_, sync_point_manager_, 176 base::ThreadTaskRunnerHandle::Get(), io_runner_, sync_point_manager_,
177 gpu_memory_buffer_factory_, gpu_feature_info_, 177 gpu_memory_buffer_factory_.get(), gpu_feature_info_,
178 std::move(activity_flags))); 178 std::move(activity_flags)));
179 179
180 media_gpu_channel_manager_.reset( 180 media_gpu_channel_manager_.reset(
181 new media::MediaGpuChannelManager(gpu_channel_manager_.get())); 181 new media::MediaGpuChannelManager(gpu_channel_manager_.get()));
182 if (watchdog_thread()) 182 if (watchdog_thread())
183 watchdog_thread()->AddPowerObserver(); 183 watchdog_thread()->AddPowerObserver();
184 } 184 }
185 185
186 void GpuService::Bind(mojom::GpuServiceRequest request) { 186 void GpuService::Bind(mojom::GpuServiceRequest request) {
187 if (main_runner_->BelongsToCurrentThread()) { 187 if (main_runner_->BelongsToCurrentThread()) {
188 bind_task_tracker_.PostTask( 188 bind_task_tracker_.PostTask(
189 io_runner_.get(), FROM_HERE, 189 io_runner_.get(), FROM_HERE,
190 base::Bind(&GpuService::Bind, base::Unretained(this), 190 base::Bind(&GpuService::Bind, base::Unretained(this),
191 base::Passed(std::move(request)))); 191 base::Passed(std::move(request))));
192 return; 192 return;
193 } 193 }
194 bindings_->AddBinding(this, std::move(request)); 194 bindings_->AddBinding(this, std::move(request));
195 } 195 }
196 196
197 gpu::ImageFactory* GpuService::gpu_image_factory() {
198 return gpu_memory_buffer_factory_
199 ? gpu_memory_buffer_factory_->AsImageFactory()
200 : nullptr;
201 }
202
197 void GpuService::RecordLogMessage(int severity, 203 void GpuService::RecordLogMessage(int severity,
198 size_t message_start, 204 size_t message_start,
199 const std::string& str) { 205 const std::string& str) {
200 // This can be run from any thread. 206 // This can be run from any thread.
201 std::string header = str.substr(0, message_start); 207 std::string header = str.substr(0, message_start);
202 std::string message = str.substr(message_start); 208 std::string message = str.substr(message_start);
203 (*gpu_host_)->RecordLogMessage(severity, header, message); 209 (*gpu_host_)->RecordLogMessage(severity, header, message);
204 } 210 }
205 211
206 void GpuService::CreateGpuMemoryBuffer( 212 void GpuService::CreateGpuMemoryBuffer(
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 508
503 void GpuService::Stop(const StopCallback& callback) { 509 void GpuService::Stop(const StopCallback& callback) {
504 DCHECK(io_runner_->BelongsToCurrentThread()); 510 DCHECK(io_runner_->BelongsToCurrentThread());
505 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] { 511 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] {
506 base::MessageLoop::current()->QuitWhenIdle(); 512 base::MessageLoop::current()->QuitWhenIdle();
507 }), 513 }),
508 callback); 514 callback);
509 } 515 }
510 516
511 } // namespace ui 517 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/gpu/gpu_service.h ('k') | services/ui/ws/gpu_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698