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_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include "base/android/sys_utils.h" | 9 #include "base/android/sys_utils.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "content/browser/renderer_host/compositor_impl_android.h" | 39 #include "content/browser/renderer_host/compositor_impl_android.h" |
40 #include "content/browser/renderer_host/dip_util.h" | 40 #include "content/browser/renderer_host/dip_util.h" |
41 #include "content/browser/renderer_host/image_transport_factory_android.h" | 41 #include "content/browser/renderer_host/image_transport_factory_android.h" |
42 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h
" | 42 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h
" |
43 #include "content/browser/renderer_host/input/web_input_event_util.h" | 43 #include "content/browser/renderer_host/input/web_input_event_util.h" |
44 #include "content/browser/renderer_host/render_process_host_impl.h" | 44 #include "content/browser/renderer_host/render_process_host_impl.h" |
45 #include "content/browser/renderer_host/render_view_host_impl.h" | 45 #include "content/browser/renderer_host/render_view_host_impl.h" |
46 #include "content/browser/renderer_host/render_widget_host_impl.h" | 46 #include "content/browser/renderer_host/render_widget_host_impl.h" |
47 #include "content/common/gpu/client/gl_helper.h" | 47 #include "content/common/gpu/client/gl_helper.h" |
48 #include "content/common/gpu/gpu_messages.h" | 48 #include "content/common/gpu/gpu_messages.h" |
| 49 #include "content/common/input/did_overscroll_params.h" |
49 #include "content/common/input_messages.h" | 50 #include "content/common/input_messages.h" |
50 #include "content/common/view_messages.h" | 51 #include "content/common/view_messages.h" |
51 #include "content/public/browser/devtools_agent_host.h" | 52 #include "content/public/browser/devtools_agent_host.h" |
52 #include "content/public/browser/render_view_host.h" | 53 #include "content/public/browser/render_view_host.h" |
53 #include "content/public/common/content_switches.h" | 54 #include "content/public/common/content_switches.h" |
54 #include "gpu/command_buffer/client/gles2_interface.h" | 55 #include "gpu/command_buffer/client/gles2_interface.h" |
55 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 56 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
56 #include "skia/ext/image_operations.h" | 57 #include "skia/ext/image_operations.h" |
57 #include "third_party/khronos/GLES2/gl2.h" | 58 #include "third_party/khronos/GLES2/gl2.h" |
58 #include "third_party/khronos/GLES2/gl2ext.h" | 59 #include "third_party/khronos/GLES2/gl2ext.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 } | 208 } |
208 | 209 |
209 | 210 |
210 bool RenderWidgetHostViewAndroid::OnMessageReceived( | 211 bool RenderWidgetHostViewAndroid::OnMessageReceived( |
211 const IPC::Message& message) { | 212 const IPC::Message& message) { |
212 bool handled = true; | 213 bool handled = true; |
213 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAndroid, message) | 214 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAndroid, message) |
214 IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent) | 215 IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent) |
215 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor, | 216 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor, |
216 OnDidChangeBodyBackgroundColor) | 217 OnDidChangeBodyBackgroundColor) |
| 218 IPC_MESSAGE_HANDLER(ViewHostMsg_DidOverscroll, OnDidOverscroll) |
217 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrame, | 219 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrame, |
218 OnSetNeedsBeginFrame) | 220 OnSetNeedsBeginFrame) |
219 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, | 221 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
220 OnTextInputStateChanged) | 222 OnTextInputStateChanged) |
221 IPC_MESSAGE_HANDLER(ViewHostMsg_SmartClipDataExtracted, | 223 IPC_MESSAGE_HANDLER(ViewHostMsg_SmartClipDataExtracted, |
222 OnSmartClipDataExtracted) | 224 OnSmartClipDataExtracted) |
223 IPC_MESSAGE_UNHANDLED(handled = false) | 225 IPC_MESSAGE_UNHANDLED(handled = false) |
224 IPC_END_MESSAGE_MAP() | 226 IPC_END_MESSAGE_MAP() |
225 return handled; | 227 return handled; |
226 } | 228 } |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 void RenderWidgetHostViewAndroid::OnDidChangeBodyBackgroundColor( | 510 void RenderWidgetHostViewAndroid::OnDidChangeBodyBackgroundColor( |
509 SkColor color) { | 511 SkColor color) { |
510 if (cached_background_color_ == color) | 512 if (cached_background_color_ == color) |
511 return; | 513 return; |
512 | 514 |
513 cached_background_color_ = color; | 515 cached_background_color_ = color; |
514 if (content_view_core_) | 516 if (content_view_core_) |
515 content_view_core_->OnBackgroundColorChanged(color); | 517 content_view_core_->OnBackgroundColorChanged(color); |
516 } | 518 } |
517 | 519 |
| 520 void RenderWidgetHostViewAndroid::OnDidOverscroll( |
| 521 const DidOverscrollParams& params) { |
| 522 if (!content_view_core_ || !layer_ || !is_showing_) |
| 523 return; |
| 524 |
| 525 const float device_scale_factor = content_view_core_->GetDpiScale(); |
| 526 if (overscroll_effect_->OnOverscrolled( |
| 527 content_view_core_->GetLayer(), |
| 528 base::TimeTicks::Now(), |
| 529 gfx::ScaleVector2d(params.accumulated_overscroll, |
| 530 device_scale_factor), |
| 531 gfx::ScaleVector2d(params.latest_overscroll_delta, |
| 532 device_scale_factor), |
| 533 gfx::ScaleVector2d(params.current_fling_velocity, |
| 534 device_scale_factor))) { |
| 535 content_view_core_->SetNeedsAnimate(); |
| 536 } |
| 537 } |
| 538 |
518 void RenderWidgetHostViewAndroid::SendBeginFrame( | 539 void RenderWidgetHostViewAndroid::SendBeginFrame( |
519 const cc::BeginFrameArgs& args) { | 540 const cc::BeginFrameArgs& args) { |
520 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::SendBeginFrame"); | 541 TRACE_EVENT0("cc", "RenderWidgetHostViewAndroid::SendBeginFrame"); |
521 if (!host_) | 542 if (!host_) |
522 return; | 543 return; |
523 | 544 |
524 if (flush_input_requested_) { | 545 if (flush_input_requested_) { |
525 flush_input_requested_ = false; | 546 flush_input_requested_ = false; |
526 host_->FlushInput(); | 547 host_->FlushInput(); |
527 content_view_core_->RemoveBeginFrameSubscriber(); | 548 content_view_core_->RemoveBeginFrameSubscriber(); |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 | 1312 |
1292 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { | 1313 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { |
1293 if (host_) | 1314 if (host_) |
1294 host_->MoveCaret(point); | 1315 host_->MoveCaret(point); |
1295 } | 1316 } |
1296 | 1317 |
1297 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 1318 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
1298 return cached_background_color_; | 1319 return cached_background_color_; |
1299 } | 1320 } |
1300 | 1321 |
1301 void RenderWidgetHostViewAndroid::OnOverscrolled( | |
1302 gfx::Vector2dF accumulated_overscroll, | |
1303 gfx::Vector2dF current_fling_velocity) { | |
1304 if (!content_view_core_ || !layer_ || !is_showing_) | |
1305 return; | |
1306 | |
1307 const float device_scale_factor = content_view_core_->GetDpiScale(); | |
1308 if (overscroll_effect_->OnOverscrolled( | |
1309 content_view_core_->GetLayer(), | |
1310 base::TimeTicks::Now(), | |
1311 gfx::ScaleVector2d(accumulated_overscroll, device_scale_factor), | |
1312 gfx::ScaleVector2d(current_fling_velocity, device_scale_factor))) { | |
1313 content_view_core_->SetNeedsAnimate(); | |
1314 } | |
1315 } | |
1316 | |
1317 void RenderWidgetHostViewAndroid::DidStopFlinging() { | 1322 void RenderWidgetHostViewAndroid::DidStopFlinging() { |
1318 if (content_view_core_) | 1323 if (content_view_core_) |
1319 content_view_core_->DidStopFlinging(); | 1324 content_view_core_->DidStopFlinging(); |
1320 } | 1325 } |
1321 | 1326 |
1322 void RenderWidgetHostViewAndroid::SetContentViewCore( | 1327 void RenderWidgetHostViewAndroid::SetContentViewCore( |
1323 ContentViewCoreImpl* content_view_core) { | 1328 ContentViewCoreImpl* content_view_core) { |
1324 RemoveLayers(); | 1329 RemoveLayers(); |
1325 if (observing_root_window_ && content_view_core_) { | 1330 if (observing_root_window_ && content_view_core_) { |
1326 content_view_core_->GetWindowAndroid()->RemoveObserver(this); | 1331 content_view_core_->GetWindowAndroid()->RemoveObserver(this); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 // RenderWidgetHostView, public: | 1506 // RenderWidgetHostView, public: |
1502 | 1507 |
1503 // static | 1508 // static |
1504 RenderWidgetHostView* | 1509 RenderWidgetHostView* |
1505 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { | 1510 RenderWidgetHostView::CreateViewForWidget(RenderWidgetHost* widget) { |
1506 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 1511 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
1507 return new RenderWidgetHostViewAndroid(rwhi, NULL); | 1512 return new RenderWidgetHostViewAndroid(rwhi, NULL); |
1508 } | 1513 } |
1509 | 1514 |
1510 } // namespace content | 1515 } // namespace content |
OLD | NEW |