| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 | 767 |
| 768 void GpuProcessHost::OnChannelEstablished( | 768 void GpuProcessHost::OnChannelEstablished( |
| 769 int client_id, | 769 int client_id, |
| 770 const EstablishChannelCallback& callback, | 770 const EstablishChannelCallback& callback, |
| 771 mojo::ScopedMessagePipeHandle channel_handle) { | 771 mojo::ScopedMessagePipeHandle channel_handle) { |
| 772 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); | 772 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); |
| 773 DCHECK(!channel_requests_.empty()); | 773 DCHECK(!channel_requests_.empty()); |
| 774 DCHECK(channel_requests_.front().Equals(callback)); | 774 DCHECK(channel_requests_.front().Equals(callback)); |
| 775 channel_requests_.pop(); | 775 channel_requests_.pop(); |
| 776 | 776 |
| 777 auto* gpu_data_manager = GpuDataManagerImpl::GetInstance(); |
| 777 // Currently if any of the GPU features are blacklisted, we don't establish a | 778 // Currently if any of the GPU features are blacklisted, we don't establish a |
| 778 // GPU channel. | 779 // GPU channel. |
| 779 if (channel_handle.is_valid() && | 780 if (channel_handle.is_valid() && |
| 780 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(nullptr)) { | 781 !gpu_data_manager->GpuAccessAllowed(nullptr)) { |
| 781 gpu_service_ptr_->CloseChannel(client_id); | 782 gpu_service_ptr_->CloseChannel(client_id); |
| 782 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), | 783 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
| 783 EstablishChannelStatus::GPU_ACCESS_DENIED); | 784 EstablishChannelStatus::GPU_ACCESS_DENIED); |
| 784 RecordLogMessage(logging::LOG_WARNING, "WARNING", | 785 RecordLogMessage(logging::LOG_WARNING, "WARNING", |
| 785 "Hardware acceleration is unavailable."); | 786 "Hardware acceleration is unavailable."); |
| 786 return; | 787 return; |
| 787 } | 788 } |
| 788 | 789 |
| 789 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_, | 790 callback.Run(IPC::ChannelHandle(channel_handle.release()), |
| 790 EstablishChannelStatus::SUCCESS); | 791 gpu_data_manager->GetGPUInfo(), EstablishChannelStatus::SUCCESS); |
| 791 } | 792 } |
| 792 | 793 |
| 793 void GpuProcessHost::OnGpuMemoryBufferCreated( | 794 void GpuProcessHost::OnGpuMemoryBufferCreated( |
| 794 const gfx::GpuMemoryBufferHandle& handle) { | 795 const gfx::GpuMemoryBufferHandle& handle) { |
| 795 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); | 796 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
| 796 | 797 |
| 797 DCHECK(!create_gpu_memory_buffer_requests_.empty()); | 798 DCHECK(!create_gpu_memory_buffer_requests_.empty()); |
| 798 auto callback = create_gpu_memory_buffer_requests_.front(); | 799 auto callback = create_gpu_memory_buffer_requests_.front(); |
| 799 create_gpu_memory_buffer_requests_.pop(); | 800 create_gpu_memory_buffer_requests_.pop(); |
| 800 callback.Run(handle, BufferCreationStatus::SUCCESS); | 801 callback.Run(handle, BufferCreationStatus::SUCCESS); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 process_->GetTerminationStatus(true /* known_dead */, NULL)); | 840 process_->GetTerminationStatus(true /* known_dead */, NULL)); |
| 840 } | 841 } |
| 841 | 842 |
| 842 void GpuProcessHost::DidInitialize( | 843 void GpuProcessHost::DidInitialize( |
| 843 const gpu::GPUInfo& gpu_info, | 844 const gpu::GPUInfo& gpu_info, |
| 844 const gpu::GpuFeatureInfo& gpu_feature_info) { | 845 const gpu::GpuFeatureInfo& gpu_feature_info) { |
| 845 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", true); | 846 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", true); |
| 846 initialized_ = true; | 847 initialized_ = true; |
| 847 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); | 848 GpuDataManagerImpl* gpu_data_manager = GpuDataManagerImpl::GetInstance(); |
| 848 if (!gpu_data_manager->ShouldUseSwiftShader()) { | 849 if (!gpu_data_manager->ShouldUseSwiftShader()) { |
| 849 gpu_info_ = gpu_info; | |
| 850 gpu_data_manager->UpdateGpuInfo(gpu_info); | 850 gpu_data_manager->UpdateGpuInfo(gpu_info); |
| 851 gpu_data_manager->UpdateGpuFeatureInfo(gpu_feature_info); | 851 gpu_data_manager->UpdateGpuFeatureInfo(gpu_feature_info); |
| 852 } else { | |
| 853 gpu_info_ = gpu_data_manager->GetGPUInfo(); | |
| 854 } | 852 } |
| 855 } | 853 } |
| 856 | 854 |
| 857 void GpuProcessHost::DidFailInitialize() { | 855 void GpuProcessHost::DidFailInitialize() { |
| 858 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", false); | 856 UMA_HISTOGRAM_BOOLEAN("GPU.GPUProcessInitialized", false); |
| 859 initialized_ = false; | 857 initialized_ = false; |
| 860 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); | 858 GpuDataManagerImpl::GetInstance()->OnGpuProcessInitFailure(); |
| 861 } | 859 } |
| 862 | 860 |
| 863 void GpuProcessHost::DidCreateOffscreenContext(const GURL& url) { | 861 void GpuProcessHost::DidCreateOffscreenContext(const GURL& url) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1209 if (!cache.get()) | 1207 if (!cache.get()) |
| 1210 return; | 1208 return; |
| 1211 | 1209 |
| 1212 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, | 1210 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, |
| 1213 weak_ptr_factory_.GetWeakPtr())); | 1211 weak_ptr_factory_.GetWeakPtr())); |
| 1214 | 1212 |
| 1215 client_id_to_shader_cache_[client_id] = cache; | 1213 client_id_to_shader_cache_[client_id] = cache; |
| 1216 } | 1214 } |
| 1217 | 1215 |
| 1218 } // namespace content | 1216 } // namespace content |
| OLD | NEW |