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/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 namespace { | 88 namespace { |
89 | 89 |
90 bool g_check_for_pending_resize_ack = true; | 90 bool g_check_for_pending_resize_ack = true; |
91 | 91 |
92 // How long to (synchronously) wait for the renderer to respond with a | 92 // How long to (synchronously) wait for the renderer to respond with a |
93 // PaintRect message, when our backing-store is invalid, before giving up and | 93 // PaintRect message, when our backing-store is invalid, before giving up and |
94 // returning a null or incorrectly sized backing-store from GetBackingStore. | 94 // returning a null or incorrectly sized backing-store from GetBackingStore. |
95 // This timeout impacts the "choppiness" of our window resize perf. | 95 // This timeout impacts the "choppiness" of our window resize perf. |
96 const int kPaintMsgTimeoutMS = 50; | 96 const int kPaintMsgTimeoutMS = 50; |
97 | 97 |
| 98 // Maximal number of LatencyInfo that can be contained in |
| 99 // ViewHostMsg_CompositorSurfaceBuffersSwapped_Params. |
| 100 const unsigned int kMaxLatencyInfoNumber = 100; |
| 101 |
98 typedef std::pair<int32, int32> RenderWidgetHostID; | 102 typedef std::pair<int32, int32> RenderWidgetHostID; |
99 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> | 103 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> |
100 RoutingIDWidgetMap; | 104 RoutingIDWidgetMap; |
101 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = | 105 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = |
102 LAZY_INSTANCE_INITIALIZER; | 106 LAZY_INSTANCE_INITIALIZER; |
103 | 107 |
104 // Implements the RenderWidgetHostIterator interface. It keeps a list of | 108 // Implements the RenderWidgetHostIterator interface. It keeps a list of |
105 // RenderWidgetHosts, and makes sure it returns a live RenderWidgetHost at each | 109 // RenderWidgetHosts, and makes sure it returns a live RenderWidgetHost at each |
106 // iteration (or NULL if there isn't any left). | 110 // iteration (or NULL if there isn't any left). |
107 class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator { | 111 class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator { |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1462 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK, | 1466 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_PAINT_AT_SIZE_ACK, |
1463 Source<RenderWidgetHost>(this), | 1467 Source<RenderWidgetHost>(this), |
1464 Details<std::pair<int, gfx::Size> >(&details)); | 1468 Details<std::pair<int, gfx::Size> >(&details)); |
1465 } | 1469 } |
1466 | 1470 |
1467 #if defined(OS_MACOSX) | 1471 #if defined(OS_MACOSX) |
1468 void RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwapped( | 1472 void RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwapped( |
1469 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { | 1473 const ViewHostMsg_CompositorSurfaceBuffersSwapped_Params& params) { |
1470 TRACE_EVENT0("renderer_host", | 1474 TRACE_EVENT0("renderer_host", |
1471 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwapped"); | 1475 "RenderWidgetHostImpl::OnCompositorSurfaceBuffersSwapped"); |
| 1476 if (params.latency_info.size() > kMaxLatencyInfoNumber) { |
| 1477 LOG(ERROR) << "ViewHostMsg_CompositorSurfaceBuffersSwapped LatencyInfo" |
| 1478 << " size " << params.latency_info.size() << " is too big."; |
| 1479 return; |
| 1480 } |
1472 if (!view_) { | 1481 if (!view_) { |
1473 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 1482 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
1474 ack_params.sync_point = 0; | 1483 ack_params.sync_point = 0; |
1475 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, | 1484 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, |
1476 params.gpu_process_host_id, | 1485 params.gpu_process_host_id, |
1477 ack_params); | 1486 ack_params); |
1478 return; | 1487 return; |
1479 } | 1488 } |
1480 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params gpu_params; | 1489 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params gpu_params; |
1481 gpu_params.surface_id = params.surface_id; | 1490 gpu_params.surface_id = params.surface_id; |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2443 return; | 2452 return; |
2444 } | 2453 } |
2445 } | 2454 } |
2446 | 2455 |
2447 Send(new ViewMsg_WindowSnapshotCompleted( | 2456 Send(new ViewMsg_WindowSnapshotCompleted( |
2448 GetRoutingID(), snapshot_id, gfx::Size(), png)); | 2457 GetRoutingID(), snapshot_id, gfx::Size(), png)); |
2449 } | 2458 } |
2450 | 2459 |
2451 // static | 2460 // static |
2452 void RenderWidgetHostImpl::CompositorFrameDrawn( | 2461 void RenderWidgetHostImpl::CompositorFrameDrawn( |
2453 const ui::LatencyInfo& latency_info) { | 2462 const std::vector<ui::LatencyInfo>& latency_info) { |
2454 std::set<RenderWidgetHostImpl*> rwhi_set; | 2463 for (size_t i = 0; i < latency_info.size(); i++) { |
2455 | 2464 std::set<RenderWidgetHostImpl*> rwhi_set; |
2456 for (ui::LatencyInfo::LatencyMap::const_iterator b = | 2465 for (ui::LatencyInfo::LatencyMap::const_iterator b = |
2457 latency_info.latency_components.begin(); | 2466 latency_info[i].latency_components.begin(); |
2458 b != latency_info.latency_components.end(); | 2467 b != latency_info[i].latency_components.end(); |
2459 ++b) { | 2468 ++b) { |
2460 if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || | 2469 if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || |
2461 b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { | 2470 b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { |
2462 // Matches with GetLatencyComponentId | 2471 // Matches with GetLatencyComponentId |
2463 int routing_id = b->first.second & 0xffffffff; | 2472 int routing_id = b->first.second & 0xffffffff; |
2464 int process_id = (b->first.second >> 32) & 0xffffffff; | 2473 int process_id = (b->first.second >> 32) & 0xffffffff; |
2465 RenderWidgetHost* rwh = | 2474 RenderWidgetHost* rwh = |
2466 RenderWidgetHost::FromID(process_id, routing_id); | 2475 RenderWidgetHost::FromID(process_id, routing_id); |
2467 if (!rwh) { | 2476 if (!rwh) { |
2468 continue; | 2477 continue; |
| 2478 } |
| 2479 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); |
| 2480 if (rwhi_set.insert(rwhi).second) |
| 2481 rwhi->FrameSwapped(latency_info[i]); |
2469 } | 2482 } |
2470 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); | |
2471 if (rwhi_set.insert(rwhi).second) | |
2472 rwhi->FrameSwapped(latency_info); | |
2473 } | 2483 } |
2474 } | 2484 } |
2475 } | 2485 } |
2476 | 2486 |
2477 } // namespace content | 2487 } // namespace content |
OLD | NEW |