| 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 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 bool preempts, | 681 bool preempts, |
| 682 bool allow_view_command_buffers, | 682 bool allow_view_command_buffers, |
| 683 bool allow_real_time_streams, | 683 bool allow_real_time_streams, |
| 684 const EstablishChannelCallback& callback) { | 684 const EstablishChannelCallback& callback) { |
| 685 DCHECK(CalledOnValidThread()); | 685 DCHECK(CalledOnValidThread()); |
| 686 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); | 686 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); |
| 687 | 687 |
| 688 // If GPU features are already blacklisted, no need to establish the channel. | 688 // If GPU features are already blacklisted, no need to establish the channel. |
| 689 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { | 689 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { |
| 690 DVLOG(1) << "GPU blacklisted, refusing to open a GPU channel."; | 690 DVLOG(1) << "GPU blacklisted, refusing to open a GPU channel."; |
| 691 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 691 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
| 692 EstablishChannelStatus::GPU_ACCESS_DENIED); |
| 692 return; | 693 return; |
| 693 } | 694 } |
| 694 | 695 |
| 695 DCHECK_EQ(preempts, allow_view_command_buffers); | 696 DCHECK_EQ(preempts, allow_view_command_buffers); |
| 696 DCHECK_EQ(preempts, allow_real_time_streams); | 697 DCHECK_EQ(preempts, allow_real_time_streams); |
| 697 bool is_gpu_host = preempts; | 698 bool is_gpu_host = preempts; |
| 698 | 699 |
| 699 channel_requests_.push(callback); | 700 channel_requests_.push(callback); |
| 700 gpu_service_ptr_->EstablishGpuChannel( | 701 gpu_service_ptr_->EstablishGpuChannel( |
| 701 client_id, client_tracing_id, is_gpu_host, | 702 client_id, client_tracing_id, is_gpu_host, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); | 754 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); |
| 754 DCHECK(!channel_requests_.empty()); | 755 DCHECK(!channel_requests_.empty()); |
| 755 DCHECK(channel_requests_.front().Equals(callback)); | 756 DCHECK(channel_requests_.front().Equals(callback)); |
| 756 channel_requests_.pop(); | 757 channel_requests_.pop(); |
| 757 | 758 |
| 758 // Currently if any of the GPU features are blacklisted, we don't establish a | 759 // Currently if any of the GPU features are blacklisted, we don't establish a |
| 759 // GPU channel. | 760 // GPU channel. |
| 760 if (channel_handle.is_valid() && | 761 if (channel_handle.is_valid() && |
| 761 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(nullptr)) { | 762 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(nullptr)) { |
| 762 gpu_service_ptr_->CloseChannel(client_id); | 763 gpu_service_ptr_->CloseChannel(client_id); |
| 763 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 764 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
| 765 EstablishChannelStatus::GPU_ACCESS_DENIED); |
| 764 RecordLogMessage(logging::LOG_WARNING, "WARNING", | 766 RecordLogMessage(logging::LOG_WARNING, "WARNING", |
| 765 "Hardware acceleration is unavailable."); | 767 "Hardware acceleration is unavailable."); |
| 766 return; | 768 return; |
| 767 } | 769 } |
| 768 | 770 |
| 769 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_); | 771 callback.Run(IPC::ChannelHandle(channel_handle.release()), gpu_info_, |
| 772 EstablishChannelStatus::SUCCESS); |
| 770 } | 773 } |
| 771 | 774 |
| 772 void GpuProcessHost::OnGpuMemoryBufferCreated( | 775 void GpuProcessHost::OnGpuMemoryBufferCreated( |
| 773 const gfx::GpuMemoryBufferHandle& handle) { | 776 const gfx::GpuMemoryBufferHandle& handle) { |
| 774 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); | 777 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
| 775 | 778 |
| 776 DCHECK(!create_gpu_memory_buffer_requests_.empty()); | 779 DCHECK(!create_gpu_memory_buffer_requests_.empty()); |
| 777 auto callback = create_gpu_memory_buffer_requests_.front(); | 780 auto callback = create_gpu_memory_buffer_requests_.front(); |
| 778 create_gpu_memory_buffer_requests_.pop(); | 781 create_gpu_memory_buffer_requests_.pop(); |
| 779 callback.Run(handle); | 782 callback.Run(handle); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1054 return true; | 1057 return true; |
| 1055 } | 1058 } |
| 1056 | 1059 |
| 1057 void GpuProcessHost::SendOutstandingReplies() { | 1060 void GpuProcessHost::SendOutstandingReplies() { |
| 1058 valid_ = false; | 1061 valid_ = false; |
| 1059 | 1062 |
| 1060 // First send empty channel handles for all EstablishChannel requests. | 1063 // First send empty channel handles for all EstablishChannel requests. |
| 1061 while (!channel_requests_.empty()) { | 1064 while (!channel_requests_.empty()) { |
| 1062 auto callback = channel_requests_.front(); | 1065 auto callback = channel_requests_.front(); |
| 1063 channel_requests_.pop(); | 1066 channel_requests_.pop(); |
| 1064 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 1067 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo(), |
| 1068 EstablishChannelStatus::GPU_HOST_INVALID); |
| 1065 } | 1069 } |
| 1066 | 1070 |
| 1067 while (!create_gpu_memory_buffer_requests_.empty()) { | 1071 while (!create_gpu_memory_buffer_requests_.empty()) { |
| 1068 auto callback = create_gpu_memory_buffer_requests_.front(); | 1072 auto callback = create_gpu_memory_buffer_requests_.front(); |
| 1069 create_gpu_memory_buffer_requests_.pop(); | 1073 create_gpu_memory_buffer_requests_.pop(); |
| 1070 callback.Run(gfx::GpuMemoryBufferHandle()); | 1074 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 1071 } | 1075 } |
| 1072 | 1076 |
| 1073 if (!send_destroying_video_surface_done_cb_.is_null()) | 1077 if (!send_destroying_video_surface_done_cb_.is_null()) |
| 1074 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); | 1078 base::ResetAndReturn(&send_destroying_video_surface_done_cb_).Run(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 if (!cache.get()) | 1197 if (!cache.get()) |
| 1194 return; | 1198 return; |
| 1195 | 1199 |
| 1196 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, | 1200 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, |
| 1197 weak_ptr_factory_.GetWeakPtr())); | 1201 weak_ptr_factory_.GetWeakPtr())); |
| 1198 | 1202 |
| 1199 client_id_to_shader_cache_[client_id] = cache; | 1203 client_id_to_shader_cache_[client_id] = cache; |
| 1200 } | 1204 } |
| 1201 | 1205 |
| 1202 } // namespace content | 1206 } // namespace content |
| OLD | NEW |