Chromium Code Reviews| 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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 845 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 845 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| 846 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 846 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
| 847 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); | 847 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
| 848 | 848 |
| 849 if (!ui::LatencyInfo::Verify(params.latency_info, | 849 if (!ui::LatencyInfo::Verify(params.latency_info, |
| 850 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) | 850 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) |
| 851 return; | 851 return; |
| 852 | 852 |
| 853 gfx::AcceleratedWidget native_widget = | 853 gfx::AcceleratedWidget native_widget = |
| 854 GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); | 854 GpuSurfaceTracker::Get()->AcquireNativeWidget(params.surface_id); |
| 855 | |
| 856 // Retrieve the render widget helper to forward this message to on the UI | |
| 857 // thread. | |
| 858 RenderWidgetHelper* helper = NULL; | |
| 859 int render_widget_id = 0; | |
| 855 if (native_widget) { | 860 if (native_widget) { |
| 856 RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnIOThread(this, params); | 861 int render_process_id = 0; |
| 857 return; | 862 if (RenderWidgetHelper::GetRenderWidgetIDForWidget( |
| 863 native_widget, &render_process_id, &render_widget_id)) { | |
|
piman
2014/07/07 18:27:43
Why do we need this? What's different with the ren
ccameron
2014/07/07 18:45:23
The surface was created for the browser, so it doe
piman
2014/07/07 19:40:56
I'm worried about races (lookup is done on the IO
| |
| 864 helper = RenderWidgetHelper::FromProcessHostID(render_process_id); | |
| 865 } | |
| 866 } else { | |
| 867 int render_process_id = 0; | |
| 868 if (GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( | |
| 869 params.surface_id, &render_process_id, &render_widget_id)) { | |
| 870 helper = RenderWidgetHelper::FromProcessHostID(render_process_id); | |
| 871 } | |
| 858 } | 872 } |
| 859 | 873 |
| 860 gfx::GLSurfaceHandle surface_handle = | 874 // If this is not targetting a native widget and we don't find a helper, then |
| 861 GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id); | 875 // ack immediately and ignore the message. |
| 862 // Compositor window is always gfx::kNullPluginWindow. | 876 if (!helper && !native_widget) { |
| 863 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no | 877 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 864 // plugin windows. | 878 ack_params.sync_point = 0; |
| 865 if (surface_handle.handle != gfx::kNullPluginWindow || | |
| 866 surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) { | |
| 867 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); | |
| 868 return; | |
| 869 } | |
| 870 | |
| 871 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
| 872 ack_params.sync_point = 0; | |
| 873 | |
| 874 int render_process_id = 0; | |
| 875 int render_widget_id = 0; | |
| 876 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( | |
| 877 params.surface_id, &render_process_id, &render_widget_id)) { | |
| 878 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, | |
| 879 ack_params)); | |
| 880 return; | |
| 881 } | |
| 882 RenderWidgetHelper* helper = | |
| 883 RenderWidgetHelper::FromProcessHostID(render_process_id); | |
| 884 if (!helper) { | |
| 885 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, | 879 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, |
| 886 ack_params)); | 880 ack_params)); |
| 887 return; | 881 return; |
| 888 } | 882 } |
| 889 | 883 |
| 884 // If this is targetting a native widget, then ack the swap immediately to | |
| 885 // avoid introducing a deadlock between the browser and GPU processes (rate | |
| 886 // limiting is done through the compositor). | |
| 887 if (native_widget) { | |
| 888 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | |
| 889 ack_params.sync_point = 0; | |
| 890 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, | |
| 891 ack_params)); | |
| 892 } | |
| 893 | |
| 890 // Pass the SwapBuffers on to the RenderWidgetHelper to wake up the UI thread | 894 // Pass the SwapBuffers on to the RenderWidgetHelper to wake up the UI thread |
| 891 // if the browser is waiting for a new frame. Otherwise the RenderWidgetHelper | 895 // if the browser is waiting for a new frame. Otherwise the RenderWidgetHelper |
| 892 // will forward to the RenderWidgetHostView via RenderProcessHostImpl and | 896 // will forward to the RenderWidgetHostView via RenderProcessHostImpl and |
| 893 // RenderWidgetHostImpl. | 897 // RenderWidgetHostImpl. |
| 894 ViewHostMsg_CompositorSurfaceBuffersSwapped_Params view_params; | 898 ViewHostMsg_CompositorSurfaceBuffersSwapped_Params view_params; |
| 899 view_params.use_native_widget = native_widget; | |
| 895 view_params.surface_id = params.surface_id; | 900 view_params.surface_id = params.surface_id; |
| 896 view_params.surface_handle = params.surface_handle; | 901 view_params.surface_handle = params.surface_handle; |
| 897 view_params.route_id = params.route_id; | 902 view_params.route_id = params.route_id; |
| 898 view_params.size = params.size; | 903 view_params.size = params.size; |
| 899 view_params.scale_factor = params.scale_factor; | 904 view_params.scale_factor = params.scale_factor; |
| 900 view_params.gpu_process_host_id = host_id_; | 905 view_params.gpu_process_host_id = host_id_; |
| 901 view_params.latency_info = params.latency_info; | 906 view_params.latency_info = params.latency_info; |
| 902 helper->DidReceiveBackingStoreMsg(ViewHostMsg_CompositorSurfaceBuffersSwapped( | 907 if (helper) { |
| 903 render_widget_id, | 908 helper->DidReceiveBackingStoreMsg( |
| 904 view_params)); | 909 ViewHostMsg_CompositorSurfaceBuffersSwapped( |
| 910 render_widget_id, | |
| 911 view_params)); | |
| 912 } else if (native_widget) { | |
| 913 BrowserThread::PostTask( | |
| 914 BrowserThread::UI, | |
| 915 FROM_HERE, | |
| 916 base::Bind(&RenderWidgetHelper::OnNativeSurfaceBuffersSwappedOnUIThread, | |
| 917 view_params)); | |
| 918 } | |
| 905 } | 919 } |
| 906 #endif // OS_MACOSX | 920 #endif // OS_MACOSX |
| 907 | 921 |
| 908 void GpuProcessHost::OnProcessLaunched() { | 922 void GpuProcessHost::OnProcessLaunched() { |
| 909 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", | 923 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
| 910 base::TimeTicks::Now() - init_start_time_); | 924 base::TimeTicks::Now() - init_start_time_); |
| 911 } | 925 } |
| 912 | 926 |
| 913 void GpuProcessHost::OnProcessCrashed(int exit_code) { | 927 void GpuProcessHost::OnProcessCrashed(int exit_code) { |
| 914 SendOutstandingReplies(); | 928 SendOutstandingReplies(); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1133 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1120 ClientIdToShaderCacheMap::iterator iter = | 1134 ClientIdToShaderCacheMap::iterator iter = |
| 1121 client_id_to_shader_cache_.find(client_id); | 1135 client_id_to_shader_cache_.find(client_id); |
| 1122 // If the cache doesn't exist then this is an off the record profile. | 1136 // If the cache doesn't exist then this is an off the record profile. |
| 1123 if (iter == client_id_to_shader_cache_.end()) | 1137 if (iter == client_id_to_shader_cache_.end()) |
| 1124 return; | 1138 return; |
| 1125 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1139 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1126 } | 1140 } |
| 1127 | 1141 |
| 1128 } // namespace content | 1142 } // namespace content |
| OLD | NEW |