| 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 "gpu/ipc/service/gpu_channel_manager.h" | 5 #include "gpu/ipc/service/gpu_channel_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 delegate_(delegate), | 55 delegate_(delegate), |
| 56 watchdog_(watchdog), | 56 watchdog_(watchdog), |
| 57 shutdown_event_(shutdown_event), | 57 shutdown_event_(shutdown_event), |
| 58 share_group_(new gfx::GLShareGroup), | 58 share_group_(new gfx::GLShareGroup), |
| 59 mailbox_manager_(gles2::MailboxManager::Create(gpu_preferences)), | 59 mailbox_manager_(gles2::MailboxManager::Create(gpu_preferences)), |
| 60 gpu_memory_manager_(this), | 60 gpu_memory_manager_(this), |
| 61 sync_point_manager_(sync_point_manager), | 61 sync_point_manager_(sync_point_manager), |
| 62 sync_point_client_waiter_( | 62 sync_point_client_waiter_( |
| 63 sync_point_manager->CreateSyncPointClientWaiter()), | 63 sync_point_manager->CreateSyncPointClientWaiter()), |
| 64 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), | 64 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), |
| 65 exiting_for_lost_context_(false), |
| 65 weak_factory_(this) { | 66 weak_factory_(this) { |
| 66 DCHECK(task_runner); | 67 DCHECK(task_runner); |
| 67 DCHECK(io_task_runner); | 68 DCHECK(io_task_runner); |
| 68 if (gpu_preferences_.ui_prioritize_in_gpu_process) | 69 if (gpu_preferences_.ui_prioritize_in_gpu_process) |
| 69 preemption_flag_ = new PreemptionFlag; | 70 preemption_flag_ = new PreemptionFlag; |
| 70 } | 71 } |
| 71 | 72 |
| 72 GpuChannelManager::~GpuChannelManager() { | 73 GpuChannelManager::~GpuChannelManager() { |
| 73 // Destroy channels before anything else because of dependencies. | 74 // Destroy channels before anything else because of dependencies. |
| 74 gpu_channels_.clear(); | 75 gpu_channels_.clear(); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 241 |
| 241 void GpuChannelManager::LoseAllContexts() { | 242 void GpuChannelManager::LoseAllContexts() { |
| 242 for (auto& kv : gpu_channels_) { | 243 for (auto& kv : gpu_channels_) { |
| 243 kv.second->MarkAllContextsLost(); | 244 kv.second->MarkAllContextsLost(); |
| 244 } | 245 } |
| 245 task_runner_->PostTask(FROM_HERE, | 246 task_runner_->PostTask(FROM_HERE, |
| 246 base::Bind(&GpuChannelManager::DestroyAllChannels, | 247 base::Bind(&GpuChannelManager::DestroyAllChannels, |
| 247 weak_factory_.GetWeakPtr())); | 248 weak_factory_.GetWeakPtr())); |
| 248 } | 249 } |
| 249 | 250 |
| 251 void GpuChannelManager::MaybeExitOnContextLost() { |
| 252 if (!gpu_preferences().single_process && !gpu_preferences().in_process_gpu) { |
| 253 LOG(ERROR) << "Exiting GPU process because some drivers cannot recover" |
| 254 << " from problems."; |
| 255 // Signal the message loop to quit to shut down other threads |
| 256 // gracefully. |
| 257 base::MessageLoop::current()->QuitNow(); |
| 258 exiting_for_lost_context_ = true; |
| 259 } |
| 260 } |
| 261 |
| 250 void GpuChannelManager::DestroyAllChannels() { | 262 void GpuChannelManager::DestroyAllChannels() { |
| 251 gpu_channels_.clear(); | 263 gpu_channels_.clear(); |
| 252 } | 264 } |
| 253 | 265 |
| 254 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { | 266 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { |
| 255 if (!default_offscreen_surface_.get()) { | 267 if (!default_offscreen_surface_.get()) { |
| 256 default_offscreen_surface_ = | 268 default_offscreen_surface_ = |
| 257 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); | 269 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); |
| 258 } | 270 } |
| 259 return default_offscreen_surface_.get(); | 271 return default_offscreen_surface_.get(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 } | 312 } |
| 301 } | 313 } |
| 302 if (!stub || !stub->decoder()->MakeCurrent()) | 314 if (!stub || !stub->decoder()->MakeCurrent()) |
| 303 return; | 315 return; |
| 304 glFinish(); | 316 glFinish(); |
| 305 DidAccessGpu(); | 317 DidAccessGpu(); |
| 306 } | 318 } |
| 307 #endif | 319 #endif |
| 308 | 320 |
| 309 } // namespace gpu | 321 } // namespace gpu |
| OLD | NEW |