Chromium Code Reviews| 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/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" |
| 11 #include "content/common/gpu/gpu_memory_manager.h" | 11 #include "content/common/gpu/gpu_memory_manager.h" |
| 12 #include "content/common/gpu/gpu_messages.h" | 12 #include "content/common/gpu/gpu_messages.h" |
| 13 #include "content/common/gpu/sync_point_manager.h" | 13 #include "content/common/gpu/sync_point_manager.h" |
| 14 #include "content/common/message_router.h" | 14 #include "content/common/message_router.h" |
| 15 #include "gpu/command_buffer/service/feature_info.h" | 15 #include "gpu/command_buffer/service/feature_info.h" |
| 16 #include "gpu/command_buffer/service/gpu_switches.h" | 16 #include "gpu/command_buffer/service/gpu_switches.h" |
| 17 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 17 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
| 18 #include "gpu/command_buffer/service/memory_program_cache.h" | 18 #include "gpu/command_buffer/service/memory_program_cache.h" |
| 19 #include "gpu/command_buffer/service/shader_translator_cache.h" | 19 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 20 #include "ipc/message_filter.h" | 20 #include "ipc/message_filter.h" |
| 21 #include "ui/gl/gl_bindings.h" | 21 #include "ui/gl/gl_bindings.h" |
| 22 #include "ui/gl/gl_share_group.h" | 22 #include "ui/gl/gl_share_group.h" |
| 23 #if defined(USE_OZONE) | |
| 24 #include "ui/ozone/public/gpu_platform_support.h" | |
| 25 #include "ui/ozone/public/ozone_platform.h" | |
| 26 #endif | |
| 23 | 27 |
| 24 namespace content { | 28 namespace content { |
| 25 | 29 |
| 26 namespace { | 30 namespace { |
| 27 | 31 |
| 28 class GpuChannelManagerMessageFilter : public IPC::MessageFilter { | 32 class GpuChannelManagerMessageFilter : public IPC::MessageFilter { |
| 29 public: | 33 public: |
| 30 GpuChannelManagerMessageFilter( | 34 GpuChannelManagerMessageFilter( |
| 31 GpuMemoryBufferFactory* gpu_memory_buffer_factory) | 35 GpuMemoryBufferFactory* gpu_memory_buffer_factory) |
| 32 : sender_(NULL), gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {} | 36 : sender_(NULL), gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {} |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 | 159 |
| 156 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { | 160 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { |
| 157 bool handled = true; | 161 bool handled = true; |
| 158 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) | 162 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) |
| 159 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) | 163 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
| 160 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) | 164 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
| 161 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, | 165 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, |
| 162 OnCreateViewCommandBuffer) | 166 OnCreateViewCommandBuffer) |
| 163 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) | 167 IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) |
| 164 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) | 168 IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) |
| 169 IPC_MESSAGE_HANDLER(GpuMsg_RelinquishResources, OnRelinquishResources) | |
| 165 IPC_MESSAGE_UNHANDLED(handled = false) | 170 IPC_MESSAGE_UNHANDLED(handled = false) |
| 166 IPC_END_MESSAGE_MAP() | 171 IPC_END_MESSAGE_MAP() |
| 167 return handled; | 172 return handled; |
| 168 } | 173 } |
| 169 | 174 |
| 170 bool GpuChannelManager::Send(IPC::Message* msg) { return router_->Send(msg); } | 175 bool GpuChannelManager::Send(IPC::Message* msg) { return router_->Send(msg); } |
| 171 | 176 |
| 172 void GpuChannelManager::OnEstablishChannel(int client_id, | 177 void GpuChannelManager::OnEstablishChannel(int client_id, |
| 173 bool share_context, | 178 bool share_context, |
| 174 bool allow_future_sync_points) { | 179 bool allow_future_sync_points) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 } | 321 } |
| 317 | 322 |
| 318 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { | 323 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { |
| 319 if (!default_offscreen_surface_.get()) { | 324 if (!default_offscreen_surface_.get()) { |
| 320 default_offscreen_surface_ = | 325 default_offscreen_surface_ = |
| 321 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); | 326 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); |
| 322 } | 327 } |
| 323 return default_offscreen_surface_.get(); | 328 return default_offscreen_surface_.get(); |
| 324 } | 329 } |
| 325 | 330 |
| 331 void GpuChannelManager::OnRelinquishResources() { | |
| 332 if (default_offscreen_surface_.get()) { | |
| 333 default_offscreen_surface_->Destroy(); | |
| 334 default_offscreen_surface_ = NULL; | |
| 335 } | |
| 336 #if defined(USE_OZONE) | |
| 337 ui::OzonePlatform::GetInstance()->GetGpuPlatformSupport()-> | |
| 338 RelinquishGpuResources(base::Bind( | |
| 339 &GpuChannelManager::OnResourcesReliuquished, base::Unretained(this))); | |
|
piman
2014/11/20 21:06:43
Is Unretained safe?
If it is, can you document why
GusFernandez
2014/11/20 21:42:48
Used the safer weak_factory_.GetWeakPtr() instead.
| |
| 340 #else | |
| 341 OnResourcesReliuquished(); | |
|
piman
2014/11/20 21:06:43
typo: Reliuquished -> Relinquished
GusFernandez
2014/11/20 21:42:48
Done.
| |
| 342 #endif | |
| 343 } | |
| 344 | |
| 345 void GpuChannelManager::OnResourcesReliuquished() { | |
| 346 Send(new GpuHostMsg_ResourcesRelinquished()); | |
| 347 } | |
| 348 | |
| 326 } // namespace content | 349 } // namespace content |
| OLD | NEW |