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 <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 DCHECK(!params.bitmap_rect.IsEmpty()); | 1629 DCHECK(!params.bitmap_rect.IsEmpty()); |
1630 gfx::Size pixel_size = gfx::ToFlooredSize( | 1630 gfx::Size pixel_size = gfx::ToFlooredSize( |
1631 gfx::ScaleSize(params.bitmap_rect.size(), params.scale_factor)); | 1631 gfx::ScaleSize(params.bitmap_rect.size(), params.scale_factor)); |
1632 const size_t size = pixel_size.height() * pixel_size.width() * 4; | 1632 const size_t size = pixel_size.height() * pixel_size.width() * 4; |
1633 if (dib->size() < size) { | 1633 if (dib->size() < size) { |
1634 DLOG(WARNING) << "Transport DIB too small for given rectangle"; | 1634 DLOG(WARNING) << "Transport DIB too small for given rectangle"; |
1635 RecordAction(UserMetricsAction("BadMessageTerminate_RWH1")); | 1635 RecordAction(UserMetricsAction("BadMessageTerminate_RWH1")); |
1636 GetProcess()->ReceivedBadMessage(); | 1636 GetProcess()->ReceivedBadMessage(); |
1637 } else { | 1637 } else { |
1638 UNSHIPPED_TRACE_EVENT_INSTANT2("test_latency", "UpdateRect", | 1638 UNSHIPPED_TRACE_EVENT_INSTANT2("test_latency", "UpdateRect", |
| 1639 TRACE_EVENT_SCOPE_THREAD, |
1639 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y(), | 1640 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y(), |
1640 "color", 0xffffff & *static_cast<uint32*>(dib->memory())); | 1641 "color", 0xffffff & *static_cast<uint32*>(dib->memory())); |
1641 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectWidth", | 1642 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectWidth", |
| 1643 TRACE_EVENT_SCOPE_THREAD, |
1642 "width", params.bitmap_rect.width()); | 1644 "width", params.bitmap_rect.width()); |
1643 | 1645 |
1644 // Scroll the backing store. | 1646 // Scroll the backing store. |
1645 if (!params.scroll_rect.IsEmpty()) { | 1647 if (!params.scroll_rect.IsEmpty()) { |
1646 ScrollBackingStoreRect(params.scroll_delta, | 1648 ScrollBackingStoreRect(params.scroll_delta, |
1647 params.scroll_rect, | 1649 params.scroll_rect, |
1648 params.view_size); | 1650 params.view_size); |
1649 } | 1651 } |
1650 | 1652 |
1651 // Paint the backing store. This will update it with the | 1653 // Paint the backing store. This will update it with the |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 // Measures the time from receiving the MsgUpdateRect IPC to completing the | 1746 // Measures the time from receiving the MsgUpdateRect IPC to completing the |
1745 // DidUpdateBackingStore() method. On platforms which have asynchronous | 1747 // DidUpdateBackingStore() method. On platforms which have asynchronous |
1746 // painting, such as Linux, this is the sum of MPArch.RWH_OnMsgUpdateRect, | 1748 // painting, such as Linux, this is the sum of MPArch.RWH_OnMsgUpdateRect, |
1747 // MPArch.RWH_DidUpdateBackingStore, and the time spent asynchronously | 1749 // MPArch.RWH_DidUpdateBackingStore, and the time spent asynchronously |
1748 // waiting for the paint to complete. | 1750 // waiting for the paint to complete. |
1749 // | 1751 // |
1750 // On other platforms, this will be equivalent to MPArch.RWH_OnMsgUpdateRect. | 1752 // On other platforms, this will be equivalent to MPArch.RWH_OnMsgUpdateRect. |
1751 delta = now - paint_start; | 1753 delta = now - paint_start; |
1752 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); | 1754 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); |
1753 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectComplete", | 1755 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectComplete", |
| 1756 TRACE_EVENT_SCOPE_THREAD, |
1754 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y()); | 1757 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y()); |
1755 } | 1758 } |
1756 | 1759 |
1757 void RenderWidgetHostImpl::OnInputEventAck( | 1760 void RenderWidgetHostImpl::OnInputEventAck( |
1758 WebInputEvent::Type event_type, InputEventAckState ack_result) { | 1761 WebInputEvent::Type event_type, InputEventAckState ack_result) { |
1759 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnInputEventAck"); | 1762 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnInputEventAck"); |
1760 bool processed = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); | 1763 bool processed = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); |
1761 | 1764 |
1762 if (!in_process_event_types_.empty() && | 1765 if (!in_process_event_types_.empty() && |
1763 in_process_event_types_.front() == event_type) | 1766 in_process_event_types_.front() == event_type) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 return; | 1833 return; |
1831 if (tick_active_smooth_scroll_gestures_task_posted_) | 1834 if (tick_active_smooth_scroll_gestures_task_posted_) |
1832 return; | 1835 return; |
1833 TickActiveSmoothScrollGesture(); | 1836 TickActiveSmoothScrollGesture(); |
1834 } | 1837 } |
1835 | 1838 |
1836 void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { | 1839 void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { |
1837 TRACE_EVENT0("input", "RenderWidgetHostImpl::TickActiveSmoothScrollGesture"); | 1840 TRACE_EVENT0("input", "RenderWidgetHostImpl::TickActiveSmoothScrollGesture"); |
1838 tick_active_smooth_scroll_gestures_task_posted_ = false; | 1841 tick_active_smooth_scroll_gestures_task_posted_ = false; |
1839 if (active_smooth_scroll_gestures_.empty()) { | 1842 if (active_smooth_scroll_gestures_.empty()) { |
1840 TRACE_EVENT_INSTANT0("input", "EarlyOut_NoActiveScrollGesture"); | 1843 TRACE_EVENT_INSTANT0("input", "EarlyOut_NoActiveScrollGesture", |
| 1844 TRACE_EVENT_SCOPE_THREAD); |
1841 return; | 1845 return; |
1842 } | 1846 } |
1843 | 1847 |
1844 base::TimeTicks now = TimeTicks::HighResNow(); | 1848 base::TimeTicks now = TimeTicks::HighResNow(); |
1845 base::TimeDelta preferred_interval = | 1849 base::TimeDelta preferred_interval = |
1846 base::TimeDelta::FromMilliseconds(kSyntheticScrollMessageIntervalMs); | 1850 base::TimeDelta::FromMilliseconds(kSyntheticScrollMessageIntervalMs); |
1847 base::TimeDelta time_until_next_ideal_interval = | 1851 base::TimeDelta time_until_next_ideal_interval = |
1848 (last_smooth_scroll_gestures_tick_time_ + preferred_interval) - | 1852 (last_smooth_scroll_gestures_tick_time_ + preferred_interval) - |
1849 now; | 1853 now; |
1850 if (time_until_next_ideal_interval.InMilliseconds() > 0) { | 1854 if (time_until_next_ideal_interval.InMilliseconds() > 0) { |
1851 TRACE_EVENT_INSTANT1( | 1855 TRACE_EVENT_INSTANT1( |
1852 "input", "EarlyOut_TickedTooRecently", | 1856 "input", "EarlyOut_TickedTooRecently", TRACE_EVENT_SCOPE_THREAD, |
1853 "delay", time_until_next_ideal_interval.InMilliseconds()); | 1857 "delay", time_until_next_ideal_interval.InMilliseconds()); |
1854 // Post a task. | 1858 // Post a task. |
1855 tick_active_smooth_scroll_gestures_task_posted_ = true; | 1859 tick_active_smooth_scroll_gestures_task_posted_ = true; |
1856 MessageLoop::current()->PostDelayedTask( | 1860 MessageLoop::current()->PostDelayedTask( |
1857 FROM_HERE, | 1861 FROM_HERE, |
1858 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, | 1862 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, |
1859 weak_factory_.GetWeakPtr()), | 1863 weak_factory_.GetWeakPtr()), |
1860 time_until_next_ideal_interval); | 1864 time_until_next_ideal_interval); |
1861 return; | 1865 return; |
1862 } | 1866 } |
(...skipping 20 matching lines...) Expand all Loading... |
1883 DCHECK(it != active_smooth_scroll_gestures_.end()); | 1887 DCHECK(it != active_smooth_scroll_gestures_.end()); |
1884 active_smooth_scroll_gestures_.erase(it); | 1888 active_smooth_scroll_gestures_.erase(it); |
1885 | 1889 |
1886 Send(new ViewMsg_SmoothScrollCompleted(routing_id_, id)); | 1890 Send(new ViewMsg_SmoothScrollCompleted(routing_id_, id)); |
1887 } | 1891 } |
1888 | 1892 |
1889 // No need to post the next tick if an input is in flight. | 1893 // No need to post the next tick if an input is in flight. |
1890 if (!in_process_event_types_.empty()) | 1894 if (!in_process_event_types_.empty()) |
1891 return; | 1895 return; |
1892 | 1896 |
1893 TRACE_EVENT_INSTANT1("input", "PostTickTask", | 1897 TRACE_EVENT_INSTANT1("input", "PostTickTask", TRACE_EVENT_SCOPE_THREAD, |
1894 "delay", preferred_interval.InMilliseconds()); | 1898 "delay", preferred_interval.InMilliseconds()); |
1895 tick_active_smooth_scroll_gestures_task_posted_ = true; | 1899 tick_active_smooth_scroll_gestures_task_posted_ = true; |
1896 MessageLoop::current()->PostDelayedTask( | 1900 MessageLoop::current()->PostDelayedTask( |
1897 FROM_HERE, | 1901 FROM_HERE, |
1898 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, | 1902 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, |
1899 weak_factory_.GetWeakPtr()), | 1903 weak_factory_.GetWeakPtr()), |
1900 preferred_interval); | 1904 preferred_interval); |
1901 } | 1905 } |
1902 | 1906 |
1903 void RenderWidgetHostImpl::OnSelectRangeAck() { | 1907 void RenderWidgetHostImpl::OnSelectRangeAck() { |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2430 return; | 2434 return; |
2431 | 2435 |
2432 OnRenderAutoResized(new_size); | 2436 OnRenderAutoResized(new_size); |
2433 } | 2437 } |
2434 | 2438 |
2435 void RenderWidgetHostImpl::DetachDelegate() { | 2439 void RenderWidgetHostImpl::DetachDelegate() { |
2436 delegate_ = NULL; | 2440 delegate_ = NULL; |
2437 } | 2441 } |
2438 | 2442 |
2439 } // namespace content | 2443 } // namespace content |
OLD | NEW |