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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 bool preempts, | 670 bool preempts, |
671 bool allow_view_command_buffers, | 671 bool allow_view_command_buffers, |
672 bool allow_real_time_streams, | 672 bool allow_real_time_streams, |
673 const EstablishChannelCallback& callback) { | 673 const EstablishChannelCallback& callback) { |
674 DCHECK(CalledOnValidThread()); | 674 DCHECK(CalledOnValidThread()); |
675 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); | 675 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); |
676 | 676 |
677 // If GPU features are already blacklisted, no need to establish the channel. | 677 // If GPU features are already blacklisted, no need to establish the channel. |
678 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { | 678 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { |
679 DVLOG(1) << "GPU blacklisted, refusing to open a GPU channel."; | 679 DVLOG(1) << "GPU blacklisted, refusing to open a GPU channel."; |
680 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 680 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
| 681 EstablishChannelStatus::GPU_ACCESS_DENIED); |
681 return; | 682 return; |
682 } | 683 } |
683 | 684 |
684 DCHECK_EQ(preempts, allow_view_command_buffers); | 685 DCHECK_EQ(preempts, allow_view_command_buffers); |
685 DCHECK_EQ(preempts, allow_real_time_streams); | 686 DCHECK_EQ(preempts, allow_real_time_streams); |
686 bool is_gpu_host = preempts; | 687 bool is_gpu_host = preempts; |
687 | 688 |
688 channel_requests_.push(callback); | 689 channel_requests_.push(callback); |
689 gpu_service_ptr_->EstablishGpuChannel( | 690 gpu_service_ptr_->EstablishGpuChannel( |
690 client_id, client_tracing_id, is_gpu_host, | 691 client_id, client_tracing_id, is_gpu_host, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); | 743 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); |
743 DCHECK(!channel_requests_.empty()); | 744 DCHECK(!channel_requests_.empty()); |
744 DCHECK(channel_requests_.front().Equals(callback)); | 745 DCHECK(channel_requests_.front().Equals(callback)); |
745 channel_requests_.pop(); | 746 channel_requests_.pop(); |
746 | 747 |
747 // Currently if any of the GPU features are blacklisted, we don't establish a | 748 // Currently if any of the GPU features are blacklisted, we don't establish a |
748 // GPU channel. | 749 // GPU channel. |
749 if (channel_handle.is_valid() && | 750 if (channel_handle.is_valid() && |
750 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(nullptr)) { | 751 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(nullptr)) { |
751 gpu_service_ptr_->CloseChannel(client_id); | 752 gpu_service_ptr_->CloseChannel(client_id); |
752 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 753 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
| 754 EstablishChannelStatus::GPU_ACCESS_DENIED); |
753 RecordLogMessage(logging::LOG_WARNING, "WARNING", | 755 RecordLogMessage(logging::LOG_WARNING, "WARNING", |
754 "Hardware acceleration is unavailable."); | 756 "Hardware acceleration is unavailable."); |
755 return; | 757 return; |
756 } | 758 } |
757 | 759 |
758 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_); | 760 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_, |
| 761 EstablishChannelStatus::SUCCESS); |
759 } | 762 } |
760 | 763 |
761 void GpuProcessHost::OnGpuMemoryBufferCreated( | 764 void GpuProcessHost::OnGpuMemoryBufferCreated( |
762 const gfx::GpuMemoryBufferHandle& handle) { | 765 const gfx::GpuMemoryBufferHandle& handle) { |
763 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); | 766 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
764 | 767 |
765 DCHECK(!create_gpu_memory_buffer_requests_.empty()); | 768 DCHECK(!create_gpu_memory_buffer_requests_.empty()); |
766 auto callback = create_gpu_memory_buffer_requests_.front(); | 769 auto callback = create_gpu_memory_buffer_requests_.front(); |
767 create_gpu_memory_buffer_requests_.pop(); | 770 create_gpu_memory_buffer_requests_.pop(); |
768 callback.Run(handle); | 771 callback.Run(handle); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 return true; | 1039 return true; |
1037 } | 1040 } |
1038 | 1041 |
1039 void GpuProcessHost::SendOutstandingReplies() { | 1042 void GpuProcessHost::SendOutstandingReplies() { |
1040 valid_ = false; | 1043 valid_ = false; |
1041 | 1044 |
1042 // First send empty channel handles for all EstablishChannel requests. | 1045 // First send empty channel handles for all EstablishChannel requests. |
1043 while (!channel_requests_.empty()) { | 1046 while (!channel_requests_.empty()) { |
1044 auto callback = channel_requests_.front(); | 1047 auto callback = channel_requests_.front(); |
1045 channel_requests_.pop(); | 1048 channel_requests_.pop(); |
1046 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 1049 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
| 1050 EstablishChannelStatus::GPU_HOST_INVALID); |
1047 } | 1051 } |
1048 | 1052 |
1049 while (!create_gpu_memory_buffer_requests_.empty()) { | 1053 while (!create_gpu_memory_buffer_requests_.empty()) { |
1050 auto callback = create_gpu_memory_buffer_requests_.front(); | 1054 auto callback = create_gpu_memory_buffer_requests_.front(); |
1051 create_gpu_memory_buffer_requests_.pop(); | 1055 create_gpu_memory_buffer_requests_.pop(); |
1052 callback.Run(gfx::GpuMemoryBufferHandle()); | 1056 callback.Run(gfx::GpuMemoryBufferHandle()); |
1053 } | 1057 } |
1054 | 1058 |
1055 if (!send_destroying_video_surface_done_cb_.is_null()) | 1059 if (!send_destroying_video_surface_done_cb_.is_null()) |
1056 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); | 1060 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 if (!cache.get()) | 1179 if (!cache.get()) |
1176 return; | 1180 return; |
1177 | 1181 |
1178 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, | 1182 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, |
1179 weak_ptr_factory_.GetWeakPtr())); | 1183 weak_ptr_factory_.GetWeakPtr())); |
1180 | 1184 |
1181 client_id_to_shader_cache_[client_id] = cache; | 1185 client_id_to_shader_cache_[client_id] = cache; |
1182 } | 1186 } |
1183 | 1187 |
1184 } // namespace content | 1188 } // namespace content |
OLD | NEW |