| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "components/tracing/tracing_switches.h" | 24 #include "components/tracing/tracing_switches.h" |
| 25 #include "content/browser/browser_child_process_host_impl.h" | 25 #include "content/browser/browser_child_process_host_impl.h" |
| 26 #include "content/browser/gpu/compositor_util.h" | 26 #include "content/browser/gpu/compositor_util.h" |
| 27 #include "content/browser/gpu/gpu_data_manager_impl.h" | 27 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 28 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 28 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 29 #include "content/browser/gpu/gpu_surface_tracker.h" | 29 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 30 #include "content/browser/gpu/shader_disk_cache.h" | 30 #include "content/browser/gpu/shader_disk_cache.h" |
| 31 #include "content/browser/mojo/mojo_application_host.h" | 31 #include "content/browser/mojo/mojo_application_host.h" |
| 32 #include "content/browser/renderer_host/render_widget_host_impl.h" | 32 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 33 #include "content/common/child_process_host_impl.h" | 33 #include "content/common/child_process_host_impl.h" |
| 34 #include "content/common/gpu/gpu_messages.h" | 34 #include "content/common/gpu/gpu_host_messages.h" |
| 35 #include "content/common/in_process_child_thread_params.h" | 35 #include "content/common/in_process_child_thread_params.h" |
| 36 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
| 37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/browser/content_browser_client.h" | 38 #include "content/public/browser/content_browser_client.h" |
| 39 #include "content/public/browser/render_process_host.h" | 39 #include "content/public/browser/render_process_host.h" |
| 40 #include "content/public/browser/render_widget_host_view.h" | 40 #include "content/public/browser/render_widget_host_view.h" |
| 41 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 41 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 42 #include "content/public/common/content_client.h" | 42 #include "content/public/common/content_client.h" |
| 43 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 44 #include "content/public/common/result_codes.h" | 44 #include "content/public/common/result_codes.h" |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 OnDidCreateOffscreenContext) | 608 OnDidCreateOffscreenContext) |
| 609 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | 609 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) |
| 610 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 610 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
| 611 OnDidDestroyOffscreenContext) | 611 OnDidDestroyOffscreenContext) |
| 612 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | 612 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, |
| 613 OnGpuMemoryUmaStatsReceived) | 613 OnGpuMemoryUmaStatsReceived) |
| 614 #if defined(OS_MACOSX) | 614 #if defined(OS_MACOSX) |
| 615 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 615 IPC_MESSAGE_HANDLER_GENERIC(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 616 OnAcceleratedSurfaceBuffersSwapped(message)) | 616 OnAcceleratedSurfaceBuffersSwapped(message)) |
| 617 #endif | 617 #endif |
| 618 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, | 618 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, OnDestroyChannel) |
| 619 OnDestroyChannel) | 619 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, OnCacheShader) |
| 620 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, | |
| 621 OnCacheShader) | |
| 622 #if defined(OS_WIN) | 620 #if defined(OS_WIN) |
| 623 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, | 621 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, |
| 624 OnAcceleratedSurfaceCreatedChildWindow) | 622 OnAcceleratedSurfaceCreatedChildWindow) |
| 625 #endif | 623 #endif |
| 626 | 624 |
| 627 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 625 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
| 628 IPC_END_MESSAGE_MAP() | 626 IPC_END_MESSAGE_MAP() |
| 629 | 627 |
| 630 return true; | 628 return true; |
| 631 } | 629 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 DCHECK(CalledOnValidThread()); | 680 DCHECK(CalledOnValidThread()); |
| 683 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); | 681 TRACE_EVENT0("gpu", "GpuProcessHost::EstablishGpuChannel"); |
| 684 | 682 |
| 685 // If GPU features are already blacklisted, no need to establish the channel. | 683 // If GPU features are already blacklisted, no need to establish the channel. |
| 686 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { | 684 if (!GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { |
| 687 DVLOG(1) << "GPU blacklisted, refusing to open a GPU channel."; | 685 DVLOG(1) << "GPU blacklisted, refusing to open a GPU channel."; |
| 688 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 686 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
| 689 return; | 687 return; |
| 690 } | 688 } |
| 691 | 689 |
| 692 GpuMsg_EstablishChannel_Params params; | 690 EstablishChannelParams params; |
| 693 params.client_id = client_id; | 691 params.client_id = client_id; |
| 694 params.client_tracing_id = client_tracing_id; | 692 params.client_tracing_id = client_tracing_id; |
| 695 params.preempts = preempts; | 693 params.preempts = preempts; |
| 696 params.allow_view_command_buffers = allow_view_command_buffers; | 694 params.allow_view_command_buffers = allow_view_command_buffers; |
| 697 params.allow_real_time_streams = allow_real_time_streams; | 695 params.allow_real_time_streams = allow_real_time_streams; |
| 698 if (Send(new GpuMsg_EstablishChannel(params))) { | 696 if (Send(new GpuMsg_EstablishChannel(params))) { |
| 699 channel_requests_.push(callback); | 697 channel_requests_.push(callback); |
| 700 } else { | 698 } else { |
| 701 DVLOG(1) << "Failed to send GpuMsg_EstablishChannel."; | 699 DVLOG(1) << "Failed to send GpuMsg_EstablishChannel."; |
| 702 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 700 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 778 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
| 781 } | 779 } |
| 782 | 780 |
| 783 void GpuProcessHost::OnChannelEstablished( | 781 void GpuProcessHost::OnChannelEstablished( |
| 784 const IPC::ChannelHandle& channel_handle) { | 782 const IPC::ChannelHandle& channel_handle) { |
| 785 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); | 783 TRACE_EVENT0("gpu", "GpuProcessHost::OnChannelEstablished"); |
| 786 | 784 |
| 787 if (channel_requests_.empty()) { | 785 if (channel_requests_.empty()) { |
| 788 // This happens when GPU process is compromised. | 786 // This happens when GPU process is compromised. |
| 789 RouteOnUIThread(GpuHostMsg_OnLogMessage( | 787 RouteOnUIThread(GpuHostMsg_OnLogMessage( |
| 790 logging::LOG_WARNING, | 788 logging::LOG_WARNING, "WARNING", |
| 791 "WARNING", | |
| 792 "Received a ChannelEstablished message but no requests in queue.")); | 789 "Received a ChannelEstablished message but no requests in queue.")); |
| 793 return; | 790 return; |
| 794 } | 791 } |
| 795 EstablishChannelCallback callback = channel_requests_.front(); | 792 EstablishChannelCallback callback = channel_requests_.front(); |
| 796 channel_requests_.pop(); | 793 channel_requests_.pop(); |
| 797 | 794 |
| 798 // Currently if any of the GPU features are blacklisted, we don't establish a | 795 // Currently if any of the GPU features are blacklisted, we don't establish a |
| 799 // GPU channel. | 796 // GPU channel. |
| 800 if (!channel_handle.name.empty() && | 797 if (!channel_handle.name.empty() && |
| 801 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { | 798 !GpuDataManagerImpl::GetInstance()->GpuAccessAllowed(NULL)) { |
| 802 Send(new GpuMsg_CloseChannel(channel_handle)); | 799 Send(new GpuMsg_CloseChannel(channel_handle)); |
| 803 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); | 800 callback.Run(IPC::ChannelHandle(), gpu::GPUInfo()); |
| 804 RouteOnUIThread(GpuHostMsg_OnLogMessage( | 801 RouteOnUIThread( |
| 805 logging::LOG_WARNING, | 802 GpuHostMsg_OnLogMessage(logging::LOG_WARNING, "WARNING", |
| 806 "WARNING", | 803 "Hardware acceleration is unavailable.")); |
| 807 "Hardware acceleration is unavailable.")); | |
| 808 return; | 804 return; |
| 809 } | 805 } |
| 810 | 806 |
| 811 callback.Run(channel_handle, gpu_info_); | 807 callback.Run(channel_handle, gpu_info_); |
| 812 } | 808 } |
| 813 | 809 |
| 814 void GpuProcessHost::OnGpuMemoryBufferCreated( | 810 void GpuProcessHost::OnGpuMemoryBufferCreated( |
| 815 const gfx::GpuMemoryBufferHandle& handle) { | 811 const gfx::GpuMemoryBufferHandle& handle) { |
| 816 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); | 812 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryBufferCreated"); |
| 817 | 813 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1143 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1148 ClientIdToShaderCacheMap::iterator iter = | 1144 ClientIdToShaderCacheMap::iterator iter = |
| 1149 client_id_to_shader_cache_.find(client_id); | 1145 client_id_to_shader_cache_.find(client_id); |
| 1150 // If the cache doesn't exist then this is an off the record profile. | 1146 // If the cache doesn't exist then this is an off the record profile. |
| 1151 if (iter == client_id_to_shader_cache_.end()) | 1147 if (iter == client_id_to_shader_cache_.end()) |
| 1152 return; | 1148 return; |
| 1153 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1149 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1154 } | 1150 } |
| 1155 | 1151 |
| 1156 } // namespace content | 1152 } // namespace content |
| OLD | NEW |