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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 base::WaitableEvent* shutdown_event, | 51 base::WaitableEvent* shutdown_event, |
52 SyncPointManager* sync_point_manager, | 52 SyncPointManager* sync_point_manager, |
53 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 53 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
54 : task_runner_(task_runner), | 54 : task_runner_(task_runner), |
55 io_task_runner_(io_task_runner), | 55 io_task_runner_(io_task_runner), |
56 gpu_preferences_(gpu_preferences), | 56 gpu_preferences_(gpu_preferences), |
57 gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()), | 57 gpu_driver_bug_workarounds_(base::CommandLine::ForCurrentProcess()), |
58 delegate_(delegate), | 58 delegate_(delegate), |
59 watchdog_(watchdog), | 59 watchdog_(watchdog), |
60 shutdown_event_(shutdown_event), | 60 shutdown_event_(shutdown_event), |
61 share_group_(new gfx::GLShareGroup), | 61 share_group_(new gl::GLShareGroup), |
62 mailbox_manager_(gles2::MailboxManager::Create(gpu_preferences)), | 62 mailbox_manager_(gles2::MailboxManager::Create(gpu_preferences)), |
63 gpu_memory_manager_(this), | 63 gpu_memory_manager_(this), |
64 sync_point_manager_(sync_point_manager), | 64 sync_point_manager_(sync_point_manager), |
65 sync_point_client_waiter_( | 65 sync_point_client_waiter_( |
66 sync_point_manager->CreateSyncPointClientWaiter()), | 66 sync_point_manager->CreateSyncPointClientWaiter()), |
67 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), | 67 gpu_memory_buffer_factory_(gpu_memory_buffer_factory), |
68 exiting_for_lost_context_(false), | 68 exiting_for_lost_context_(false), |
69 weak_factory_(this) { | 69 weak_factory_(this) { |
70 DCHECK(task_runner); | 70 DCHECK(task_runner); |
71 DCHECK(io_task_runner); | 71 DCHECK(io_task_runner); |
72 if (gpu_preferences_.ui_prioritize_in_gpu_process) | 72 if (gpu_preferences_.ui_prioritize_in_gpu_process) |
73 preemption_flag_ = new PreemptionFlag; | 73 preemption_flag_ = new PreemptionFlag; |
74 } | 74 } |
75 | 75 |
76 GpuChannelManager::~GpuChannelManager() { | 76 GpuChannelManager::~GpuChannelManager() { |
77 // Destroy channels before anything else because of dependencies. | 77 // Destroy channels before anything else because of dependencies. |
78 gpu_channels_.clear(); | 78 gpu_channels_.clear(); |
79 if (default_offscreen_surface_.get()) { | 79 if (default_offscreen_surface_.get()) { |
80 default_offscreen_surface_->Destroy(); | 80 default_offscreen_surface_->Destroy(); |
81 default_offscreen_surface_ = NULL; | 81 default_offscreen_surface_ = NULL; |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 gles2::ProgramCache* GpuChannelManager::program_cache() { | 85 gles2::ProgramCache* GpuChannelManager::program_cache() { |
86 if (!program_cache_.get() && | 86 if (!program_cache_.get() && |
87 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary || | 87 (gl::g_driver_gl.ext.b_GL_ARB_get_program_binary || |
88 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && | 88 gl::g_driver_gl.ext.b_GL_OES_get_program_binary) && |
89 !gpu_preferences_.disable_gpu_program_cache) { | 89 !gpu_preferences_.disable_gpu_program_cache) { |
90 program_cache_.reset(new gles2::MemoryProgramCache( | 90 program_cache_.reset(new gles2::MemoryProgramCache( |
91 gpu_preferences_.gpu_program_cache_size, | 91 gpu_preferences_.gpu_program_cache_size, |
92 gpu_preferences_.disable_gpu_shader_disk_cache)); | 92 gpu_preferences_.disable_gpu_shader_disk_cache)); |
93 } | 93 } |
94 return program_cache_.get(); | 94 return program_cache_.get(); |
95 } | 95 } |
96 | 96 |
97 gles2::ShaderTranslatorCache* | 97 gles2::ShaderTranslatorCache* |
98 GpuChannelManager::shader_translator_cache() { | 98 GpuChannelManager::shader_translator_cache() { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // gracefully. | 225 // gracefully. |
226 base::MessageLoop::current()->QuitNow(); | 226 base::MessageLoop::current()->QuitNow(); |
227 exiting_for_lost_context_ = true; | 227 exiting_for_lost_context_ = true; |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 void GpuChannelManager::DestroyAllChannels() { | 231 void GpuChannelManager::DestroyAllChannels() { |
232 gpu_channels_.clear(); | 232 gpu_channels_.clear(); |
233 } | 233 } |
234 | 234 |
235 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { | 235 gl::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { |
236 if (!default_offscreen_surface_.get()) { | 236 if (!default_offscreen_surface_.get()) { |
237 default_offscreen_surface_ = | 237 default_offscreen_surface_ = |
238 gl::init::CreateOffscreenGLSurface(gfx::Size()); | 238 gl::init::CreateOffscreenGLSurface(gfx::Size()); |
239 } | 239 } |
240 return default_offscreen_surface_.get(); | 240 return default_offscreen_surface_.get(); |
241 } | 241 } |
242 | 242 |
243 #if defined(OS_ANDROID) | 243 #if defined(OS_ANDROID) |
244 void GpuChannelManager::DidAccessGpu() { | 244 void GpuChannelManager::DidAccessGpu() { |
245 last_gpu_access_time_ = base::TimeTicks::Now(); | 245 last_gpu_access_time_ = base::TimeTicks::Now(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 } | 282 } |
283 if (!stub || !stub->decoder()->MakeCurrent()) | 283 if (!stub || !stub->decoder()->MakeCurrent()) |
284 return; | 284 return; |
285 glFinish(); | 285 glFinish(); |
286 DidAccessGpu(); | 286 DidAccessGpu(); |
287 } | 287 } |
288 #endif | 288 #endif |
289 | 289 |
290 } // namespace gpu | 290 } // namespace gpu |
OLD | NEW |