| 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_manager.h" | 11 #include "content/common/gpu/gpu_memory_manager.h" |
| 11 #include "content/common/gpu/gpu_messages.h" | 12 #include "content/common/gpu/gpu_messages.h" |
| 12 #include "content/common/gpu/sync_point_manager.h" | 13 #include "content/common/gpu/sync_point_manager.h" |
| 13 #include "content/common/message_router.h" | 14 #include "content/common/message_router.h" |
| 14 #include "gpu/command_buffer/service/feature_info.h" | 15 #include "gpu/command_buffer/service/feature_info.h" |
| 15 #include "gpu/command_buffer/service/gpu_switches.h" | 16 #include "gpu/command_buffer/service/gpu_switches.h" |
| 16 #include "gpu/command_buffer/service/mailbox_manager.h" | 17 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 17 #include "gpu/command_buffer/service/memory_program_cache.h" | 18 #include "gpu/command_buffer/service/memory_program_cache.h" |
| 18 #include "gpu/command_buffer/service/shader_translator_cache.h" | 19 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 19 #include "ui/gl/gl_bindings.h" | 20 #include "ui/gl/gl_bindings.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 39 shutdown_event_(shutdown_event), | 40 shutdown_event_(shutdown_event), |
| 40 router_(router), | 41 router_(router), |
| 41 gpu_memory_manager_( | 42 gpu_memory_manager_( |
| 42 this, | 43 this, |
| 43 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), | 44 GpuMemoryManager::kDefaultMaxSurfacesWithFrontbufferSoftLimit), |
| 44 watchdog_(watchdog), | 45 watchdog_(watchdog), |
| 45 sync_point_manager_(new SyncPointManager) { | 46 sync_point_manager_(new SyncPointManager) { |
| 46 DCHECK(router_); | 47 DCHECK(router_); |
| 47 DCHECK(io_message_loop); | 48 DCHECK(io_message_loop); |
| 48 DCHECK(shutdown_event); | 49 DCHECK(shutdown_event); |
| 50 GpuMemoryBufferFactory::Initialize(); |
| 49 } | 51 } |
| 50 | 52 |
| 51 GpuChannelManager::~GpuChannelManager() { | 53 GpuChannelManager::~GpuChannelManager() { |
| 52 gpu_channels_.clear(); | 54 gpu_channels_.clear(); |
| 53 if (default_offscreen_surface_.get()) { | 55 if (default_offscreen_surface_.get()) { |
| 54 default_offscreen_surface_->Destroy(); | 56 default_offscreen_surface_->Destroy(); |
| 55 default_offscreen_surface_ = NULL; | 57 default_offscreen_surface_ = NULL; |
| 56 } | 58 } |
| 57 DCHECK(image_operations_.empty()); | 59 DCHECK(image_operations_.empty()); |
| 58 } | 60 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); | 178 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); |
| 177 if (iter != gpu_channels_.end()) { | 179 if (iter != gpu_channels_.end()) { |
| 178 succeeded = iter->second->CreateViewCommandBuffer( | 180 succeeded = iter->second->CreateViewCommandBuffer( |
| 179 window, surface_id, init_params, route_id); | 181 window, surface_id, init_params, route_id); |
| 180 } | 182 } |
| 181 | 183 |
| 182 Send(new GpuHostMsg_CommandBufferCreated(succeeded)); | 184 Send(new GpuHostMsg_CommandBufferCreated(succeeded)); |
| 183 } | 185 } |
| 184 | 186 |
| 185 void GpuChannelManager::CreateImage( | 187 void GpuChannelManager::CreateImage( |
| 186 gfx::PluginWindowHandle window, int32 client_id, int32 image_id) { | 188 const gfx::GpuMemoryBufferHandle& handle, |
| 187 gfx::Size size; | 189 const gfx::Size& size, |
| 190 unsigned internalformat, |
| 191 int32 client_id, |
| 192 int32 image_id) { |
| 193 if (!GpuMemoryBufferFactory::CreateGpuMemoryBuffer(handle, |
| 194 size, |
| 195 internalformat, |
| 196 0)) { |
| 197 Send(new GpuHostMsg_ImageCreated(false)); |
| 198 return; |
| 199 } |
| 188 | 200 |
| 189 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); | 201 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); |
| 190 if (iter != gpu_channels_.end()) { | 202 Send(new GpuHostMsg_ImageCreated( |
| 191 iter->second->CreateImage(window, image_id, &size); | 203 iter != gpu_channels_.end() |
| 192 } | 204 ? iter->second->CreateImage(handle, size, internalformat, image_id) |
| 193 | 205 : false)); |
| 194 Send(new GpuHostMsg_ImageCreated(size)); | |
| 195 } | 206 } |
| 196 | 207 |
| 197 void GpuChannelManager::OnCreateImage( | 208 void GpuChannelManager::OnCreateImage( |
| 198 gfx::PluginWindowHandle window, int32 client_id, int32 image_id) { | 209 const gfx::GpuMemoryBufferHandle& handle, |
| 210 const gfx::Size& size, |
| 211 unsigned internalformat, |
| 212 int32 client_id, |
| 213 int32 image_id) { |
| 199 DCHECK(image_id); | 214 DCHECK(image_id); |
| 200 | 215 |
| 201 if (image_operations_.empty()) { | 216 if (image_operations_.empty()) { |
| 202 CreateImage(window, client_id, image_id); | 217 CreateImage(handle, size, internalformat, client_id, image_id); |
| 203 } else { | 218 } else { |
| 204 image_operations_.push_back( | 219 image_operations_.push_back( |
| 205 new ImageOperation(0, base::Bind(&GpuChannelManager::CreateImage, | 220 new ImageOperation(0, base::Bind(&GpuChannelManager::CreateImage, |
| 206 base::Unretained(this), | 221 base::Unretained(this), |
| 207 window, | 222 handle, |
| 223 size, |
| 224 internalformat, |
| 208 client_id, | 225 client_id, |
| 209 image_id))); | 226 image_id))); |
| 210 } | 227 } |
| 211 } | 228 } |
| 212 | 229 |
| 213 void GpuChannelManager::DeleteImage(int32 client_id, int32 image_id) { | 230 void GpuChannelManager::DeleteImage(int32 client_id, int32 image_id) { |
| 214 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); | 231 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); |
| 215 if (iter != gpu_channels_.end()) { | 232 if (iter != gpu_channels_.end()) { |
| 216 iter->second->DeleteImage(image_id); | 233 iter->second->DeleteImage(image_id); |
| 217 } | 234 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 328 |
| 312 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { | 329 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { |
| 313 if (!default_offscreen_surface_.get()) { | 330 if (!default_offscreen_surface_.get()) { |
| 314 default_offscreen_surface_ = | 331 default_offscreen_surface_ = |
| 315 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); | 332 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); |
| 316 } | 333 } |
| 317 return default_offscreen_surface_.get(); | 334 return default_offscreen_surface_.get(); |
| 318 } | 335 } |
| 319 | 336 |
| 320 } // namespace content | 337 } // namespace content |
| OLD | NEW |