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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 #include "ui/ozone/ozone_switches.h" | 57 #include "ui/ozone/ozone_switches.h" |
58 #endif | 58 #endif |
59 | 59 |
60 namespace content { | 60 namespace content { |
61 | 61 |
62 bool GpuProcessHost::gpu_enabled_ = true; | 62 bool GpuProcessHost::gpu_enabled_ = true; |
63 bool GpuProcessHost::hardware_gpu_enabled_ = true; | 63 bool GpuProcessHost::hardware_gpu_enabled_ = true; |
64 | 64 |
65 namespace { | 65 namespace { |
66 | 66 |
| 67 const unsigned int kMaxLatencyInfoNumber = 100; |
| 68 |
67 enum GPUProcessLifetimeEvent { | 69 enum GPUProcessLifetimeEvent { |
68 LAUNCHED, | 70 LAUNCHED, |
69 DIED_FIRST_TIME, | 71 DIED_FIRST_TIME, |
70 DIED_SECOND_TIME, | 72 DIED_SECOND_TIME, |
71 DIED_THIRD_TIME, | 73 DIED_THIRD_TIME, |
72 DIED_FOURTH_TIME, | 74 DIED_FOURTH_TIME, |
73 GPU_PROCESS_LIFETIME_EVENT_MAX = 100 | 75 GPU_PROCESS_LIFETIME_EVENT_MAX = 100 |
74 }; | 76 }; |
75 | 77 |
76 // Indexed by GpuProcessKind. There is one of each kind maximum. This array may | 78 // Indexed by GpuProcessKind. There is one of each kind maximum. This array may |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 127 } |
126 } | 128 } |
127 | 129 |
128 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
129 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process | 131 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process |
130 // (RenderWidget). | 132 // (RenderWidget). |
131 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( | 133 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( |
132 int surface_id, | 134 int surface_id, |
133 base::TimeTicks timebase, | 135 base::TimeTicks timebase, |
134 base::TimeDelta interval, | 136 base::TimeDelta interval, |
135 const ui::LatencyInfo& latency_info) { | 137 const std::vector<ui::LatencyInfo>& latency_info) { |
136 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 138 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
137 BrowserThread::PostTask( | 139 BrowserThread::PostTask( |
138 BrowserThread::UI, | 140 BrowserThread::UI, |
139 FROM_HERE, | 141 FROM_HERE, |
140 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForRenderer, | 142 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForRenderer, |
141 surface_id, timebase, interval, latency_info)); | 143 surface_id, timebase, interval, latency_info)); |
142 return; | 144 return; |
143 } | 145 } |
144 | 146 |
145 int render_process_id = 0; | 147 int render_process_id = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
160 RenderWidgetHostImpl::From(rwh)->DidReceiveRendererFrame(); | 162 RenderWidgetHostImpl::From(rwh)->DidReceiveRendererFrame(); |
161 } | 163 } |
162 | 164 |
163 void AcceleratedSurfaceBuffersSwappedCompleted( | 165 void AcceleratedSurfaceBuffersSwappedCompleted( |
164 int host_id, | 166 int host_id, |
165 int route_id, | 167 int route_id, |
166 int surface_id, | 168 int surface_id, |
167 bool alive, | 169 bool alive, |
168 base::TimeTicks timebase, | 170 base::TimeTicks timebase, |
169 base::TimeDelta interval, | 171 base::TimeDelta interval, |
170 const ui::LatencyInfo& latency_info) { | 172 const std::vector<ui::LatencyInfo>& latency_info) { |
171 AcceleratedSurfaceBuffersSwappedCompletedForGPU( | 173 AcceleratedSurfaceBuffersSwappedCompletedForGPU( |
172 host_id, route_id, alive, timebase, interval); | 174 host_id, route_id, alive, timebase, interval); |
173 AcceleratedSurfaceBuffersSwappedCompletedForRenderer( | 175 AcceleratedSurfaceBuffersSwappedCompletedForRenderer( |
174 surface_id, timebase, interval, latency_info); | 176 surface_id, timebase, interval, latency_info); |
175 } | 177 } |
176 | 178 |
177 // NOTE: changes to this class need to be reviewed by the security team. | 179 // NOTE: changes to this class need to be reviewed by the security team. |
178 class GpuSandboxedProcessLauncherDelegate | 180 class GpuSandboxedProcessLauncherDelegate |
179 : public SandboxedProcessLauncherDelegate { | 181 : public SandboxedProcessLauncherDelegate { |
180 public: | 182 public: |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 ignore_result(scoped_completion_runner.Release()); | 913 ignore_result(scoped_completion_runner.Release()); |
912 | 914 |
913 ViewHostMsg_CompositorSurfaceBuffersSwapped_Params view_params; | 915 ViewHostMsg_CompositorSurfaceBuffersSwapped_Params view_params; |
914 view_params.surface_id = params.surface_id; | 916 view_params.surface_id = params.surface_id; |
915 view_params.surface_handle = params.surface_handle; | 917 view_params.surface_handle = params.surface_handle; |
916 view_params.route_id = params.route_id; | 918 view_params.route_id = params.route_id; |
917 view_params.size = params.size; | 919 view_params.size = params.size; |
918 view_params.scale_factor = params.scale_factor; | 920 view_params.scale_factor = params.scale_factor; |
919 view_params.gpu_process_host_id = host_id_; | 921 view_params.gpu_process_host_id = host_id_; |
920 view_params.latency_info = params.latency_info; | 922 view_params.latency_info = params.latency_info; |
| 923 if (view_params.latency_info.size() > kMaxLatencyInfoNumber) { |
| 924 for (size_t i = 0; i < view_params.latency_info.size(); i++) |
| 925 view_params.latency_info[i].AddLatencyNumber( |
| 926 ui::LATENCY_INFO_LIST_TERMINATED_OVERFLOW_COMPONENT, 0, 0); |
| 927 view_params.latency_info.clear(); |
| 928 } |
921 helper->DidReceiveBackingStoreMsg(ViewHostMsg_CompositorSurfaceBuffersSwapped( | 929 helper->DidReceiveBackingStoreMsg(ViewHostMsg_CompositorSurfaceBuffersSwapped( |
922 render_widget_id, | 930 render_widget_id, |
923 view_params)); | 931 view_params)); |
924 } | 932 } |
925 #endif // OS_MACOSX | 933 #endif // OS_MACOSX |
926 | 934 |
927 #if defined(OS_WIN) | 935 #if defined(OS_WIN) |
928 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 936 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
929 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 937 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
930 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); | 938 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
931 | 939 |
932 base::ScopedClosureRunner scoped_completion_runner( | 940 base::ScopedClosureRunner scoped_completion_runner( |
933 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, | 941 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, |
934 host_id_, params.route_id, params.surface_id, | 942 host_id_, params.route_id, params.surface_id, |
935 true, base::TimeTicks(), base::TimeDelta(), ui::LatencyInfo())); | 943 true, base::TimeTicks(), base::TimeDelta(), |
| 944 std::vector<ui::LatencyInfo>())); |
936 | 945 |
937 gfx::GLSurfaceHandle handle = | 946 gfx::GLSurfaceHandle handle = |
938 GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id); | 947 GpuSurfaceTracker::Get()->GetSurfaceHandle(params.surface_id); |
939 | 948 |
940 if (handle.is_null()) | 949 if (handle.is_null()) |
941 return; | 950 return; |
942 | 951 |
943 if (handle.transport_type == gfx::TEXTURE_TRANSPORT) { | 952 if (handle.transport_type == gfx::TEXTURE_TRANSPORT) { |
944 TRACE_EVENT1("gpu", "SurfaceIDNotFound_RoutingToUI", | 953 TRACE_EVENT1("gpu", "SurfaceIDNotFound_RoutingToUI", |
945 "surface_id", params.surface_id); | 954 "surface_id", params.surface_id); |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1270 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1262 ClientIdToShaderCacheMap::iterator iter = | 1271 ClientIdToShaderCacheMap::iterator iter = |
1263 client_id_to_shader_cache_.find(client_id); | 1272 client_id_to_shader_cache_.find(client_id); |
1264 // If the cache doesn't exist then this is an off the record profile. | 1273 // If the cache doesn't exist then this is an off the record profile. |
1265 if (iter == client_id_to_shader_cache_.end()) | 1274 if (iter == client_id_to_shader_cache_.end()) |
1266 return; | 1275 return; |
1267 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1276 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1268 } | 1277 } |
1269 | 1278 |
1270 } // namespace content | 1279 } // namespace content |
OLD | NEW |