Chromium Code Reviews| Index: content/common/gpu/gpu_channel_manager.cc |
| diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc |
| index 1da6aecf2f3c82608fc57654592fc22c5d557c85..1e876477105eb8ddfa9239834d4810e4d7a9c3bf 100644 |
| --- a/content/common/gpu/gpu_channel_manager.cc |
| +++ b/content/common/gpu/gpu_channel_manager.cc |
| @@ -42,6 +42,7 @@ GpuChannelManager::~GpuChannelManager() { |
| default_offscreen_surface_->Destroy(); |
| default_offscreen_surface_ = NULL; |
| } |
| + DCHECK(image_operations_.empty()); |
| } |
| gpu::gles2::ProgramCache* GpuChannelManager::program_cache() { |
| @@ -95,6 +96,8 @@ bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { |
| IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
| IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, |
| OnCreateViewCommandBuffer) |
| + IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage) |
| + IPC_MESSAGE_HANDLER(GpuMsg_DeleteImage, OnDeleteImage) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP_EX() |
| return handled; |
| @@ -169,6 +172,77 @@ void GpuChannelManager::OnCreateViewCommandBuffer( |
| Send(new GpuHostMsg_CommandBufferCreated(route_id)); |
| } |
| +void GpuChannelManager::CreateImage( |
| + gfx::PluginWindowHandle window, int32 client_id, int32 image_id) { |
| + gfx::Size size; |
| + |
| + GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); |
| + if (iter != gpu_channels_.end()) { |
| + iter->second->CreateImage(window, image_id, &size); |
| + } |
| + |
| + Send(new GpuHostMsg_ImageCreated(size)); |
| +} |
| + |
| +void GpuChannelManager::OnCreateImage( |
| + gfx::PluginWindowHandle window, int32 client_id, int32 image_id) { |
| + DCHECK(image_id); |
| + |
| + if (image_operations_.empty()) |
| + CreateImage(window, client_id, image_id); |
| + else |
|
piman
2012/10/17 17:46:20
nit: style requires braces here because the statem
reveman
2012/10/17 21:22:55
Ah, braces required for multiple lines and not jus
|
| + image_operations_.push_back( |
| + std::make_pair(0, base::Bind(&GpuChannelManager::CreateImage, |
| + base::Unretained(this), |
| + window, |
| + client_id, |
| + image_id))); |
| +} |
| + |
| +void GpuChannelManager::DeleteImage(int32 client_id, int32 image_id) { |
| + GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); |
| + if (iter != gpu_channels_.end()) { |
| + iter->second->DeleteImage(image_id); |
| + } |
| +} |
| + |
| +void GpuChannelManager::OnDeleteImage( |
| + int32 client_id, int32 image_id, int32 sync_point) { |
| + DCHECK(image_id); |
| + |
| + if (!sync_point && image_operations_.empty()) { |
| + DeleteImage(client_id, image_id); |
| + } else { |
| + image_operations_.push_back( |
| + std::make_pair(sync_point, base::Bind(&GpuChannelManager::DeleteImage, |
| + base::Unretained(this), |
| + client_id, |
| + image_id))); |
| + if (sync_point) |
|
piman
2012/10/17 17:46:20
nit: style requires braces
|
| + sync_point_manager()->AddSyncPointCallback( |
| + sync_point, |
| + base::Bind(&GpuChannelManager::OnDeleteImageSyncPointRetired, |
| + base::Unretained(this), |
| + &image_operations_.back())); |
|
piman
2012/10/17 17:46:20
I don't think taking a pointer to the deque entry
reveman
2012/10/17 21:22:55
Oops, that's bad.
|
| + } |
| +} |
| + |
| +void GpuChannelManager::OnDeleteImageSyncPointRetired( |
| + ImageOperation* delete_image_operation) { |
| + // Mark operation as no longer having a pending sync point. |
| + delete_image_operation->first = 0; |
| + |
| + // De-queue operations until we reach a pending sync point. |
| + while (!image_operations_.empty()) { |
| + // Check if operation has a pending sync point. |
| + if (image_operations_.front().first) |
| + return; |
| + |
| + image_operations_.front().second.Run(); |
| + image_operations_.pop_front(); |
| + } |
| +} |
| + |
| void GpuChannelManager::LoseAllContexts() { |
| MessageLoop::current()->PostTask( |
| FROM_HERE, |