| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 #include "gpu/command_buffer/client/gles2_implementation.h" | 70 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 71 #include "gpu/command_buffer/client/gles2_interface.h" | 71 #include "gpu/command_buffer/client/gles2_interface.h" |
| 72 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 72 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 73 #include "ipc/ipc_message_macros.h" | 73 #include "ipc/ipc_message_macros.h" |
| 74 #include "ipc/ipc_message_start.h" | 74 #include "ipc/ipc_message_start.h" |
| 75 #include "skia/ext/image_operations.h" | 75 #include "skia/ext/image_operations.h" |
| 76 #include "third_party/khronos/GLES2/gl2.h" | 76 #include "third_party/khronos/GLES2/gl2.h" |
| 77 #include "third_party/khronos/GLES2/gl2ext.h" | 77 #include "third_party/khronos/GLES2/gl2ext.h" |
| 78 #include "third_party/skia/include/core/SkCanvas.h" | 78 #include "third_party/skia/include/core/SkCanvas.h" |
| 79 #include "ui/android/delegated_frame_host_android.h" | 79 #include "ui/android/delegated_frame_host_android.h" |
| 80 #include "ui/android/overscroll_refresh.h" |
| 80 #include "ui/android/window_android.h" | 81 #include "ui/android/window_android.h" |
| 81 #include "ui/android/window_android_compositor.h" | 82 #include "ui/android/window_android_compositor.h" |
| 82 #include "ui/base/layout.h" | 83 #include "ui/base/layout.h" |
| 83 #include "ui/display/display.h" | 84 #include "ui/display/display.h" |
| 84 #include "ui/display/screen.h" | 85 #include "ui/display/screen.h" |
| 85 #include "ui/events/base_event_utils.h" | 86 #include "ui/events/base_event_utils.h" |
| 86 #include "ui/events/blink/blink_event_util.h" | 87 #include "ui/events/blink/blink_event_util.h" |
| 87 #include "ui/events/blink/did_overscroll_params.h" | 88 #include "ui/events/blink/did_overscroll_params.h" |
| 88 #include "ui/events/blink/web_input_event_traits.h" | 89 #include "ui/events/blink/web_input_event_traits.h" |
| 89 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 90 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 base::CommandLine::ForCurrentProcess()->HasSwitch( | 332 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 332 switches::kEnableAdaptiveSelectionHandleOrientation); | 333 switches::kEnableAdaptiveSelectionHandleOrientation); |
| 333 config.enable_longpress_drag_selection = | 334 config.enable_longpress_drag_selection = |
| 334 base::CommandLine::ForCurrentProcess()->HasSwitch( | 335 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 335 switches::kEnableLongpressDragSelection); | 336 switches::kEnableLongpressDragSelection); |
| 336 return base::MakeUnique<ui::TouchSelectionController>(client, config); | 337 return base::MakeUnique<ui::TouchSelectionController>(client, config); |
| 337 } | 338 } |
| 338 | 339 |
| 339 std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( | 340 std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( |
| 340 ContentViewCoreImpl* content_view_core, | 341 ContentViewCoreImpl* content_view_core, |
| 342 ui::OverscrollRefreshHandler* overscroll_refresh_handler, |
| 341 float dpi_scale) { | 343 float dpi_scale) { |
| 342 return base::MakeUnique<OverscrollControllerAndroid>(content_view_core, | 344 return base::MakeUnique<OverscrollControllerAndroid>( |
| 343 dpi_scale); | 345 content_view_core, overscroll_refresh_handler, dpi_scale); |
| 344 } | 346 } |
| 345 | 347 |
| 346 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { | 348 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
| 347 gfx::RectF rect = controller.GetRectBetweenBounds(); | 349 gfx::RectF rect = controller.GetRectBetweenBounds(); |
| 348 if (rect.IsEmpty()) | 350 if (rect.IsEmpty()) |
| 349 return rect; | 351 return rect; |
| 350 | 352 |
| 351 rect.Union(controller.GetStartHandleRect()); | 353 rect.Union(controller.GetStartHandleRect()); |
| 352 rect.Union(controller.GetEndHandleRect()); | 354 rect.Union(controller.GetEndHandleRect()); |
| 353 return rect; | 355 return rect; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 431 while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
| 430 if (widget->GetView()) { | 432 if (widget->GetView()) { |
| 431 static_cast<RenderWidgetHostViewAndroid*>(widget->GetView()) | 433 static_cast<RenderWidgetHostViewAndroid*>(widget->GetView()) |
| 432 ->OnLostResources(); | 434 ->OnLostResources(); |
| 433 } | 435 } |
| 434 } | 436 } |
| 435 } | 437 } |
| 436 | 438 |
| 437 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( | 439 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( |
| 438 RenderWidgetHostImpl* widget_host, | 440 RenderWidgetHostImpl* widget_host, |
| 439 ContentViewCoreImpl* content_view_core) | 441 ContentViewCoreImpl* content_view_core, |
| 442 ui::OverscrollRefreshHandler* overscroll_refresh_handler) |
| 440 : host_(widget_host), | 443 : host_(widget_host), |
| 441 outstanding_vsync_requests_(0), | 444 outstanding_vsync_requests_(0), |
| 442 is_showing_(!widget_host->is_hidden()), | 445 is_showing_(!widget_host->is_hidden()), |
| 443 is_window_visible_(true), | 446 is_window_visible_(true), |
| 444 is_window_activity_started_(true), | 447 is_window_activity_started_(true), |
| 445 content_view_core_(nullptr), | 448 content_view_core_(nullptr), |
| 449 overscroll_refresh_handler_(overscroll_refresh_handler), |
| 446 ime_adapter_android_(this), | 450 ime_adapter_android_(this), |
| 447 cached_background_color_(SK_ColorWHITE), | 451 cached_background_color_(SK_ColorWHITE), |
| 448 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), | 452 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), |
| 449 gesture_provider_(ui::GetGestureProviderConfig( | 453 gesture_provider_(ui::GetGestureProviderConfig( |
| 450 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 454 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
| 451 this), | 455 this), |
| 452 stylus_text_selector_(this), | 456 stylus_text_selector_(this), |
| 453 using_browser_compositor_(CompositorImpl::IsInitialized()), | 457 using_browser_compositor_(CompositorImpl::IsInitialized()), |
| 454 synchronous_compositor_client_(nullptr), | 458 synchronous_compositor_client_(nullptr), |
| 455 frame_evictor_(new DelegatedFrameEvictor(this)), | 459 frame_evictor_(new DelegatedFrameEvictor(this)), |
| (...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 | 1799 |
| 1796 if (resize) | 1800 if (resize) |
| 1797 WasResized(); | 1801 WasResized(); |
| 1798 | 1802 |
| 1799 if (!selection_controller_) | 1803 if (!selection_controller_) |
| 1800 selection_controller_ = CreateSelectionController(this, content_view_core_); | 1804 selection_controller_ = CreateSelectionController(this, content_view_core_); |
| 1801 | 1805 |
| 1802 if (!overscroll_controller_ && | 1806 if (!overscroll_controller_ && |
| 1803 view_.GetWindowAndroid()->GetCompositor()) { | 1807 view_.GetWindowAndroid()->GetCompositor()) { |
| 1804 overscroll_controller_ = CreateOverscrollController( | 1808 overscroll_controller_ = CreateOverscrollController( |
| 1805 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1809 content_view_core_, overscroll_refresh_handler_, |
| 1810 ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1806 } | 1811 } |
| 1807 } | 1812 } |
| 1808 | 1813 |
| 1809 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1814 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| 1810 while (!ack_callbacks_.empty()) { | 1815 while (!ack_callbacks_.empty()) { |
| 1811 ack_callbacks_.front().Run(); | 1816 ack_callbacks_.front().Run(); |
| 1812 ack_callbacks_.pop(); | 1817 ack_callbacks_.pop(); |
| 1813 } | 1818 } |
| 1814 } | 1819 } |
| 1815 | 1820 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 | 1867 |
| 1863 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { | 1868 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { |
| 1864 StopObservingRootWindow(); | 1869 StopObservingRootWindow(); |
| 1865 OnDetachCompositor(); | 1870 OnDetachCompositor(); |
| 1866 } | 1871 } |
| 1867 | 1872 |
| 1868 void RenderWidgetHostViewAndroid::OnAttachCompositor() { | 1873 void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
| 1869 DCHECK(content_view_core_); | 1874 DCHECK(content_view_core_); |
| 1870 if (!overscroll_controller_) | 1875 if (!overscroll_controller_) |
| 1871 overscroll_controller_ = CreateOverscrollController( | 1876 overscroll_controller_ = CreateOverscrollController( |
| 1872 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1877 content_view_core_, overscroll_refresh_handler_, |
| 1878 ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1873 ui::WindowAndroidCompositor* compositor = | 1879 ui::WindowAndroidCompositor* compositor = |
| 1874 view_.GetWindowAndroid()->GetCompositor(); | 1880 view_.GetWindowAndroid()->GetCompositor(); |
| 1875 delegated_frame_host_->RegisterFrameSinkHierarchy( | 1881 delegated_frame_host_->RegisterFrameSinkHierarchy( |
| 1876 compositor->GetFrameSinkId()); | 1882 compositor->GetFrameSinkId()); |
| 1877 } | 1883 } |
| 1878 | 1884 |
| 1879 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1885 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1880 DCHECK(content_view_core_); | 1886 DCHECK(content_view_core_); |
| 1881 DCHECK(using_browser_compositor_); | 1887 DCHECK(using_browser_compositor_); |
| 1882 RunAckCallbacks(); | 1888 RunAckCallbacks(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 case ui::MotionEvent::ACTION_UP: | 1983 case ui::MotionEvent::ACTION_UP: |
| 1978 case ui::MotionEvent::ACTION_POINTER_UP: | 1984 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1979 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1985 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1980 delta.InMicroseconds(), 1, 1000000, 50); | 1986 delta.InMicroseconds(), 1, 1000000, 50); |
| 1981 default: | 1987 default: |
| 1982 return; | 1988 return; |
| 1983 } | 1989 } |
| 1984 } | 1990 } |
| 1985 | 1991 |
| 1986 } // namespace content | 1992 } // namespace content |
| OLD | NEW |