| 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/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 | 637 |
| 638 DCHECK(CalledOnValidThread()); | 638 DCHECK(CalledOnValidThread()); |
| 639 | 639 |
| 640 if (!compositing_surface.is_null() && | 640 if (!compositing_surface.is_null() && |
| 641 Send(new GpuMsg_CreateViewCommandBuffer( | 641 Send(new GpuMsg_CreateViewCommandBuffer( |
| 642 compositing_surface, surface_id, client_id, init_params, route_id))) { | 642 compositing_surface, surface_id, client_id, init_params, route_id))) { |
| 643 create_command_buffer_requests_.push(callback); | 643 create_command_buffer_requests_.push(callback); |
| 644 surface_refs_.insert(std::make_pair(surface_id, | 644 surface_refs_.insert(std::make_pair(surface_id, |
| 645 GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface(surface_id))); | 645 GpuSurfaceTracker::GetInstance()->GetSurfaceRefForSurface(surface_id))); |
| 646 } else { | 646 } else { |
| 647 callback.Run(false); | 647 // Could distinguish here between compositing_surface being NULL |
| 648 // and Send failing, if desired. |
| 649 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
| 648 } | 650 } |
| 649 } | 651 } |
| 650 | 652 |
| 651 void GpuProcessHost::CreateImage(gfx::PluginWindowHandle window, | 653 void GpuProcessHost::CreateImage(gfx::PluginWindowHandle window, |
| 652 int client_id, | 654 int client_id, |
| 653 int image_id, | 655 int image_id, |
| 654 const CreateImageCallback& callback) { | 656 const CreateImageCallback& callback) { |
| 655 TRACE_EVENT0("gpu", "GpuProcessHost::CreateImage"); | 657 TRACE_EVENT0("gpu", "GpuProcessHost::CreateImage"); |
| 656 | 658 |
| 657 DCHECK(CalledOnValidThread()); | 659 DCHECK(CalledOnValidThread()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 logging::LOG_WARNING, | 738 logging::LOG_WARNING, |
| 737 "WARNING", | 739 "WARNING", |
| 738 "Hardware acceleration is unavailable.")); | 740 "Hardware acceleration is unavailable.")); |
| 739 return; | 741 return; |
| 740 } | 742 } |
| 741 | 743 |
| 742 callback.Run(channel_handle, | 744 callback.Run(channel_handle, |
| 743 GpuDataManagerImpl::GetInstance()->GetGPUInfo()); | 745 GpuDataManagerImpl::GetInstance()->GetGPUInfo()); |
| 744 } | 746 } |
| 745 | 747 |
| 746 void GpuProcessHost::OnCommandBufferCreated(bool succeeded) { | 748 void GpuProcessHost::OnCommandBufferCreated(CreateCommandBufferResult result) { |
| 747 TRACE_EVENT0("gpu", "GpuProcessHost::OnCommandBufferCreated"); | 749 TRACE_EVENT0("gpu", "GpuProcessHost::OnCommandBufferCreated"); |
| 748 | 750 |
| 749 if (create_command_buffer_requests_.empty()) | 751 if (create_command_buffer_requests_.empty()) |
| 750 return; | 752 return; |
| 751 | 753 |
| 752 CreateCommandBufferCallback callback = | 754 CreateCommandBufferCallback callback = |
| 753 create_command_buffer_requests_.front(); | 755 create_command_buffer_requests_.front(); |
| 754 create_command_buffer_requests_.pop(); | 756 create_command_buffer_requests_.pop(); |
| 755 callback.Run(succeeded); | 757 callback.Run(result); |
| 756 } | 758 } |
| 757 | 759 |
| 758 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { | 760 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { |
| 759 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyCommandBuffer"); | 761 TRACE_EVENT0("gpu", "GpuProcessHost::OnDestroyCommandBuffer"); |
| 760 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); | 762 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); |
| 761 if (it != surface_refs_.end()) { | 763 if (it != surface_refs_.end()) { |
| 762 surface_refs_.erase(it); | 764 surface_refs_.erase(it); |
| 763 } | 765 } |
| 764 } | 766 } |
| 765 | 767 |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 while (!channel_requests_.empty()) { | 1049 while (!channel_requests_.empty()) { |
| 1048 EstablishChannelCallback callback = channel_requests_.front(); | 1050 EstablishChannelCallback callback = channel_requests_.front(); |
| 1049 channel_requests_.pop(); | 1051 channel_requests_.pop(); |
| 1050 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 1052 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
| 1051 } | 1053 } |
| 1052 | 1054 |
| 1053 while (!create_command_buffer_requests_.empty()) { | 1055 while (!create_command_buffer_requests_.empty()) { |
| 1054 CreateCommandBufferCallback callback = | 1056 CreateCommandBufferCallback callback = |
| 1055 create_command_buffer_requests_.front(); | 1057 create_command_buffer_requests_.front(); |
| 1056 create_command_buffer_requests_.pop(); | 1058 create_command_buffer_requests_.pop(); |
| 1057 callback.Run(false); | 1059 callback.Run(CREATE_COMMAND_BUFFER_FAILED_AND_CHANNEL_LOST); |
| 1058 } | 1060 } |
| 1059 } | 1061 } |
| 1060 | 1062 |
| 1061 void GpuProcessHost::BlockLiveOffscreenContexts() { | 1063 void GpuProcessHost::BlockLiveOffscreenContexts() { |
| 1062 for (std::multiset<GURL>::iterator iter = | 1064 for (std::multiset<GURL>::iterator iter = |
| 1063 urls_with_live_offscreen_contexts_.begin(); | 1065 urls_with_live_offscreen_contexts_.begin(); |
| 1064 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { | 1066 iter != urls_with_live_offscreen_contexts_.end(); ++iter) { |
| 1065 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( | 1067 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs( |
| 1066 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); | 1068 *iter, GpuDataManagerImpl::DOMAIN_GUILT_UNKNOWN); |
| 1067 } | 1069 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1114 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1113 ClientIdToShaderCacheMap::iterator iter = | 1115 ClientIdToShaderCacheMap::iterator iter = |
| 1114 client_id_to_shader_cache_.find(client_id); | 1116 client_id_to_shader_cache_.find(client_id); |
| 1115 // If the cache doesn't exist then this is an off the record profile. | 1117 // If the cache doesn't exist then this is an off the record profile. |
| 1116 if (iter == client_id_to_shader_cache_.end()) | 1118 if (iter == client_id_to_shader_cache_.end()) |
| 1117 return; | 1119 return; |
| 1118 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1120 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1119 } | 1121 } |
| 1120 | 1122 |
| 1121 } // namespace content | 1123 } // namespace content |
| OLD | NEW |