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

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

Issue 2331453004: services/ui: Use the right type of message-pump in gpu. (Closed)
Patch Set: tot merge Created 4 years, 3 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 | « no previous file | no next file » | 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_internal.h" 5 #include "services/ui/gpu/gpu_service_internal.h"
6 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.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/service/gpu_switches.h" 10 #include "gpu/command_buffer/service/gpu_switches.h"
(...skipping 10 matching lines...) Expand all
21 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" 21 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h"
22 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" 22 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h"
23 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" 23 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
24 #include "media/gpu/ipc/service/media_service.h" 24 #include "media/gpu/ipc/service/media_service.h"
25 #include "ui/gl/gl_implementation.h" 25 #include "ui/gl/gl_implementation.h"
26 #include "ui/gl/gl_switches.h" 26 #include "ui/gl/gl_switches.h"
27 #include "ui/gl/gpu_switching_manager.h" 27 #include "ui/gl/gpu_switching_manager.h"
28 #include "ui/gl/init/gl_factory.h" 28 #include "ui/gl/init/gl_factory.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
31 #if defined(USE_OZONE) 31 namespace {
32 #include "ui/ozone/public/ozone_platform.h" 32
33 #endif 33 #if defined(OS_WIN)
34 std::unique_ptr<base::MessagePump> CreateMessagePumpWin() {
35 base::MessagePumpForGpu::InitFactory();
36 return base::MessageLoop::CreateMessagePumpForType(
37 base::MessageLoop::TYPE_UI);
38 }
39 #endif // defined(OS_WIN)
40
41 #if defined(USE_X11)
42 std::unique_ptr<base::MessagePump> CreateMessagePumpX11() {
43 // TODO(sad): This should create a TYPE_UI message pump, and create a
44 // PlatformEventSource when gpu process split happens.
45 return base::MessageLoop::CreateMessagePumpForType(
46 base::MessageLoop::TYPE_DEFAULT);
47 }
48 #endif // defined(USE_X11)
49
50 #if defined(OS_MACOSX)
51 std::unique_ptr<base::MessagePump> CreateMessagePumpMac() {
52 return base::MakeUnique<base::MessagePumpCFRunLoop>();
53 }
54 #endif // defined(OS_MACOSX)
55
56 } // namespace
34 57
35 namespace ui { 58 namespace ui {
36 59
37 GpuServiceInternal::GpuServiceInternal( 60 GpuServiceInternal::GpuServiceInternal(
38 const gpu::GPUInfo& gpu_info, 61 const gpu::GPUInfo& gpu_info,
39 gpu::GpuWatchdogThread* watchdog_thread, 62 gpu::GpuWatchdogThread* watchdog_thread,
40 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory) 63 gpu::GpuMemoryBufferFactory* gpu_memory_buffer_factory)
41 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()), 64 : main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
42 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL, 65 shutdown_event_(base::WaitableEvent::ResetPolicy::MANUAL,
43 base::WaitableEvent::InitialState::NOT_SIGNALED), 66 base::WaitableEvent::InitialState::NOT_SIGNALED),
44 gpu_thread_("GpuThread"), 67 gpu_thread_("GpuThread"),
45 io_thread_("GpuIOThread"), 68 io_thread_("GpuIOThread"),
46 watchdog_thread_(watchdog_thread), 69 watchdog_thread_(watchdog_thread),
47 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), 70 gpu_memory_buffer_factory_(gpu_memory_buffer_factory),
48 gpu_info_(gpu_info), 71 gpu_info_(gpu_info),
49 binding_(this) { 72 binding_(this) {
50 base::Thread::Options thread_options(base::MessageLoop::TYPE_DEFAULT, 0); 73 base::Thread::Options thread_options;
51 thread_options.priority = base::ThreadPriority::NORMAL; 74
75 #if defined(OS_WIN)
76 thread_options.message_pump_factory = base::Bind(&CreateMessagePumpWin);
77 #elif defined(USE_X11)
78 thread_options.message_pump_factory = base::Bind(&CreateMessagePumpX11);
79 #elif defined(OS_LINUX)
80 thread_options.message_loop_type = base::MessageLoop::TYPE_DEFAULT;
81 #elif defined(OS_MACOSX)
82 thread_options.message_pump_factory = base::Bind(&CreateMessagePumpMac);
83 #else
84 thread_options.message_loop_type = base::MessageLoop::TYPE_IO;
85 #endif
86
87 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
88 thread_options.priority = base::ThreadPriority::DISPLAY;
89 #endif
52 CHECK(gpu_thread_.StartWithOptions(thread_options)); 90 CHECK(gpu_thread_.StartWithOptions(thread_options));
53 91
54 // TODO(sad): We do not need the IO thread once gpu has a separate process. It 92 // TODO(sad): We do not need the IO thread once gpu has a separate process. It
55 // should be possible to use |main_task_runner_| for doing IO tasks. 93 // should be possible to use |main_task_runner_| for doing IO tasks.
56 thread_options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0); 94 thread_options = base::Thread::Options(base::MessageLoop::TYPE_IO, 0);
57 thread_options.priority = base::ThreadPriority::NORMAL; 95 thread_options.priority = base::ThreadPriority::NORMAL;
58 #if defined(OS_ANDROID) 96 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
59 // TODO(reveman): Remove this in favor of setting it explicitly for each type 97 // TODO(reveman): Remove this in favor of setting it explicitly for each type
60 // of process. 98 // of process.
61 thread_options.priority = base::ThreadPriority::DISPLAY; 99 thread_options.priority = base::ThreadPriority::DISPLAY;
62 #endif 100 #endif
63 CHECK(io_thread_.StartWithOptions(thread_options)); 101 CHECK(io_thread_.StartWithOptions(thread_options));
64 } 102 }
65 103
66 GpuServiceInternal::~GpuServiceInternal() { 104 GpuServiceInternal::~GpuServiceInternal() {
67 if (binding_.is_bound()) { 105 if (binding_.is_bound()) {
68 // Tear down the binding in the gpu thread. 106 // Tear down the binding in the gpu thread.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 mojo::ScopedMessagePipeHandle channel_handle; 235 mojo::ScopedMessagePipeHandle channel_handle;
198 IPC::ChannelHandle handle = gpu_channel_manager_->EstablishChannel( 236 IPC::ChannelHandle handle = gpu_channel_manager_->EstablishChannel(
199 client_id, client_tracing_id, preempts, allow_view_command_buffers, 237 client_id, client_tracing_id, preempts, allow_view_command_buffers,
200 allow_real_time_streams); 238 allow_real_time_streams);
201 channel_handle.reset(handle.mojo_handle); 239 channel_handle.reset(handle.mojo_handle);
202 media_service_->AddChannel(client_id); 240 media_service_->AddChannel(client_id);
203 callback.Run(std::move(channel_handle)); 241 callback.Run(std::move(channel_handle));
204 } 242 }
205 243
206 } // namespace ui 244 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698