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