Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: content/common/gpu/gpu_channel_manager.cc

Issue 712343003: Infrastructure for temportarily relinquishing GPU resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean-up based on feedback from spang and jbauman Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_memory_buffer_factory.h" 10 #include "content/common/gpu/gpu_memory_buffer_factory.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 gpu_memory_buffer_factory_.get())), 96 gpu_memory_buffer_factory_.get())),
97 weak_factory_(this) { 97 weak_factory_(this) {
98 DCHECK(router_); 98 DCHECK(router_);
99 DCHECK(io_message_loop); 99 DCHECK(io_message_loop);
100 DCHECK(shutdown_event); 100 DCHECK(shutdown_event);
101 channel_->AddFilter(filter_.get()); 101 channel_->AddFilter(filter_.get());
102 } 102 }
103 103
104 GpuChannelManager::~GpuChannelManager() { 104 GpuChannelManager::~GpuChannelManager() {
105 gpu_channels_.clear(); 105 gpu_channels_.clear();
106 if (default_offscreen_surface_.get()) { 106 OnDeleteDefaultOffscreenSurface();
107 default_offscreen_surface_->Destroy();
108 default_offscreen_surface_ = NULL;
109 }
110 } 107 }
111 108
112 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { 109 gpu::gles2::ProgramCache* GpuChannelManager::program_cache() {
113 if (!program_cache_.get() && 110 if (!program_cache_.get() &&
114 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary || 111 (gfx::g_driver_gl.ext.b_GL_ARB_get_program_binary ||
115 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) && 112 gfx::g_driver_gl.ext.b_GL_OES_get_program_binary) &&
116 !CommandLine::ForCurrentProcess()->HasSwitch( 113 !CommandLine::ForCurrentProcess()->HasSwitch(
117 switches::kDisableGpuProgramCache)) { 114 switches::kDisableGpuProgramCache)) {
118 program_cache_.reset(new gpu::gles2::MemoryProgramCache()); 115 program_cache_.reset(new gpu::gles2::MemoryProgramCache());
119 } 116 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 152
156 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { 153 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
157 bool handled = true; 154 bool handled = true;
158 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) 155 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg)
159 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) 156 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
160 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) 157 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
161 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, 158 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
162 OnCreateViewCommandBuffer) 159 OnCreateViewCommandBuffer)
163 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) 160 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer)
164 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) 161 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader)
162 IPC_MESSAGE_HANDLER(GpuMsg_DeleteDefaultOffscreenSurface,
163 OnDeleteDefaultOffscreenSurface)
165 IPC_MESSAGE_UNHANDLED(handled = false) 164 IPC_MESSAGE_UNHANDLED(handled = false)
166 IPC_END_MESSAGE_MAP() 165 IPC_END_MESSAGE_MAP()
167 return handled; 166 return handled;
168 } 167 }
169 168
170 bool GpuChannelManager::Send(IPC::Message* msg) { return router_->Send(msg); } 169 bool GpuChannelManager::Send(IPC::Message* msg) { return router_->Send(msg); }
171 170
172 void GpuChannelManager::OnEstablishChannel(int client_id, 171 void GpuChannelManager::OnEstablishChannel(int client_id,
173 bool share_context, 172 bool share_context,
174 bool allow_future_sync_points) { 173 bool allow_future_sync_points) {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 315 }
317 316
318 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 317 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
319 if (!default_offscreen_surface_.get()) { 318 if (!default_offscreen_surface_.get()) {
320 default_offscreen_surface_ = 319 default_offscreen_surface_ =
321 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); 320 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size());
322 } 321 }
323 return default_offscreen_surface_.get(); 322 return default_offscreen_surface_.get();
324 } 323 }
325 324
325 void GpuChannelManager::OnDeleteDefaultOffscreenSurface() {
326 if (default_offscreen_surface_.get()) {
327 default_offscreen_surface_->Destroy();
328 default_offscreen_surface_ = NULL;
329 }
330 }
331
326 } // namespace content 332 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698