| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
| 129 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process | 129 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process |
| 130 // (RenderWidget). | 130 // (RenderWidget). |
| 131 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( | 131 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( |
| 132 int surface_id, | 132 int surface_id, |
| 133 base::TimeTicks timebase, | 133 base::TimeTicks timebase, |
| 134 base::TimeDelta interval, | 134 base::TimeDelta interval, |
| 135 const ui::LatencyInfo& latency_info) { | 135 const std::vector<ui::LatencyInfo>& latency_info) { |
| 136 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 136 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 137 BrowserThread::PostTask( | 137 BrowserThread::PostTask( |
| 138 BrowserThread::UI, | 138 BrowserThread::UI, |
| 139 FROM_HERE, | 139 FROM_HERE, |
| 140 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForRenderer, | 140 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForRenderer, |
| 141 surface_id, timebase, interval, latency_info)); | 141 surface_id, timebase, interval, latency_info)); |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 | 144 |
| 145 int render_process_id = 0; | 145 int render_process_id = 0; |
| 146 int render_widget_id = 0; | 146 int render_widget_id = 0; |
| 147 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( | 147 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( |
| 148 surface_id, &render_process_id, &render_widget_id)) { | 148 surface_id, &render_process_id, &render_widget_id)) { |
| 149 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); | 149 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
| 150 return; | 150 return; |
| 151 } | 151 } |
| 152 RenderWidgetHost* rwh = | 152 RenderWidgetHost* rwh = |
| 153 RenderWidgetHost::FromID(render_process_id, render_widget_id); | 153 RenderWidgetHost::FromID(render_process_id, render_widget_id); |
| 154 if (!rwh) | 154 if (!rwh) |
| 155 return; | 155 return; |
| 156 RenderWidgetHostImpl::From(rwh)->AcknowledgeSwapBuffersToRenderer(); | 156 RenderWidgetHostImpl::From(rwh)->AcknowledgeSwapBuffersToRenderer(); |
| 157 if (interval != base::TimeDelta()) | 157 if (interval != base::TimeDelta()) |
| 158 RenderWidgetHostImpl::From(rwh)->UpdateVSyncParameters(timebase, interval); | 158 RenderWidgetHostImpl::From(rwh)->UpdateVSyncParameters(timebase, interval); |
| 159 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); | 159 for (size_t i = 0; i < latency_info.size(); i++) |
| 160 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info[i]); |
| 160 RenderWidgetHostImpl::From(rwh)->DidReceiveRendererFrame(); | 161 RenderWidgetHostImpl::From(rwh)->DidReceiveRendererFrame(); |
| 161 } | 162 } |
| 162 | 163 |
| 163 void AcceleratedSurfaceBuffersSwappedCompleted( | 164 void AcceleratedSurfaceBuffersSwappedCompleted( |
| 164 int host_id, | 165 int host_id, |
| 165 int route_id, | 166 int route_id, |
| 166 int surface_id, | 167 int surface_id, |
| 167 bool alive, | 168 bool alive, |
| 168 base::TimeTicks timebase, | 169 base::TimeTicks timebase, |
| 169 base::TimeDelta interval, | 170 base::TimeDelta interval, |
| 170 const ui::LatencyInfo& latency_info) { | 171 const std::vector<ui::LatencyInfo>& latency_info) { |
| 171 AcceleratedSurfaceBuffersSwappedCompletedForGPU( | 172 AcceleratedSurfaceBuffersSwappedCompletedForGPU( |
| 172 host_id, route_id, alive, timebase, interval); | 173 host_id, route_id, alive, timebase, interval); |
| 173 AcceleratedSurfaceBuffersSwappedCompletedForRenderer( | 174 AcceleratedSurfaceBuffersSwappedCompletedForRenderer( |
| 174 surface_id, timebase, interval, latency_info); | 175 surface_id, timebase, interval, latency_info); |
| 175 } | 176 } |
| 176 | 177 |
| 177 // NOTE: changes to this class need to be reviewed by the security team. | 178 // NOTE: changes to this class need to be reviewed by the security team. |
| 178 class GpuSandboxedProcessLauncherDelegate | 179 class GpuSandboxedProcessLauncherDelegate |
| 179 : public SandboxedProcessLauncherDelegate { | 180 : public SandboxedProcessLauncherDelegate { |
| 180 public: | 181 public: |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryUmaStatsReceived"); | 871 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryUmaStatsReceived"); |
| 871 uma_memory_stats_received_ = true; | 872 uma_memory_stats_received_ = true; |
| 872 uma_memory_stats_ = stats; | 873 uma_memory_stats_ = stats; |
| 873 } | 874 } |
| 874 | 875 |
| 875 #if defined(OS_MACOSX) | 876 #if defined(OS_MACOSX) |
| 876 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 877 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| 877 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 878 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
| 878 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); | 879 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
| 879 | 880 |
| 881 if (!ui::LatencyInfo::Verify(params.latency_info, |
| 882 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) |
| 883 return; |
| 884 |
| 880 gfx::GLSurfaceHandle surface_handle = | 885 gfx::GLSurfaceHandle surface_handle = |
| 881 GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id); | 886 GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id); |
| 882 // Compositor window is always gfx::kNullPluginWindow. | 887 // Compositor window is always gfx::kNullPluginWindow. |
| 883 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no | 888 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no |
| 884 // plugin windows. | 889 // plugin windows. |
| 885 if (surface_handle.handle != gfx::kNullPluginWindow || | 890 if (surface_handle.handle != gfx::kNullPluginWindow || |
| 886 surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) { | 891 surface_handle.transport_type == gfx::TEXTURE_TRANSPORT) { |
| 887 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); | 892 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
| 888 return; | 893 return; |
| 889 } | 894 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 render_widget_id, | 927 render_widget_id, |
| 923 view_params)); | 928 view_params)); |
| 924 } | 929 } |
| 925 #endif // OS_MACOSX | 930 #endif // OS_MACOSX |
| 926 | 931 |
| 927 #if defined(OS_WIN) | 932 #if defined(OS_WIN) |
| 928 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 933 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| 929 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 934 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
| 930 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); | 935 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
| 931 | 936 |
| 937 if (!ui::LatencyInfo::Verify(params.latency_info, |
| 938 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) |
| 939 return; |
| 940 |
| 932 base::ScopedClosureRunner scoped_completion_runner( | 941 base::ScopedClosureRunner scoped_completion_runner( |
| 933 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, | 942 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, |
| 934 host_id_, params.route_id, params.surface_id, | 943 host_id_, params.route_id, params.surface_id, |
| 935 true, base::TimeTicks(), base::TimeDelta(), ui::LatencyInfo())); | 944 true, base::TimeTicks(), base::TimeDelta(), |
| 945 std::vector<ui::LatencyInfo>())); |
| 936 | 946 |
| 937 gfx::GLSurfaceHandle handle = | 947 gfx::GLSurfaceHandle handle = |
| 938 GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id); | 948 GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id); |
| 939 | 949 |
| 940 if (handle.is_null()) | 950 if (handle.is_null()) |
| 941 return; | 951 return; |
| 942 | 952 |
| 943 if (handle.transport_type == gfx::TEXTURE_TRANSPORT) { | 953 if (handle.transport_type == gfx::TEXTURE_TRANSPORT) { |
| 944 TRACE_EVENT1("gpu", "SurfaceIDNotFound_RoutingToUI", | 954 TRACE_EVENT1("gpu", "SurfaceIDNotFound_RoutingToUI", |
| 945 "surface_id", params.surface_id); | 955 "surface_id", params.surface_id); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 992 gfx::Rect(params.size), target_frame, | 1002 gfx::Rect(params.size), target_frame, |
| 993 base::Bind(copy_callback, present_time)); | 1003 base::Bind(copy_callback, present_time)); |
| 994 } | 1004 } |
| 995 } | 1005 } |
| 996 } | 1006 } |
| 997 | 1007 |
| 998 void GpuProcessHost::OnAcceleratedSurfacePostSubBuffer( | 1008 void GpuProcessHost::OnAcceleratedSurfacePostSubBuffer( |
| 999 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { | 1009 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { |
| 1000 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfacePostSubBuffer"); | 1010 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfacePostSubBuffer"); |
| 1001 | 1011 |
| 1012 if (!ui::LatencyInfo::Verify(params.latency_info, |
| 1013 "GpuHostMsg_AcceleratedSurfacePostSubBuffer")) |
| 1014 return; |
| 1015 |
| 1002 NOTIMPLEMENTED(); | 1016 NOTIMPLEMENTED(); |
| 1003 } | 1017 } |
| 1004 | 1018 |
| 1005 void GpuProcessHost::OnAcceleratedSurfaceSuspend(int32 surface_id) { | 1019 void GpuProcessHost::OnAcceleratedSurfaceSuspend(int32 surface_id) { |
| 1006 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceSuspend"); | 1020 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceSuspend"); |
| 1007 | 1021 |
| 1008 gfx::PluginWindowHandle handle = | 1022 gfx::PluginWindowHandle handle = |
| 1009 GpuSurfaceTracker::Get()->GetSurfaceHandle(surface_id).handle; | 1023 GpuSurfaceTracker::Get()->GetSurfaceHandle(surface_id).handle; |
| 1010 | 1024 |
| 1011 if (!handle) { | 1025 if (!handle) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1275 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1262 ClientIdToShaderCacheMap::iterator iter = | 1276 ClientIdToShaderCacheMap::iterator iter = |
| 1263 client_id_to_shader_cache_.find(client_id); | 1277 client_id_to_shader_cache_.find(client_id); |
| 1264 // If the cache doesn't exist then this is an off the record profile. | 1278 // If the cache doesn't exist then this is an off the record profile. |
| 1265 if (iter == client_id_to_shader_cache_.end()) | 1279 if (iter == client_id_to_shader_cache_.end()) |
| 1266 return; | 1280 return; |
| 1267 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1281 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1268 } | 1282 } |
| 1269 | 1283 |
| 1270 } // namespace content | 1284 } // namespace content |
| OLD | NEW |