Chromium Code Reviews| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 #include "content/browser/gpu/gpu_data_manager_impl.h" | 48 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 49 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 49 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 50 #include "content/browser/media/android/media_web_contents_observer_android.h" | 50 #include "content/browser/media/android/media_web_contents_observer_android.h" |
| 51 #include "content/browser/renderer_host/compositor_impl_android.h" | 51 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 52 #include "content/browser/renderer_host/dip_util.h" | 52 #include "content/browser/renderer_host/dip_util.h" |
| 53 #include "content/browser/renderer_host/frame_metadata_util.h" | 53 #include "content/browser/renderer_host/frame_metadata_util.h" |
| 54 #include "content/browser/renderer_host/input/input_router_impl.h" | 54 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 55 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h " | 55 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h " |
| 56 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " | 56 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " |
| 57 #include "content/browser/renderer_host/render_process_host_impl.h" | 57 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 58 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | |
| 58 #include "content/browser/renderer_host/render_view_host_impl.h" | 59 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 59 #include "content/browser/renderer_host/render_widget_host_impl.h" | 60 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 60 #include "content/common/gpu_host_messages.h" | 61 #include "content/common/gpu_host_messages.h" |
| 61 #include "content/common/input_messages.h" | 62 #include "content/common/input_messages.h" |
| 62 #include "content/common/view_messages.h" | 63 #include "content/common/view_messages.h" |
| 63 #include "content/public/browser/android/compositor.h" | 64 #include "content/public/browser/android/compositor.h" |
| 64 #include "content/public/browser/android/synchronous_compositor_client.h" | 65 #include "content/public/browser/android/synchronous_compositor_client.h" |
| 65 #include "content/public/browser/browser_thread.h" | 66 #include "content/public/browser/browser_thread.h" |
| 66 #include "content/public/browser/devtools_agent_host.h" | 67 #include "content/public/browser/devtools_agent_host.h" |
| 67 #include "content/public/browser/render_view_host.h" | 68 #include "content/public/browser/render_view_host.h" |
| 68 #include "content/public/browser/render_widget_host_iterator.h" | 69 #include "content/public/browser/render_widget_host_iterator.h" |
| 69 #include "content/public/common/content_switches.h" | 70 #include "content/public/common/content_switches.h" |
| 70 #include "gpu/command_buffer/client/gles2_implementation.h" | 71 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 71 #include "gpu/command_buffer/client/gles2_interface.h" | 72 #include "gpu/command_buffer/client/gles2_interface.h" |
| 72 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 73 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 73 #include "ipc/ipc_message_macros.h" | 74 #include "ipc/ipc_message_macros.h" |
| 74 #include "ipc/ipc_message_start.h" | 75 #include "ipc/ipc_message_start.h" |
| 75 #include "skia/ext/image_operations.h" | 76 #include "skia/ext/image_operations.h" |
| 76 #include "third_party/khronos/GLES2/gl2.h" | 77 #include "third_party/khronos/GLES2/gl2.h" |
| 77 #include "third_party/khronos/GLES2/gl2ext.h" | 78 #include "third_party/khronos/GLES2/gl2ext.h" |
| 78 #include "third_party/skia/include/core/SkCanvas.h" | 79 #include "third_party/skia/include/core/SkCanvas.h" |
| 79 #include "ui/android/delegated_frame_host_android.h" | 80 #include "ui/android/delegated_frame_host_android.h" |
| 81 #include "ui/android/overscroll_refresh_handler.h" | |
|
boliu
2016/12/06 00:58:16
ditto, forward declare should be enough it seems
rlanday
2016/12/06 03:25:26
If I take out the header it still compiles, must b
| |
| 80 #include "ui/android/window_android.h" | 82 #include "ui/android/window_android.h" |
| 81 #include "ui/android/window_android_compositor.h" | 83 #include "ui/android/window_android_compositor.h" |
| 82 #include "ui/base/layout.h" | 84 #include "ui/base/layout.h" |
| 83 #include "ui/display/display.h" | 85 #include "ui/display/display.h" |
| 84 #include "ui/display/screen.h" | 86 #include "ui/display/screen.h" |
| 85 #include "ui/events/base_event_utils.h" | 87 #include "ui/events/base_event_utils.h" |
| 86 #include "ui/events/blink/blink_event_util.h" | 88 #include "ui/events/blink/blink_event_util.h" |
| 87 #include "ui/events/blink/did_overscroll_params.h" | 89 #include "ui/events/blink/did_overscroll_params.h" |
| 88 #include "ui/events/blink/web_input_event_traits.h" | 90 #include "ui/events/blink/web_input_event_traits.h" |
| 89 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 91 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 config.enable_adaptive_handle_orientation = | 332 config.enable_adaptive_handle_orientation = |
| 331 base::CommandLine::ForCurrentProcess()->HasSwitch( | 333 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 332 switches::kEnableAdaptiveSelectionHandleOrientation); | 334 switches::kEnableAdaptiveSelectionHandleOrientation); |
| 333 config.enable_longpress_drag_selection = | 335 config.enable_longpress_drag_selection = |
| 334 base::CommandLine::ForCurrentProcess()->HasSwitch( | 336 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 335 switches::kEnableLongpressDragSelection); | 337 switches::kEnableLongpressDragSelection); |
| 336 return base::MakeUnique<ui::TouchSelectionController>(client, config); | 338 return base::MakeUnique<ui::TouchSelectionController>(client, config); |
| 337 } | 339 } |
| 338 | 340 |
| 339 std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( | 341 std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( |
| 342 ui::OverscrollRefreshHandler* overscroll_refresh_handler, | |
| 340 ContentViewCoreImpl* content_view_core, | 343 ContentViewCoreImpl* content_view_core, |
| 341 float dpi_scale) { | 344 float dpi_scale) { |
| 342 return base::MakeUnique<OverscrollControllerAndroid>(content_view_core, | 345 return base::MakeUnique<OverscrollControllerAndroid>( |
| 343 dpi_scale); | 346 overscroll_refresh_handler, |
| 347 content_view_core->GetWindowAndroid()->GetCompositor(), dpi_scale); | |
| 344 } | 348 } |
| 345 | 349 |
| 346 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { | 350 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
| 347 gfx::RectF rect = controller.GetRectBetweenBounds(); | 351 gfx::RectF rect = controller.GetRectBetweenBounds(); |
| 348 if (rect.IsEmpty()) | 352 if (rect.IsEmpty()) |
| 349 return rect; | 353 return rect; |
| 350 | 354 |
| 351 rect.Union(controller.GetStartHandleRect()); | 355 rect.Union(controller.GetStartHandleRect()); |
| 352 rect.Union(controller.GetEndHandleRect()); | 356 rect.Union(controller.GetEndHandleRect()); |
| 353 return rect; | 357 return rect; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 if (using_browser_compositor_) { | 466 if (using_browser_compositor_) { |
| 463 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( | 467 delegated_frame_host_.reset(new ui::DelegatedFrameHostAndroid( |
| 464 &view_, cached_background_color_, | 468 &view_, cached_background_color_, |
| 465 base::Bind(&RenderWidgetHostViewAndroid::ReturnResources, | 469 base::Bind(&RenderWidgetHostViewAndroid::ReturnResources, |
| 466 weak_ptr_factory_.GetWeakPtr()))); | 470 weak_ptr_factory_.GetWeakPtr()))); |
| 467 } | 471 } |
| 468 | 472 |
| 469 host_->SetView(this); | 473 host_->SetView(this); |
| 470 SetContentViewCore(content_view_core); | 474 SetContentViewCore(content_view_core); |
| 471 | 475 |
| 476 ui::OverscrollRefreshHandler* handler = | |
| 477 host_->delegate()->GetDelegateView()->GetOverscrollRefreshHandler(); | |
| 478 if (handler) { | |
| 479 overscroll_controller_ = CreateOverscrollController( | |
| 480 handler, content_view_core_, | |
| 481 ui::GetScaleFactorForNativeView(GetNativeView())); | |
| 482 } | |
| 483 | |
| 472 if (GetTextInputManager()) | 484 if (GetTextInputManager()) |
| 473 GetTextInputManager()->AddObserver(this); | 485 GetTextInputManager()->AddObserver(this); |
| 474 } | 486 } |
| 475 | 487 |
| 476 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { | 488 RenderWidgetHostViewAndroid::~RenderWidgetHostViewAndroid() { |
| 477 if (content_view_core_) | 489 if (content_view_core_) |
| 478 content_view_core_->RemoveObserver(this); | 490 content_view_core_->RemoveObserver(this); |
| 479 SetContentViewCore(NULL); | 491 SetContentViewCore(NULL); |
| 480 DCHECK(ack_callbacks_.empty()); | 492 DCHECK(ack_callbacks_.empty()); |
| 481 DCHECK(!delegated_frame_host_); | 493 DCHECK(!delegated_frame_host_); |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1213 } | 1225 } |
| 1214 | 1226 |
| 1215 void RenderWidgetHostViewAndroid::SetSynchronousCompositorClient( | 1227 void RenderWidgetHostViewAndroid::SetSynchronousCompositorClient( |
| 1216 SynchronousCompositorClient* client) { | 1228 SynchronousCompositorClient* client) { |
| 1217 synchronous_compositor_client_ = client; | 1229 synchronous_compositor_client_ = client; |
| 1218 if (!sync_compositor_ && synchronous_compositor_client_) { | 1230 if (!sync_compositor_ && synchronous_compositor_client_) { |
| 1219 sync_compositor_ = SynchronousCompositorHost::Create(this); | 1231 sync_compositor_ = SynchronousCompositorHost::Create(this); |
| 1220 } | 1232 } |
| 1221 } | 1233 } |
| 1222 | 1234 |
| 1235 void RenderWidgetHostViewAndroid::OnSetOverscrollRefreshHandler() { | |
| 1236 overscroll_controller_ = CreateOverscrollController( | |
|
boliu
2016/12/06 00:58:16
hmm, DCHECK(!overscroll_controller_) first, to mak
rlanday
2016/12/06 03:25:26
Ok (would it be a problem if we were?)
| |
| 1237 host_->delegate()->GetDelegateView()->GetOverscrollRefreshHandler(), | |
| 1238 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | |
| 1239 } | |
| 1240 | |
| 1223 bool RenderWidgetHostViewAndroid::SupportsAnimation() const { | 1241 bool RenderWidgetHostViewAndroid::SupportsAnimation() const { |
| 1224 // The synchronous (WebView) compositor does not have a proper browser | 1242 // The synchronous (WebView) compositor does not have a proper browser |
| 1225 // compositor with which to drive animations. | 1243 // compositor with which to drive animations. |
| 1226 return using_browser_compositor_; | 1244 return using_browser_compositor_; |
| 1227 } | 1245 } |
| 1228 | 1246 |
| 1229 void RenderWidgetHostViewAndroid::SetNeedsAnimate() { | 1247 void RenderWidgetHostViewAndroid::SetNeedsAnimate() { |
| 1230 DCHECK(view_.GetWindowAndroid()); | 1248 DCHECK(view_.GetWindowAndroid()); |
| 1231 DCHECK(using_browser_compositor_); | 1249 DCHECK(using_browser_compositor_); |
| 1232 view_.GetWindowAndroid()->SetNeedsAnimate(); | 1250 view_.GetWindowAndroid()->SetNeedsAnimate(); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1808 } | 1826 } |
| 1809 | 1827 |
| 1810 if (is_showing_) | 1828 if (is_showing_) |
| 1811 StartObservingRootWindow(); | 1829 StartObservingRootWindow(); |
| 1812 | 1830 |
| 1813 if (resize) | 1831 if (resize) |
| 1814 WasResized(); | 1832 WasResized(); |
| 1815 | 1833 |
| 1816 if (!selection_controller_) | 1834 if (!selection_controller_) |
| 1817 selection_controller_ = CreateSelectionController(this, content_view_core_); | 1835 selection_controller_ = CreateSelectionController(this, content_view_core_); |
| 1818 | |
| 1819 if (!overscroll_controller_ && | |
| 1820 view_.GetWindowAndroid()->GetCompositor()) { | |
| 1821 overscroll_controller_ = CreateOverscrollController( | |
| 1822 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | |
| 1823 } | |
| 1824 } | 1836 } |
| 1825 | 1837 |
| 1826 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1838 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| 1827 while (!ack_callbacks_.empty()) { | 1839 while (!ack_callbacks_.empty()) { |
| 1828 ack_callbacks_.front().Run(); | 1840 ack_callbacks_.front().Run(); |
| 1829 ack_callbacks_.pop(); | 1841 ack_callbacks_.pop(); |
| 1830 } | 1842 } |
| 1831 } | 1843 } |
| 1832 | 1844 |
| 1833 void RenderWidgetHostViewAndroid::OnGestureEvent( | 1845 void RenderWidgetHostViewAndroid::OnGestureEvent( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1877 OnAttachCompositor(); | 1889 OnAttachCompositor(); |
| 1878 } | 1890 } |
| 1879 | 1891 |
| 1880 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { | 1892 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { |
| 1881 StopObservingRootWindow(); | 1893 StopObservingRootWindow(); |
| 1882 OnDetachCompositor(); | 1894 OnDetachCompositor(); |
| 1883 } | 1895 } |
| 1884 | 1896 |
| 1885 void RenderWidgetHostViewAndroid::OnAttachCompositor() { | 1897 void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
| 1886 DCHECK(content_view_core_); | 1898 DCHECK(content_view_core_); |
| 1887 if (!overscroll_controller_) | 1899 if (!overscroll_controller_) { |
| 1888 overscroll_controller_ = CreateOverscrollController( | 1900 ui::OverscrollRefreshHandler* handler = |
| 1889 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1901 host_->delegate()->GetDelegateView()->GetOverscrollRefreshHandler(); |
| 1902 if (handler) { | |
| 1903 overscroll_controller_ = CreateOverscrollController( | |
| 1904 handler, content_view_core_, | |
| 1905 ui::GetScaleFactorForNativeView(GetNativeView())); | |
| 1906 } | |
| 1907 } | |
| 1890 ui::WindowAndroidCompositor* compositor = | 1908 ui::WindowAndroidCompositor* compositor = |
| 1891 view_.GetWindowAndroid()->GetCompositor(); | 1909 view_.GetWindowAndroid()->GetCompositor(); |
| 1892 delegated_frame_host_->RegisterFrameSinkHierarchy( | 1910 delegated_frame_host_->RegisterFrameSinkHierarchy( |
| 1893 compositor->GetFrameSinkId()); | 1911 compositor->GetFrameSinkId()); |
| 1894 } | 1912 } |
| 1895 | 1913 |
| 1896 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1914 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1897 DCHECK(content_view_core_); | 1915 DCHECK(content_view_core_); |
| 1898 DCHECK(using_browser_compositor_); | 1916 DCHECK(using_browser_compositor_); |
| 1899 RunAckCallbacks(); | 1917 RunAckCallbacks(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1994 case ui::MotionEvent::ACTION_UP: | 2012 case ui::MotionEvent::ACTION_UP: |
| 1995 case ui::MotionEvent::ACTION_POINTER_UP: | 2013 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1996 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 2014 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1997 delta.InMicroseconds(), 1, 1000000, 50); | 2015 delta.InMicroseconds(), 1, 1000000, 50); |
| 1998 default: | 2016 default: |
| 1999 return; | 2017 return; |
| 2000 } | 2018 } |
| 2001 } | 2019 } |
| 2002 | 2020 |
| 2003 } // namespace content | 2021 } // namespace content |
| OLD | NEW |