| 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 CHECK(params.latency_info.size() < kMaxLatencyInfoNumber); |
| 1472 if (!view_) { | 1477 if (!view_) { |
| 1473 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 1478 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 1474 ack_params.sync_point = 0; | 1479 ack_params.sync_point = 0; |
| 1475 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, | 1480 RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, |
| 1476 params.gpu_process_host_id, | 1481 params.gpu_process_host_id, |
| 1477 ack_params); | 1482 ack_params); |
| 1478 return; | 1483 return; |
| 1479 } | 1484 } |
| 1480 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params gpu_params; | 1485 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params gpu_params; |
| 1481 gpu_params.surface_id = params.surface_id; | 1486 gpu_params.surface_id = params.surface_id; |
| (...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 return; | 2448 return; |
| 2444 } | 2449 } |
| 2445 } | 2450 } |
| 2446 | 2451 |
| 2447 Send(new ViewMsg_WindowSnapshotCompleted( | 2452 Send(new ViewMsg_WindowSnapshotCompleted( |
| 2448 GetRoutingID(), snapshot_id, gfx::Size(), png)); | 2453 GetRoutingID(), snapshot_id, gfx::Size(), png)); |
| 2449 } | 2454 } |
| 2450 | 2455 |
| 2451 // static | 2456 // static |
| 2452 void RenderWidgetHostImpl::CompositorFrameDrawn( | 2457 void RenderWidgetHostImpl::CompositorFrameDrawn( |
| 2453 const ui::LatencyInfo& latency_info) { | 2458 const std::vector<ui::LatencyInfo>& latency_info) { |
| 2454 std::set<RenderWidgetHostImpl*> rwhi_set; | 2459 for (size_t i = 0; i < latency_info.size(); i++) { |
| 2455 | 2460 std::set<RenderWidgetHostImpl*> rwhi_set; |
| 2456 for (ui::LatencyInfo::LatencyMap::const_iterator b = | 2461 for (ui::LatencyInfo::LatencyMap::const_iterator b = |
| 2457 latency_info.latency_components.begin(); | 2462 latency_info[i].latency_components.begin(); |
| 2458 b != latency_info.latency_components.end(); | 2463 b != latency_info[i].latency_components.end(); |
| 2459 ++b) { | 2464 ++b) { |
| 2460 if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || | 2465 if (b->first.first == ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT || |
| 2461 b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { | 2466 b->first.first == ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT) { |
| 2462 // Matches with GetLatencyComponentId | 2467 // Matches with GetLatencyComponentId |
| 2463 int routing_id = b->first.second & 0xffffffff; | 2468 int routing_id = b->first.second & 0xffffffff; |
| 2464 int process_id = (b->first.second >> 32) & 0xffffffff; | 2469 int process_id = (b->first.second >> 32) & 0xffffffff; |
| 2465 RenderWidgetHost* rwh = | 2470 RenderWidgetHost* rwh = |
| 2466 RenderWidgetHost::FromID(process_id, routing_id); | 2471 RenderWidgetHost::FromID(process_id, routing_id); |
| 2467 if (!rwh) { | 2472 if (!rwh) { |
| 2468 continue; | 2473 continue; |
| 2474 } |
| 2475 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); |
| 2476 if (rwhi_set.insert(rwhi).second) |
| 2477 rwhi->FrameSwapped(latency_info[i]); |
| 2469 } | 2478 } |
| 2470 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); | |
| 2471 if (rwhi_set.insert(rwhi).second) | |
| 2472 rwhi->FrameSwapped(latency_info); | |
| 2473 } | 2479 } |
| 2474 } | 2480 } |
| 2475 } | 2481 } |
| 2476 | 2482 |
| 2477 } // namespace content | 2483 } // namespace content |
| OLD | NEW |