OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/render_widget_host_view_views.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h" | 8 #include "chrome/browser/renderer_host/accelerated_surface_container_touch.h" |
9 #include "content/browser/renderer_host/render_widget_host.h" | 9 #include "content/browser/renderer_host/render_widget_host.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/gtk/WebInputEventFact
ory.h" |
11 #include "ui/gfx/gl/gl_bindings.h" | 11 #include "ui/gfx/gl/gl_bindings.h" |
12 #include "views/widget/widget.h" | 12 #include "views/widget/widget.h" |
13 | 13 |
14 static const char kRenderWidgetHostViewKey[] = "__RENDER_WIDGET_HOST_VIEW__"; | 14 static const char kRenderWidgetHostViewKey[] = "__RENDER_WIDGET_HOST_VIEW__"; |
15 | 15 |
16 using WebKit::WebInputEventFactory; | 16 using WebKit::WebInputEventFactory; |
17 using WebKit::WebTouchEvent; | 17 using WebKit::WebTouchEvent; |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 WebKit::WebTouchPoint::State TouchPointStateFromEvent( | 21 WebKit::WebTouchPocontent::NOTIFICATION_State TouchPointStateFromEvent( |
22 const views::TouchEvent* event) { | 22 const views::TouchEvent* event) { |
23 switch (event->type()) { | 23 switch (event->type()) { |
24 case ui::ET_TOUCH_PRESSED: | 24 case ui::ET_TOUCH_PRESSED: |
25 return WebKit::WebTouchPoint::StatePressed; | 25 return WebKit::WebTouchPocontent::NOTIFICATION_StatePressed; |
26 case ui::ET_TOUCH_RELEASED: | 26 case ui::ET_TOUCH_RELEASED: |
27 return WebKit::WebTouchPoint::StateReleased; | 27 return WebKit::WebTouchPocontent::NOTIFICATION_StateReleased; |
28 case ui::ET_TOUCH_MOVED: | 28 case ui::ET_TOUCH_MOVED: |
29 return WebKit::WebTouchPoint::StateMoved; | 29 return WebKit::WebTouchPocontent::NOTIFICATION_StateMoved; |
30 case ui::ET_TOUCH_CANCELLED: | 30 case ui::ET_TOUCH_CANCELLED: |
31 return WebKit::WebTouchPoint::StateCancelled; | 31 return WebKit::WebTouchPocontent::NOTIFICATION_StateCancelled; |
32 default: | 32 default: |
33 return WebKit::WebTouchPoint::StateUndefined; | 33 return WebKit::WebTouchPocontent::NOTIFICATION_StateUndefined; |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 WebKit::WebInputEvent::Type TouchEventTypeFromEvent( | 37 WebKit::WebInputEvent::Type TouchEventTypeFromEvent( |
38 const views::TouchEvent* event) { | 38 const views::TouchEvent* event) { |
39 switch (event->type()) { | 39 switch (event->type()) { |
40 case ui::ET_TOUCH_PRESSED: | 40 case ui::ET_TOUCH_PRESSED: |
41 return WebKit::WebInputEvent::TouchStart; | 41 return WebKit::WebInputEvent::TouchStart; |
42 case ui::ET_TOUCH_RELEASED: | 42 case ui::ET_TOUCH_RELEASED: |
43 return WebKit::WebInputEvent::TouchEnd; | 43 return WebKit::WebInputEvent::TouchEnd; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (!point) | 131 if (!point) |
132 return ui::TOUCH_STATUS_UNKNOWN; | 132 return ui::TOUCH_STATUS_UNKNOWN; |
133 | 133 |
134 if (status != ui::TOUCH_STATUS_START) | 134 if (status != ui::TOUCH_STATUS_START) |
135 status = ui::TOUCH_STATUS_CONTINUE; | 135 status = ui::TOUCH_STATUS_CONTINUE; |
136 | 136 |
137 UpdateTouchParams(event, point); | 137 UpdateTouchParams(event, point); |
138 | 138 |
139 // Update the location and state of the point. | 139 // Update the location and state of the point. |
140 point->state = TouchPointStateFromEvent(&event); | 140 point->state = TouchPointStateFromEvent(&event); |
141 if (point->state == WebKit::WebTouchPoint::StateMoved) { | 141 if (point->state == WebKit::WebTouchPocontent::NOTIFICATION_StateMoved) { |
142 // It is possible for badly written touch drivers to emit Move events even | 142 // It is possible for badly written touch drivers to emit Move events even |
143 // when the touch location hasn't changed. In such cases, consume the event | 143 // when the touch location hasn't changed. In such cases, consume the event |
144 // and pretend nothing happened. | 144 // and pretend nothing happened. |
145 if (point->position.x == event.x() && point->position.y == event.y()) { | 145 if (point->position.x == event.x() && point->position.y == event.y()) { |
146 return status; | 146 return status; |
147 } | 147 } |
148 } | 148 } |
149 UpdateTouchPointPosition(&event, GetMirroredPosition(), point); | 149 UpdateTouchPointPosition(&event, GetMirroredPosition(), point); |
150 | 150 |
151 // Mark the rest of the points as stationary. | 151 // Mark the rest of the points as stationary. |
152 for (int i = 0; i < touch_event_.touchPointsLength; ++i) { | 152 for (int i = 0; i < touch_event_.touchPointsLength; ++i) { |
153 WebKit::WebTouchPoint* iter = touch_event_.touchPoints + i; | 153 WebKit::WebTouchPoint* iter = touch_event_.touchPoints + i; |
154 if (iter != point) { | 154 if (iter != point) { |
155 iter->state = WebKit::WebTouchPoint::StateStationary; | 155 iter->state = WebKit::WebTouchPocontent::NOTIFICATION_StateStationary; |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 // Update the type of the touch event. | 159 // Update the type of the touch event. |
160 touch_event_.type = TouchEventTypeFromEvent(&event); | 160 touch_event_.type = TouchEventTypeFromEvent(&event); |
161 touch_event_.timeStampSeconds = base::Time::Now().ToDoubleT(); | 161 touch_event_.timeStampSeconds = base::Time::Now().ToDoubleT(); |
162 | 162 |
163 // The event and all the touches have been updated. Dispatch. | 163 // The event and all the touches have been updated. Dispatch. |
164 host_->ForwardTouchEvent(touch_event_); | 164 host_->ForwardTouchEvent(touch_event_); |
165 | 165 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 | 208 |
209 void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) { | 209 void RenderWidgetHostViewViews::AcceleratedSurfaceRelease(uint64 surface_id) { |
210 accelerated_surface_containers_.erase(surface_id); | 210 accelerated_surface_containers_.erase(surface_id); |
211 } | 211 } |
212 | 212 |
213 void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped( | 213 void RenderWidgetHostViewViews::AcceleratedSurfaceBuffersSwapped( |
214 uint64 surface_id) { | 214 uint64 surface_id) { |
215 SetExternalTexture(accelerated_surface_containers_[surface_id].get()); | 215 SetExternalTexture(accelerated_surface_containers_[surface_id].get()); |
216 glFlush(); | 216 glFlush(); |
217 } | 217 } |
OLD | NEW |