Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 375863005: Touch emulator: allow multiple touch streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better touch sequence end check Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 original_component.sequence_number, 957 original_component.sequence_number,
958 original_component.event_time, 958 original_component.event_time,
959 original_component.event_count); 959 original_component.event_count);
960 } 960 }
961 } 961 }
962 962
963 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, latency_info); 963 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, latency_info);
964 input_router_->SendGestureEvent(gesture_with_latency); 964 input_router_->SendGestureEvent(gesture_with_latency);
965 } 965 }
966 966
967 void RenderWidgetHostImpl::ForwardTouchEvent( 967 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent(
968 const blink::WebTouchEvent& touch_event) { 968 const blink::WebTouchEvent& touch_event) {
969 ForwardTouchEventWithLatencyInfo(touch_event, ui::LatencyInfo()); 969 ForwardTouchEventWithLatencyInfoFromStream(
970 touch_event, ui::LatencyInfo(), TouchStreamTracker::EMULATED_STREAM);
970 } 971 }
971 972
972 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( 973 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(
973 const blink::WebTouchEvent& touch_event, 974 const blink::WebTouchEvent& touch_event,
974 const ui::LatencyInfo& ui_latency) { 975 const ui::LatencyInfo& ui_latency) {
976 ForwardTouchEventWithLatencyInfoFromStream(
977 touch_event, ui_latency, TouchStreamTracker::NATIVE_STREAM);
978 }
979
980 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfoFromStream(
981 const blink::WebTouchEvent& touch_event,
982 const ui::LatencyInfo& ui_latency,
983 TouchStreamTracker::TouchStream stream) {
975 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); 984 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent");
976 985
977 // Always forward TouchEvents for touch stream consistency. They will be 986 // Always forward TouchEvents from active touch stream for consistency.
978 // ignored if appropriate in FilterInputEvent(). 987 // They will be ignored if appropriate in FilterInputEvent().
979 988
980 ui::LatencyInfo latency_info = 989 ui::LatencyInfo latency_info =
981 CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type); 990 CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type);
982 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); 991 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info);
992
993 if (touch_stream_tracker_) {
994 InputEventAckState ack_result =
995 touch_stream_tracker_->FilterTouchEventFromStream(touch_event, stream);
996 if (ack_result != INPUT_EVENT_ACK_STATE_UNKNOWN) {
997 OnTouchEventAckFromStream(touch_with_latency, ack_result, stream);
998 return;
999 }
1000 }
1001
983 input_router_->SendTouchEvent(touch_with_latency); 1002 input_router_->SendTouchEvent(touch_with_latency);
984 } 1003 }
985 1004
986 void RenderWidgetHostImpl::ForwardKeyboardEvent( 1005 void RenderWidgetHostImpl::ForwardKeyboardEvent(
987 const NativeWebKeyboardEvent& key_event) { 1006 const NativeWebKeyboardEvent& key_event) {
988 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); 1007 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent");
989 if (IgnoreInputEvents()) 1008 if (IgnoreInputEvents())
990 return; 1009 return;
991 1010
992 if (!process_->HasConnection()) 1011 if (!process_->HasConnection())
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) { 1641 void RenderWidgetHostImpl::OnSetCursor(const WebCursor& cursor) {
1623 SetCursor(cursor); 1642 SetCursor(cursor);
1624 } 1643 }
1625 1644
1626 void RenderWidgetHostImpl::OnSetTouchEventEmulationEnabled( 1645 void RenderWidgetHostImpl::OnSetTouchEventEmulationEnabled(
1627 bool enabled, bool allow_pinch) { 1646 bool enabled, bool allow_pinch) {
1628 if (delegate_) 1647 if (delegate_)
1629 delegate_->OnTouchEmulationEnabled(enabled); 1648 delegate_->OnTouchEmulationEnabled(enabled);
1630 1649
1631 if (enabled) { 1650 if (enabled) {
1632 if (!touch_emulator_) 1651 if (!touch_emulator_) {
1652 touch_stream_tracker_.reset(new TouchStreamTracker());
1633 touch_emulator_.reset(new TouchEmulator(this)); 1653 touch_emulator_.reset(new TouchEmulator(this));
1654 }
1634 touch_emulator_->Enable(allow_pinch); 1655 touch_emulator_->Enable(allow_pinch);
1635 } else { 1656 } else {
1636 if (touch_emulator_) 1657 if (touch_emulator_)
1637 touch_emulator_->Disable(); 1658 touch_emulator_->Disable();
1638 } 1659 }
1639 } 1660 }
1640 1661
1641 void RenderWidgetHostImpl::OnTextInputStateChanged( 1662 void RenderWidgetHostImpl::OnTextInputStateChanged(
1642 const ViewHostMsg_TextInputState_Params& params) { 1663 const ViewHostMsg_TextInputState_Params& params) {
1643 if (view_) 1664 if (view_)
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED; 1905 ack_result = INPUT_EVENT_ACK_STATE_CONSUMED;
1885 } 1906 }
1886 1907
1887 if (view_) 1908 if (view_)
1888 view_->GestureEventAck(event.event, ack_result); 1909 view_->GestureEventAck(event.event, ack_result);
1889 } 1910 }
1890 1911
1891 void RenderWidgetHostImpl::OnTouchEventAck( 1912 void RenderWidgetHostImpl::OnTouchEventAck(
1892 const TouchEventWithLatencyInfo& event, 1913 const TouchEventWithLatencyInfo& event,
1893 InputEventAckState ack_result) { 1914 InputEventAckState ack_result) {
1915 TouchStreamTracker::TouchStream stream = TouchStreamTracker::NATIVE_STREAM;
1916 if (touch_stream_tracker_)
1917 stream = touch_stream_tracker_->OnTouchEventAck(event, ack_result);
1918 OnTouchEventAckFromStream(event, ack_result, stream);
1919 }
1920
1921 void RenderWidgetHostImpl::OnTouchEventAckFromStream(
1922 const TouchEventWithLatencyInfo& event,
1923 InputEventAckState ack_result,
1924 TouchStreamTracker::TouchStream stream) {
1894 TouchEventWithLatencyInfo touch_event = event; 1925 TouchEventWithLatencyInfo touch_event = event;
1895 touch_event.latency.AddLatencyNumber( 1926 touch_event.latency.AddLatencyNumber(
1896 ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, 0, 0); 1927 ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, 0, 0);
1897 // TouchEvent latency ends at ack if it didn't cause any rendering. 1928 // TouchEvent latency ends at ack if it didn't cause any rendering.
1898 if (!touch_event.latency.FindLatency( 1929 if (!touch_event.latency.FindLatency(
1899 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { 1930 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) {
1900 touch_event.latency.AddLatencyNumber( 1931 touch_event.latency.AddLatencyNumber(
1901 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); 1932 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0);
1902 } 1933 }
1903 ComputeTouchLatency(touch_event.latency); 1934 ComputeTouchLatency(touch_event.latency);
1904 1935
1905 if (touch_emulator_ && touch_emulator_->HandleTouchEventAck(ack_result)) 1936 if (stream == TouchStreamTracker::EMULATED_STREAM) {
1937 DCHECK(touch_emulator_);
1938 touch_emulator_->HandleTouchEventAck(ack_result);
1906 return; 1939 return;
1940 }
1907 1941
1942 DCHECK(stream == TouchStreamTracker::NATIVE_STREAM);
1908 if (view_) 1943 if (view_)
1909 view_->ProcessAckedTouchEvent(touch_event, ack_result); 1944 view_->ProcessAckedTouchEvent(touch_event, ack_result);
1910 } 1945 }
1911 1946
1912 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { 1947 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) {
1913 if (type == BAD_ACK_MESSAGE) { 1948 if (type == BAD_ACK_MESSAGE) {
1914 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH2")); 1949 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH2"));
1915 process_->ReceivedBadMessage(); 1950 process_->ReceivedBadMessage();
1916 } else if (type == UNEXPECTED_EVENT_TYPE) { 1951 } else if (type == UNEXPECTED_EVENT_TYPE) {
1917 suppress_next_char_events_ = false; 1952 suppress_next_char_events_ = false;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
2387 } 2422 }
2388 } 2423 }
2389 2424
2390 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { 2425 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() {
2391 if (view_) 2426 if (view_)
2392 return view_->PreferredReadbackFormat(); 2427 return view_->PreferredReadbackFormat();
2393 return kN32_SkColorType; 2428 return kN32_SkColorType;
2394 } 2429 }
2395 2430
2396 } // namespace content 2431 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698