| 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 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 DCHECK(!params.bitmap_rect.IsEmpty()); | 1666 DCHECK(!params.bitmap_rect.IsEmpty()); |
| 1667 gfx::Size pixel_size = gfx::ToFlooredSize( | 1667 gfx::Size pixel_size = gfx::ToFlooredSize( |
| 1668 gfx::ScaleSize(params.bitmap_rect.size(), params.scale_factor)); | 1668 gfx::ScaleSize(params.bitmap_rect.size(), params.scale_factor)); |
| 1669 const size_t size = pixel_size.height() * pixel_size.width() * 4; | 1669 const size_t size = pixel_size.height() * pixel_size.width() * 4; |
| 1670 if (dib->size() < size) { | 1670 if (dib->size() < size) { |
| 1671 DLOG(WARNING) << "Transport DIB too small for given rectangle"; | 1671 DLOG(WARNING) << "Transport DIB too small for given rectangle"; |
| 1672 RecordAction(UserMetricsAction("BadMessageTerminate_RWH1")); | 1672 RecordAction(UserMetricsAction("BadMessageTerminate_RWH1")); |
| 1673 GetProcess()->ReceivedBadMessage(); | 1673 GetProcess()->ReceivedBadMessage(); |
| 1674 } else { | 1674 } else { |
| 1675 UNSHIPPED_TRACE_EVENT_INSTANT2("test_latency", "UpdateRect", | 1675 UNSHIPPED_TRACE_EVENT_INSTANT2("test_latency", "UpdateRect", |
| 1676 TRACE_EVENT_SCOPE_THREAD, |
| 1676 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y(), | 1677 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y(), |
| 1677 "color", 0xffffff & *static_cast<uint32*>(dib->memory())); | 1678 "color", 0xffffff & *static_cast<uint32*>(dib->memory())); |
| 1678 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectWidth", | 1679 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectWidth", |
| 1680 TRACE_EVENT_SCOPE_THREAD, |
| 1679 "width", params.bitmap_rect.width()); | 1681 "width", params.bitmap_rect.width()); |
| 1680 | 1682 |
| 1681 // Scroll the backing store. | 1683 // Scroll the backing store. |
| 1682 if (!params.scroll_rect.IsEmpty()) { | 1684 if (!params.scroll_rect.IsEmpty()) { |
| 1683 ScrollBackingStoreRect(params.scroll_delta, | 1685 ScrollBackingStoreRect(params.scroll_delta, |
| 1684 params.scroll_rect, | 1686 params.scroll_rect, |
| 1685 params.view_size); | 1687 params.view_size); |
| 1686 } | 1688 } |
| 1687 | 1689 |
| 1688 // Paint the backing store. This will update it with the | 1690 // Paint the backing store. This will update it with the |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 // Measures the time from receiving the MsgUpdateRect IPC to completing the | 1783 // Measures the time from receiving the MsgUpdateRect IPC to completing the |
| 1782 // DidUpdateBackingStore() method. On platforms which have asynchronous | 1784 // DidUpdateBackingStore() method. On platforms which have asynchronous |
| 1783 // painting, such as Linux, this is the sum of MPArch.RWH_OnMsgUpdateRect, | 1785 // painting, such as Linux, this is the sum of MPArch.RWH_OnMsgUpdateRect, |
| 1784 // MPArch.RWH_DidUpdateBackingStore, and the time spent asynchronously | 1786 // MPArch.RWH_DidUpdateBackingStore, and the time spent asynchronously |
| 1785 // waiting for the paint to complete. | 1787 // waiting for the paint to complete. |
| 1786 // | 1788 // |
| 1787 // On other platforms, this will be equivalent to MPArch.RWH_OnMsgUpdateRect. | 1789 // On other platforms, this will be equivalent to MPArch.RWH_OnMsgUpdateRect. |
| 1788 delta = now - paint_start; | 1790 delta = now - paint_start; |
| 1789 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); | 1791 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); |
| 1790 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectComplete", | 1792 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectComplete", |
| 1793 TRACE_EVENT_SCOPE_THREAD, |
| 1791 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y()); | 1794 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y()); |
| 1792 } | 1795 } |
| 1793 | 1796 |
| 1794 void RenderWidgetHostImpl::OnInputEventAck( | 1797 void RenderWidgetHostImpl::OnInputEventAck( |
| 1795 WebInputEvent::Type event_type, InputEventAckState ack_result) { | 1798 WebInputEvent::Type event_type, InputEventAckState ack_result) { |
| 1796 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnInputEventAck"); | 1799 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnInputEventAck"); |
| 1797 bool processed = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); | 1800 bool processed = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); |
| 1798 | 1801 |
| 1799 if (!in_process_event_types_.empty() && | 1802 if (!in_process_event_types_.empty() && |
| 1800 in_process_event_types_.front() == event_type) | 1803 in_process_event_types_.front() == event_type) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 return; | 1870 return; |
| 1868 if (tick_active_smooth_scroll_gestures_task_posted_) | 1871 if (tick_active_smooth_scroll_gestures_task_posted_) |
| 1869 return; | 1872 return; |
| 1870 TickActiveSmoothScrollGesture(); | 1873 TickActiveSmoothScrollGesture(); |
| 1871 } | 1874 } |
| 1872 | 1875 |
| 1873 void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { | 1876 void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { |
| 1874 TRACE_EVENT0("input", "RenderWidgetHostImpl::TickActiveSmoothScrollGesture"); | 1877 TRACE_EVENT0("input", "RenderWidgetHostImpl::TickActiveSmoothScrollGesture"); |
| 1875 tick_active_smooth_scroll_gestures_task_posted_ = false; | 1878 tick_active_smooth_scroll_gestures_task_posted_ = false; |
| 1876 if (active_smooth_scroll_gestures_.empty()) { | 1879 if (active_smooth_scroll_gestures_.empty()) { |
| 1877 TRACE_EVENT_INSTANT0("input", "EarlyOut_NoActiveScrollGesture"); | 1880 TRACE_EVENT_INSTANT0("input", "EarlyOut_NoActiveScrollGesture", |
| 1881 TRACE_EVENT_SCOPE_THREAD); |
| 1878 return; | 1882 return; |
| 1879 } | 1883 } |
| 1880 | 1884 |
| 1881 base::TimeTicks now = TimeTicks::HighResNow(); | 1885 base::TimeTicks now = TimeTicks::HighResNow(); |
| 1882 base::TimeDelta preferred_interval = | 1886 base::TimeDelta preferred_interval = |
| 1883 base::TimeDelta::FromMilliseconds(kSyntheticScrollMessageIntervalMs); | 1887 base::TimeDelta::FromMilliseconds(kSyntheticScrollMessageIntervalMs); |
| 1884 base::TimeDelta time_until_next_ideal_interval = | 1888 base::TimeDelta time_until_next_ideal_interval = |
| 1885 (last_smooth_scroll_gestures_tick_time_ + preferred_interval) - | 1889 (last_smooth_scroll_gestures_tick_time_ + preferred_interval) - |
| 1886 now; | 1890 now; |
| 1887 if (time_until_next_ideal_interval.InMilliseconds() > 0) { | 1891 if (time_until_next_ideal_interval.InMilliseconds() > 0) { |
| 1888 TRACE_EVENT_INSTANT1( | 1892 TRACE_EVENT_INSTANT1( |
| 1889 "input", "EarlyOut_TickedTooRecently", | 1893 "input", "EarlyOut_TickedTooRecently", TRACE_EVENT_SCOPE_THREAD, |
| 1890 "delay", time_until_next_ideal_interval.InMilliseconds()); | 1894 "delay", time_until_next_ideal_interval.InMilliseconds()); |
| 1891 // Post a task. | 1895 // Post a task. |
| 1892 tick_active_smooth_scroll_gestures_task_posted_ = true; | 1896 tick_active_smooth_scroll_gestures_task_posted_ = true; |
| 1893 MessageLoop::current()->PostDelayedTask( | 1897 MessageLoop::current()->PostDelayedTask( |
| 1894 FROM_HERE, | 1898 FROM_HERE, |
| 1895 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, | 1899 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, |
| 1896 weak_factory_.GetWeakPtr()), | 1900 weak_factory_.GetWeakPtr()), |
| 1897 time_until_next_ideal_interval); | 1901 time_until_next_ideal_interval); |
| 1898 return; | 1902 return; |
| 1899 } | 1903 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1920 DCHECK(it != active_smooth_scroll_gestures_.end()); | 1924 DCHECK(it != active_smooth_scroll_gestures_.end()); |
| 1921 active_smooth_scroll_gestures_.erase(it); | 1925 active_smooth_scroll_gestures_.erase(it); |
| 1922 | 1926 |
| 1923 Send(new ViewMsg_SmoothScrollCompleted(routing_id_, id)); | 1927 Send(new ViewMsg_SmoothScrollCompleted(routing_id_, id)); |
| 1924 } | 1928 } |
| 1925 | 1929 |
| 1926 // No need to post the next tick if an input is in flight. | 1930 // No need to post the next tick if an input is in flight. |
| 1927 if (!in_process_event_types_.empty()) | 1931 if (!in_process_event_types_.empty()) |
| 1928 return; | 1932 return; |
| 1929 | 1933 |
| 1930 TRACE_EVENT_INSTANT1("input", "PostTickTask", | 1934 TRACE_EVENT_INSTANT1("input", "PostTickTask", TRACE_EVENT_SCOPE_THREAD, |
| 1931 "delay", preferred_interval.InMilliseconds()); | 1935 "delay", preferred_interval.InMilliseconds()); |
| 1932 tick_active_smooth_scroll_gestures_task_posted_ = true; | 1936 tick_active_smooth_scroll_gestures_task_posted_ = true; |
| 1933 MessageLoop::current()->PostDelayedTask( | 1937 MessageLoop::current()->PostDelayedTask( |
| 1934 FROM_HERE, | 1938 FROM_HERE, |
| 1935 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, | 1939 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, |
| 1936 weak_factory_.GetWeakPtr()), | 1940 weak_factory_.GetWeakPtr()), |
| 1937 preferred_interval); | 1941 preferred_interval); |
| 1938 } | 1942 } |
| 1939 | 1943 |
| 1940 void RenderWidgetHostImpl::OnSelectRangeAck() { | 1944 void RenderWidgetHostImpl::OnSelectRangeAck() { |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2464 return; | 2468 return; |
| 2465 | 2469 |
| 2466 OnRenderAutoResized(new_size); | 2470 OnRenderAutoResized(new_size); |
| 2467 } | 2471 } |
| 2468 | 2472 |
| 2469 void RenderWidgetHostImpl::DetachDelegate() { | 2473 void RenderWidgetHostImpl::DetachDelegate() { |
| 2470 delegate_ = NULL; | 2474 delegate_ = NULL; |
| 2471 } | 2475 } |
| 2472 | 2476 |
| 2473 } // namespace content | 2477 } // namespace content |
| OLD | NEW |