| 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" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 IPC_BEGIN_MESSAGE_MAP(GpuChannelManagerMessageFilter, message) | 47 IPC_BEGIN_MESSAGE_MAP(GpuChannelManagerMessageFilter, message) |
| 48 IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer) | 48 IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer) |
| 49 IPC_MESSAGE_UNHANDLED(handled = false) | 49 IPC_MESSAGE_UNHANDLED(handled = false) |
| 50 IPC_END_MESSAGE_MAP() | 50 IPC_END_MESSAGE_MAP() |
| 51 return handled; | 51 return handled; |
| 52 } | 52 } |
| 53 | 53 |
| 54 protected: | 54 protected: |
| 55 ~GpuChannelManagerMessageFilter() override {} | 55 ~GpuChannelManagerMessageFilter() override {} |
| 56 | 56 |
| 57 void OnCreateGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, | 57 void OnCreateGpuMemoryBuffer( |
| 58 const gfx::Size& size, | 58 const GpuMsg_CreateGpuMemoryBuffer_Params& params) { |
| 59 gfx::GpuMemoryBuffer::Format format, | |
| 60 gfx::GpuMemoryBuffer::Usage usage) { | |
| 61 TRACE_EVENT2("gpu", | 59 TRACE_EVENT2("gpu", |
| 62 "GpuChannelManagerMessageFilter::OnCreateGpuMemoryBuffer", | 60 "GpuChannelManagerMessageFilter::OnCreateGpuMemoryBuffer", |
| 63 "primary_id", | 61 "id", |
| 64 handle.global_id.primary_id, | 62 params.id, |
| 65 "secondary_id", | 63 "client_id", |
| 66 handle.global_id.secondary_id); | 64 params.client_id); |
| 67 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated( | 65 sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated( |
| 68 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer( | 66 gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(params.type, |
| 69 handle, size, format, usage))); | 67 params.id, |
| 68 params.size, |
| 69 params.format, |
| 70 params.usage, |
| 71 params.client_id))); |
| 70 } | 72 } |
| 71 | 73 |
| 72 IPC::Sender* sender_; | 74 IPC::Sender* sender_; |
| 73 GpuMemoryBufferFactory* gpu_memory_buffer_factory_; | 75 GpuMemoryBufferFactory* gpu_memory_buffer_factory_; |
| 74 }; | 76 }; |
| 75 | 77 |
| 76 } // namespace | 78 } // namespace |
| 77 | 79 |
| 78 GpuChannelManager::GpuChannelManager(MessageRouter* router, | 80 GpuChannelManager::GpuChannelManager(MessageRouter* router, |
| 79 GpuWatchdog* watchdog, | 81 GpuWatchdog* watchdog, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 CreateCommandBufferResult result = CREATE_COMMAND_BUFFER_FAILED; | 230 CreateCommandBufferResult result = CREATE_COMMAND_BUFFER_FAILED; |
| 229 | 231 |
| 230 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); | 232 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); |
| 231 if (iter != gpu_channels_.end()) { | 233 if (iter != gpu_channels_.end()) { |
| 232 result = iter->second->CreateViewCommandBuffer( | 234 result = iter->second->CreateViewCommandBuffer( |
| 233 window, surface_id, init_params, route_id); | 235 window, surface_id, init_params, route_id); |
| 234 } | 236 } |
| 235 | 237 |
| 236 Send(new GpuHostMsg_CommandBufferCreated(result)); | 238 Send(new GpuHostMsg_CommandBufferCreated(result)); |
| 237 } | 239 } |
| 240 |
| 238 void GpuChannelManager::DestroyGpuMemoryBuffer( | 241 void GpuChannelManager::DestroyGpuMemoryBuffer( |
| 239 const gfx::GpuMemoryBufferHandle& handle) { | 242 gfx::GpuMemoryBufferType type, |
| 243 gfx::GpuMemoryBufferId id, |
| 244 int client_id) { |
| 240 io_message_loop_->PostTask( | 245 io_message_loop_->PostTask( |
| 241 FROM_HERE, | 246 FROM_HERE, |
| 242 base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO, | 247 base::Bind(&GpuChannelManager::DestroyGpuMemoryBufferOnIO, |
| 243 base::Unretained(this), | 248 base::Unretained(this), |
| 244 handle)); | 249 type, |
| 250 id, |
| 251 client_id)); |
| 245 } | 252 } |
| 246 | 253 |
| 247 void GpuChannelManager::DestroyGpuMemoryBufferOnIO( | 254 void GpuChannelManager::DestroyGpuMemoryBufferOnIO( |
| 248 const gfx::GpuMemoryBufferHandle& handle) { | 255 gfx::GpuMemoryBufferType type, |
| 249 gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(handle); | 256 gfx::GpuMemoryBufferId id, |
| 257 int client_id) { |
| 258 gpu_memory_buffer_factory_->DestroyGpuMemoryBuffer(type, id, client_id); |
| 250 } | 259 } |
| 251 | 260 |
| 252 void GpuChannelManager::OnDestroyGpuMemoryBuffer( | 261 void GpuChannelManager::OnDestroyGpuMemoryBuffer( |
| 253 const gfx::GpuMemoryBufferHandle& handle, | 262 gfx::GpuMemoryBufferType type, |
| 263 gfx::GpuMemoryBufferId id, |
| 264 int client_id, |
| 254 int32 sync_point) { | 265 int32 sync_point) { |
| 255 if (!sync_point) { | 266 if (!sync_point) { |
| 256 DestroyGpuMemoryBuffer(handle); | 267 DestroyGpuMemoryBuffer(type, id, client_id); |
| 257 } else { | 268 } else { |
| 258 sync_point_manager()->AddSyncPointCallback( | 269 sync_point_manager()->AddSyncPointCallback( |
| 259 sync_point, | 270 sync_point, |
| 260 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, | 271 base::Bind(&GpuChannelManager::DestroyGpuMemoryBuffer, |
| 261 base::Unretained(this), | 272 base::Unretained(this), |
| 262 handle)); | 273 type, |
| 274 id, |
| 275 client_id)); |
| 263 } | 276 } |
| 264 } | 277 } |
| 265 | 278 |
| 266 void GpuChannelManager::OnLoadedShader(std::string program_proto) { | 279 void GpuChannelManager::OnLoadedShader(std::string program_proto) { |
| 267 if (program_cache()) | 280 if (program_cache()) |
| 268 program_cache()->LoadProgram(program_proto); | 281 program_cache()->LoadProgram(program_proto); |
| 269 } | 282 } |
| 270 | 283 |
| 271 bool GpuChannelManager::HandleMessagesScheduled() { | 284 bool GpuChannelManager::HandleMessagesScheduled() { |
| 272 for (GpuChannelMap::iterator iter = gpu_channels_.begin(); | 285 for (GpuChannelMap::iterator iter = gpu_channels_.begin(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 317 |
| 305 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { | 318 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { |
| 306 if (!default_offscreen_surface_.get()) { | 319 if (!default_offscreen_surface_.get()) { |
| 307 default_offscreen_surface_ = | 320 default_offscreen_surface_ = |
| 308 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); | 321 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); |
| 309 } | 322 } |
| 310 return default_offscreen_surface_.get(); | 323 return default_offscreen_surface_.get(); |
| 311 } | 324 } |
| 312 | 325 |
| 313 } // namespace content | 326 } // namespace content |
| OLD | NEW |