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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 typedef std::pair<int32, int32> RenderWidgetHostID; | 98 typedef std::pair<int32, int32> RenderWidgetHostID; |
99 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> | 99 typedef base::hash_map<RenderWidgetHostID, RenderWidgetHostImpl*> |
100 RoutingIDWidgetMap; | 100 RoutingIDWidgetMap; |
101 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = | 101 base::LazyInstance<RoutingIDWidgetMap> g_routing_id_widget_map = |
102 LAZY_INSTANCE_INITIALIZER; | 102 LAZY_INSTANCE_INITIALIZER; |
103 | 103 |
104 int GetInputRouterViewFlagsFromCompositorFrameMetadata( | |
105 const cc::CompositorFrameMetadata metadata) { | |
106 int view_flags = InputRouter::VIEW_FLAGS_NONE; | |
107 | |
108 if (metadata.min_page_scale_factor == metadata.max_page_scale_factor) | |
109 view_flags |= InputRouter::FIXED_PAGE_SCALE; | |
110 | |
111 float window_width_dip = | |
112 metadata.page_scale_factor * metadata.viewport_size.width(); | |
113 if (metadata.root_layer_size.width() <= window_width_dip) | |
Xianzhu
2014/01/14 21:54:19
Can we simply skip timeout for all pages with view
jdduke (slow)
2014/01/14 21:56:38
Where do we get that data?
Xianzhu
2014/01/14 23:56:18
My fault. I thought it is available in the metadat
johnme
2014/01/15 02:15:09
No, many desktop sites have viewport tags like <me
| |
114 view_flags |= InputRouter::MOBILE_VIEWPORT; | |
115 | |
116 return view_flags; | |
Xianzhu
2014/01/14 21:54:19
Will the individual bits of view_flags be meaningf
jdduke (slow)
2014/01/14 21:56:38
Currently, no, it's only useful for the ack timeou
| |
117 } | |
118 | |
104 // Implements the RenderWidgetHostIterator interface. It keeps a list of | 119 // Implements the RenderWidgetHostIterator interface. It keeps a list of |
105 // RenderWidgetHosts, and makes sure it returns a live RenderWidgetHost at each | 120 // RenderWidgetHosts, and makes sure it returns a live RenderWidgetHost at each |
106 // iteration (or NULL if there isn't any left). | 121 // iteration (or NULL if there isn't any left). |
107 class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator { | 122 class RenderWidgetHostIteratorImpl : public RenderWidgetHostIterator { |
108 public: | 123 public: |
109 RenderWidgetHostIteratorImpl() | 124 RenderWidgetHostIteratorImpl() |
110 : current_index_(0) { | 125 : current_index_(0) { |
111 } | 126 } |
112 | 127 |
113 virtual ~RenderWidgetHostIteratorImpl() { | 128 virtual ~RenderWidgetHostIteratorImpl() { |
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1492 | 1507 |
1493 bool RenderWidgetHostImpl::OnSwapCompositorFrame( | 1508 bool RenderWidgetHostImpl::OnSwapCompositorFrame( |
1494 const IPC::Message& message) { | 1509 const IPC::Message& message) { |
1495 ViewHostMsg_SwapCompositorFrame::Param param; | 1510 ViewHostMsg_SwapCompositorFrame::Param param; |
1496 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, ¶m)) | 1511 if (!ViewHostMsg_SwapCompositorFrame::Read(&message, ¶m)) |
1497 return false; | 1512 return false; |
1498 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); | 1513 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); |
1499 uint32 output_surface_id = param.a; | 1514 uint32 output_surface_id = param.a; |
1500 param.b.AssignTo(frame.get()); | 1515 param.b.AssignTo(frame.get()); |
1501 | 1516 |
1502 bool fixed_page_scale = | 1517 input_router_->OnViewUpdated( |
1503 frame->metadata.min_page_scale_factor == | 1518 GetInputRouterViewFlagsFromCompositorFrameMetadata(frame->metadata)); |
1504 frame->metadata.max_page_scale_factor; | |
1505 int updated_view_flags = fixed_page_scale ? InputRouter::FIXED_PAGE_SCALE | |
1506 : InputRouter::VIEW_FLAGS_NONE; | |
1507 input_router_->OnViewUpdated(updated_view_flags); | |
1508 | 1519 |
1509 if (view_) { | 1520 if (view_) { |
1510 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); | 1521 view_->OnSwapCompositorFrame(output_surface_id, frame.Pass()); |
1511 view_->DidReceiveRendererFrame(); | 1522 view_->DidReceiveRendererFrame(); |
1512 } else { | 1523 } else { |
1513 cc::CompositorFrameAck ack; | 1524 cc::CompositorFrameAck ack; |
1514 if (frame->gl_frame_data) { | 1525 if (frame->gl_frame_data) { |
1515 ack.gl_frame_data = frame->gl_frame_data.Pass(); | 1526 ack.gl_frame_data = frame->gl_frame_data.Pass(); |
1516 ack.gl_frame_data->sync_point = 0; | 1527 ack.gl_frame_data->sync_point = 0; |
1517 } else if (frame->delegated_frame_data) { | 1528 } else if (frame->delegated_frame_data) { |
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2468 continue; | 2479 continue; |
2469 } | 2480 } |
2470 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); | 2481 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); |
2471 if (rwhi_set.insert(rwhi).second) | 2482 if (rwhi_set.insert(rwhi).second) |
2472 rwhi->FrameSwapped(latency_info); | 2483 rwhi->FrameSwapped(latency_info); |
2473 } | 2484 } |
2474 } | 2485 } |
2475 } | 2486 } |
2476 | 2487 |
2477 } // namespace content | 2488 } // namespace content |
OLD | NEW |