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