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_ui_shim.h" | 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 // One of the linux specific headers defines this as a macro. | 34 // One of the linux specific headers defines this as a macro. |
35 #ifdef DestroyAll | 35 #ifdef DestroyAll |
36 #undef DestroyAll | 36 #undef DestroyAll |
37 #endif | 37 #endif |
38 | 38 |
| 39 const unsigned int kMaxLatencyInfoNumber = 100; |
| 40 |
39 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = | 41 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = |
40 LAZY_INSTANCE_INITIALIZER; | 42 LAZY_INSTANCE_INITIALIZER; |
41 | 43 |
42 void SendOnIOThreadTask(int host_id, IPC::Message* msg) { | 44 void SendOnIOThreadTask(int host_id, IPC::Message* msg) { |
43 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 45 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
44 if (host) | 46 if (host) |
45 host->Send(msg); | 47 host->Send(msg); |
46 else | 48 else |
47 delete msg; | 49 delete msg; |
48 } | 50 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 GetRenderWidgetHostViewFromSurfaceID(surface_id); | 279 GetRenderWidgetHostViewFromSurfaceID(surface_id); |
278 if (!view) | 280 if (!view) |
279 return; | 281 return; |
280 view->AcceleratedSurfaceInitialized(host_id_, route_id); | 282 view->AcceleratedSurfaceInitialized(host_id_, route_id); |
281 } | 283 } |
282 | 284 |
283 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 285 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
284 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 286 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
285 TRACE_EVENT0("renderer", | 287 TRACE_EVENT0("renderer", |
286 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 288 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
| 289 if (params.latency_info.size() > kMaxLatencyInfoNumber) { |
| 290 LOG(ERROR) << "GpuHostMsg_AcceleratedSurfaceBuffersSwapped LatencyInfo" |
| 291 << " size " << params.latency_info.size() << " is too big."; |
| 292 return; |
| 293 } |
287 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 294 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
288 ack_params.mailbox_name = params.mailbox_name; | 295 ack_params.mailbox_name = params.mailbox_name; |
289 ack_params.sync_point = 0; | 296 ack_params.sync_point = 0; |
290 ScopedSendOnIOThread delayed_send( | 297 ScopedSendOnIOThread delayed_send( |
291 host_id_, | 298 host_id_, |
292 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, | 299 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, |
293 ack_params)); | 300 ack_params)); |
294 | 301 |
295 if (!params.mailbox_name.empty() && | 302 if (!params.mailbox_name.empty() && |
296 params.mailbox_name.length() != GL_MAILBOX_SIZE_CHROMIUM) | 303 params.mailbox_name.length() != GL_MAILBOX_SIZE_CHROMIUM) |
297 return; | 304 return; |
298 | 305 |
299 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( | 306 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( |
300 params.surface_id); | 307 params.surface_id); |
301 if (!view) | 308 if (!view) |
302 return; | 309 return; |
303 | 310 |
304 delayed_send.Cancel(); | 311 delayed_send.Cancel(); |
305 | 312 |
306 static const base::TimeDelta swap_delay = GetSwapDelay(); | 313 static const base::TimeDelta swap_delay = GetSwapDelay(); |
307 if (swap_delay.ToInternalValue()) | 314 if (swap_delay.ToInternalValue()) |
308 base::PlatformThread::Sleep(swap_delay); | 315 base::PlatformThread::Sleep(swap_delay); |
309 | 316 |
310 // View must send ACK message after next composite. | 317 // View must send ACK message after next composite. |
311 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); | 318 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); |
312 view->DidReceiveRendererFrame(); | 319 view->DidReceiveRendererFrame(); |
313 } | 320 } |
314 | 321 |
315 void GpuProcessHostUIShim::OnFrameDrawn(const ui::LatencyInfo& latency_info) { | 322 void GpuProcessHostUIShim::OnFrameDrawn( |
| 323 const std::vector<ui::LatencyInfo>& latency_info) { |
| 324 if (latency_info.size() > kMaxLatencyInfoNumber) { |
| 325 LOG(ERROR) << "GpuProcessHostUIShim::OnFrameDrawn LatencyInfo" |
| 326 << " size " << latency_info.size() << " is too big."; |
| 327 return; |
| 328 } |
316 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); | 329 RenderWidgetHostImpl::CompositorFrameDrawn(latency_info); |
317 } | 330 } |
318 | 331 |
319 void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( | 332 void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( |
320 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { | 333 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { |
321 TRACE_EVENT0("renderer", | 334 TRACE_EVENT0("renderer", |
322 "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); | 335 "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); |
323 | 336 if (params.latency_info.size() > kMaxLatencyInfoNumber) { |
| 337 LOG(ERROR) << "GpuHostMsg_AcceleratedSurfacePostSubBuffer LatencyInfo" |
| 338 << " size " << params.latency_info.size() << " is too big."; |
| 339 return; |
| 340 } |
324 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 341 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
325 ack_params.mailbox_name = params.mailbox_name; | 342 ack_params.mailbox_name = params.mailbox_name; |
326 ack_params.sync_point = 0; | 343 ack_params.sync_point = 0; |
327 ScopedSendOnIOThread delayed_send( | 344 ScopedSendOnIOThread delayed_send( |
328 host_id_, | 345 host_id_, |
329 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, | 346 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, |
330 ack_params)); | 347 ack_params)); |
331 | 348 |
332 if (!params.mailbox_name.empty() && | 349 if (!params.mailbox_name.empty() && |
333 params.mailbox_name.length() != GL_MAILBOX_SIZE_CHROMIUM) | 350 params.mailbox_name.length() != GL_MAILBOX_SIZE_CHROMIUM) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 view->AcceleratedSurfaceRelease(); | 383 view->AcceleratedSurfaceRelease(); |
367 } | 384 } |
368 | 385 |
369 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 386 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
370 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 387 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
371 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 388 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
372 video_memory_usage_stats); | 389 video_memory_usage_stats); |
373 } | 390 } |
374 | 391 |
375 } // namespace content | 392 } // namespace content |
OLD | NEW |