| 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 "content/common/gpu/gpu_channel_manager.h" | 5 #include "content/common/gpu/gpu_channel_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "content/common/child_thread.h" | 9 #include "content/common/child_thread.h" |
| 10 #include "content/common/gpu/gpu_channel.h" | 10 #include "content/common/gpu/gpu_channel.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 watchdog_(watchdog), | 31 watchdog_(watchdog), |
| 32 sync_point_manager_(new SyncPointManager), | 32 sync_point_manager_(new SyncPointManager), |
| 33 program_cache_(NULL) { | 33 program_cache_(NULL) { |
| 34 DCHECK(gpu_child_thread); | 34 DCHECK(gpu_child_thread); |
| 35 DCHECK(io_message_loop); | 35 DCHECK(io_message_loop); |
| 36 DCHECK(shutdown_event); | 36 DCHECK(shutdown_event); |
| 37 } | 37 } |
| 38 | 38 |
| 39 GpuChannelManager::~GpuChannelManager() { | 39 GpuChannelManager::~GpuChannelManager() { |
| 40 gpu_channels_.clear(); | 40 gpu_channels_.clear(); |
| 41 if (default_offscreen_surface_.get()) { |
| 42 default_offscreen_surface_->Destroy(); |
| 43 default_offscreen_surface_ = NULL; |
| 44 } |
| 41 } | 45 } |
| 42 | 46 |
| 43 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { | 47 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { |
| 44 if (!program_cache_.get() && | 48 if (!program_cache_.get() && |
| 45 (gfx::g_ARB_get_program_binary || gfx::g_OES_get_program_binary) && | 49 (gfx::g_ARB_get_program_binary || gfx::g_OES_get_program_binary) && |
| 46 !CommandLine::ForCurrentProcess()->HasSwitch( | 50 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 47 switches::kDisableGpuProgramCache)) { | 51 switches::kDisableGpuProgramCache)) { |
| 48 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); | 52 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); |
| 49 } | 53 } |
| 50 return program_cache_.get(); | 54 return program_cache_.get(); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 void GpuChannelManager::LoseAllContexts() { | 172 void GpuChannelManager::LoseAllContexts() { |
| 169 MessageLoop::current()->PostTask( | 173 MessageLoop::current()->PostTask( |
| 170 FROM_HERE, | 174 FROM_HERE, |
| 171 base::Bind(&GpuChannelManager::OnLoseAllContexts, | 175 base::Bind(&GpuChannelManager::OnLoseAllContexts, |
| 172 weak_factory_.GetWeakPtr())); | 176 weak_factory_.GetWeakPtr())); |
| 173 } | 177 } |
| 174 | 178 |
| 175 void GpuChannelManager::OnLoseAllContexts() { | 179 void GpuChannelManager::OnLoseAllContexts() { |
| 176 gpu_channels_.clear(); | 180 gpu_channels_.clear(); |
| 177 } | 181 } |
| 182 |
| 183 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { |
| 184 if (!default_offscreen_surface_.get()) { |
| 185 default_offscreen_surface_ = gfx::GLSurface::CreateOffscreenGLSurface( |
| 186 false, gfx::Size(1, 1)); |
| 187 } |
| 188 return default_offscreen_surface_.get(); |
| 189 } |
| OLD | NEW |