| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "gpu/config/gpu_driver_bug_list.h" | 33 #include "gpu/config/gpu_driver_bug_list.h" |
| 34 #include "gpu/config/gpu_info_collector.h" | 34 #include "gpu/config/gpu_info_collector.h" |
| 35 #include "gpu/config/gpu_switches.h" | 35 #include "gpu/config/gpu_switches.h" |
| 36 #include "gpu/config/gpu_util.h" | 36 #include "gpu/config/gpu_util.h" |
| 37 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 37 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
| 38 #include "gpu/ipc/service/gpu_config.h" | 38 #include "gpu/ipc/service/gpu_config.h" |
| 39 #include "gpu/ipc/service/gpu_init.h" | 39 #include "gpu/ipc/service/gpu_init.h" |
| 40 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" | 40 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" |
| 41 #include "gpu/ipc/service/gpu_watchdog_thread.h" | 41 #include "gpu/ipc/service/gpu_watchdog_thread.h" |
| 42 #include "ui/events/platform/platform_event_source.h" | 42 #include "ui/events/platform/platform_event_source.h" |
| 43 #include "ui/gfx/switches.h" | |
| 44 #include "ui/gl/gl_context.h" | 43 #include "ui/gl/gl_context.h" |
| 45 #include "ui/gl/gl_implementation.h" | 44 #include "ui/gl/gl_implementation.h" |
| 46 #include "ui/gl/gl_surface.h" | 45 #include "ui/gl/gl_surface.h" |
| 47 #include "ui/gl/gl_switches.h" | 46 #include "ui/gl/gl_switches.h" |
| 48 #include "ui/gl/gpu_switching_manager.h" | 47 #include "ui/gl/gpu_switching_manager.h" |
| 49 #include "ui/gl/init/gl_factory.h" | 48 #include "ui/gl/init/gl_factory.h" |
| 50 | 49 |
| 51 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 52 #include <windows.h> | 51 #include <windows.h> |
| 53 #include <dwmapi.h> | 52 #include <dwmapi.h> |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 193 |
| 195 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 194 logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |
| 196 | 195 |
| 197 // We are experiencing what appear to be memory-stomp issues in the GPU | 196 // We are experiencing what appear to be memory-stomp issues in the GPU |
| 198 // process. These issues seem to be impacting the message loop and listeners | 197 // process. These issues seem to be impacting the message loop and listeners |
| 199 // registered to it. Create the message loop on the heap to guard against | 198 // registered to it. Create the message loop on the heap to guard against |
| 200 // this. | 199 // this. |
| 201 // TODO(ericrk): Revisit this once we assess its impact on crbug.com/662802 | 200 // TODO(ericrk): Revisit this once we assess its impact on crbug.com/662802 |
| 202 // and crbug.com/609252. | 201 // and crbug.com/609252. |
| 203 std::unique_ptr<base::MessageLoop> main_message_loop; | 202 std::unique_ptr<base::MessageLoop> main_message_loop; |
| 204 if (command_line.HasSwitch(switches::kHeadless)) { | 203 |
| 205 main_message_loop.reset( | |
| 206 new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); | |
| 207 } else { | |
| 208 #if defined(OS_WIN) | 204 #if defined(OS_WIN) |
| 209 // OK to use default non-UI message loop because all GPU windows run on | 205 // OK to use default non-UI message loop because all GPU windows run on |
| 210 // dedicated thread. | 206 // dedicated thread. |
| 211 main_message_loop.reset( | 207 main_message_loop.reset( |
| 212 new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); | 208 new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); |
| 213 #elif defined(USE_X11) | 209 #elif defined(USE_X11) |
| 214 // We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX | 210 // We need a UI loop so that we can grab the Expose events. See GLSurfaceGLX |
| 215 // and https://crbug.com/326995. | 211 // and https://crbug.com/326995. |
| 216 main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); | 212 main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); |
| 217 std::unique_ptr<ui::PlatformEventSource> event_source = | 213 std::unique_ptr<ui::PlatformEventSource> event_source = |
| 218 ui::PlatformEventSource::CreateDefault(); | 214 ui::PlatformEventSource::CreateDefault(); |
| 219 #elif defined(USE_OZONE) && defined(OZONE_X11) | 215 #elif defined(USE_OZONE) && defined(OZONE_X11) |
| 220 // If we might be running Ozone X11 we need a UI loop to grab Expose events. | 216 // If we might be running Ozone X11 we need a UI loop to grab Expose events. |
| 221 // See GLSurfaceGLX and https://crbug.com/326995. | 217 // See GLSurfaceGLX and https://crbug.com/326995. |
| 222 main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); | 218 main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); |
| 223 #elif defined(USE_OZONE) | 219 #elif defined(USE_OZONE) |
| 224 main_message_loop.reset( | 220 main_message_loop.reset( |
| 225 new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); | 221 new base::MessageLoop(base::MessageLoop::TYPE_DEFAULT)); |
| 226 #elif defined(OS_LINUX) | 222 #elif defined(OS_LINUX) |
| 227 #error "Unsupported Linux platform." | 223 #error "Unsupported Linux platform." |
| 228 #elif defined(OS_MACOSX) | 224 #elif defined(OS_MACOSX) |
| 229 // This is necessary for CoreAnimation layers hosted in the GPU process to | 225 // This is necessary for CoreAnimation layers hosted in the GPU process to be |
| 230 // be drawn. See http://crbug.com/312462. | 226 // drawn. See http://crbug.com/312462. |
| 231 std::unique_ptr<base::MessagePump> pump(new base::MessagePumpCFRunLoop()); | 227 std::unique_ptr<base::MessagePump> pump(new base::MessagePumpCFRunLoop()); |
| 232 main_message_loop.reset(new base::MessageLoop(std::move(pump))); | 228 main_message_loop.reset(new base::MessageLoop(std::move(pump))); |
| 233 #else | 229 #else |
| 234 main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); | 230 main_message_loop.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); |
| 235 #endif | 231 #endif |
| 236 } | |
| 237 | 232 |
| 238 base::PlatformThread::SetName("CrGpuMain"); | 233 base::PlatformThread::SetName("CrGpuMain"); |
| 239 | 234 |
| 240 // Initializes StatisticsRecorder which tracks UMA histograms. | 235 // Initializes StatisticsRecorder which tracks UMA histograms. |
| 241 base::StatisticsRecorder::Initialize(); | 236 base::StatisticsRecorder::Initialize(); |
| 242 | 237 |
| 243 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 238 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 244 // Set thread priority before sandbox initialization. | 239 // Set thread priority before sandbox initialization. |
| 245 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); | 240 base::PlatformThread::SetCurrentThreadPriority(base::ThreadPriority::DISPLAY); |
| 246 #endif | 241 #endif |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 return true; | 350 return true; |
| 356 } | 351 } |
| 357 | 352 |
| 358 return false; | 353 return false; |
| 359 } | 354 } |
| 360 #endif // defined(OS_WIN) | 355 #endif // defined(OS_WIN) |
| 361 | 356 |
| 362 } // namespace. | 357 } // namespace. |
| 363 | 358 |
| 364 } // namespace content | 359 } // namespace content |
| OLD | NEW |