| 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 28 matching lines...) Expand all Loading... |
| 118 friend class base::RefCounted<PendingReadbackLock>; | 119 friend class base::RefCounted<PendingReadbackLock>; |
| 119 | 120 |
| 120 ~PendingReadbackLock() { | 121 ~PendingReadbackLock() { |
| 121 DCHECK_EQ(g_pending_readback_lock, this); | 122 DCHECK_EQ(g_pending_readback_lock, this); |
| 122 g_pending_readback_lock = nullptr; | 123 g_pending_readback_lock = nullptr; |
| 123 } | 124 } |
| 124 }; | 125 }; |
| 125 | 126 |
| 126 using base::android::ApplicationState; | 127 using base::android::ApplicationState; |
| 127 using base::android::ApplicationStatusListener; | 128 using base::android::ApplicationStatusListener; |
| 129 using base::android::JavaParamRef; |
| 130 using base::android::JavaRef; |
| 128 | 131 |
| 129 class GLHelperHolder { | 132 class GLHelperHolder { |
| 130 public: | 133 public: |
| 131 static GLHelperHolder* Create(); | 134 static GLHelperHolder* Create(); |
| 132 | 135 |
| 133 display_compositor::GLHelper* gl_helper() { return gl_helper_.get(); } | 136 display_compositor::GLHelper* gl_helper() { return gl_helper_.get(); } |
| 134 bool IsLost() { | 137 bool IsLost() { |
| 135 if (!gl_helper_) | 138 if (!gl_helper_) |
| 136 return true; | 139 return true; |
| 137 return provider_->ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR; | 140 return provider_->ContextGL()->GetGraphicsResetStatusKHR() != GL_NO_ERROR; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 base::CommandLine::ForCurrentProcess()->HasSwitch( | 334 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 332 switches::kEnableAdaptiveSelectionHandleOrientation); | 335 switches::kEnableAdaptiveSelectionHandleOrientation); |
| 333 config.enable_longpress_drag_selection = | 336 config.enable_longpress_drag_selection = |
| 334 base::CommandLine::ForCurrentProcess()->HasSwitch( | 337 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 335 switches::kEnableLongpressDragSelection); | 338 switches::kEnableLongpressDragSelection); |
| 336 return base::MakeUnique<ui::TouchSelectionController>(client, config); | 339 return base::MakeUnique<ui::TouchSelectionController>(client, config); |
| 337 } | 340 } |
| 338 | 341 |
| 339 std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( | 342 std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( |
| 340 ContentViewCoreImpl* content_view_core, | 343 ContentViewCoreImpl* content_view_core, |
| 344 const JavaRef<jobject>& overscroll_refresh_handler, |
| 341 float dpi_scale) { | 345 float dpi_scale) { |
| 342 return base::MakeUnique<OverscrollControllerAndroid>(content_view_core, | 346 return base::MakeUnique<OverscrollControllerAndroid>( |
| 343 dpi_scale); | 347 overscroll_refresh_handler, |
| 348 content_view_core->GetWindowAndroid()->GetCompositor(), dpi_scale); |
| 344 } | 349 } |
| 345 | 350 |
| 346 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { | 351 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
| 347 gfx::RectF rect = controller.GetRectBetweenBounds(); | 352 gfx::RectF rect = controller.GetRectBetweenBounds(); |
| 348 if (rect.IsEmpty()) | 353 if (rect.IsEmpty()) |
| 349 return rect; | 354 return rect; |
| 350 | 355 |
| 351 rect.Union(controller.GetStartHandleRect()); | 356 rect.Union(controller.GetStartHandleRect()); |
| 352 rect.Union(controller.GetEndHandleRect()); | 357 rect.Union(controller.GetEndHandleRect()); |
| 353 return rect; | 358 return rect; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 434 while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
| 430 if (widget->GetView()) { | 435 if (widget->GetView()) { |
| 431 static_cast<RenderWidgetHostViewAndroid*>(widget->GetView()) | 436 static_cast<RenderWidgetHostViewAndroid*>(widget->GetView()) |
| 432 ->OnLostResources(); | 437 ->OnLostResources(); |
| 433 } | 438 } |
| 434 } | 439 } |
| 435 } | 440 } |
| 436 | 441 |
| 437 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( | 442 RenderWidgetHostViewAndroid::RenderWidgetHostViewAndroid( |
| 438 RenderWidgetHostImpl* widget_host, | 443 RenderWidgetHostImpl* widget_host, |
| 439 ContentViewCoreImpl* content_view_core) | 444 ContentViewCoreImpl* content_view_core, |
| 445 const JavaRef<jobject>& overscroll_refresh_handler) |
| 440 : host_(widget_host), | 446 : host_(widget_host), |
| 441 outstanding_vsync_requests_(0), | 447 outstanding_vsync_requests_(0), |
| 442 is_showing_(!widget_host->is_hidden()), | 448 is_showing_(!widget_host->is_hidden()), |
| 443 is_window_visible_(true), | 449 is_window_visible_(true), |
| 444 is_window_activity_started_(true), | 450 is_window_activity_started_(true), |
| 445 content_view_core_(nullptr), | 451 content_view_core_(nullptr), |
| 452 overscroll_refresh_handler_(nullptr, overscroll_refresh_handler.obj()), |
| 446 ime_adapter_android_(this), | 453 ime_adapter_android_(this), |
| 447 cached_background_color_(SK_ColorWHITE), | 454 cached_background_color_(SK_ColorWHITE), |
| 448 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), | 455 last_compositor_frame_sink_id_(kUndefinedCompositorFrameSinkId), |
| 449 gesture_provider_(ui::GetGestureProviderConfig( | 456 gesture_provider_(ui::GetGestureProviderConfig( |
| 450 ui::GestureProviderConfigType::CURRENT_PLATFORM), | 457 ui::GestureProviderConfigType::CURRENT_PLATFORM), |
| 451 this), | 458 this), |
| 452 stylus_text_selector_(this), | 459 stylus_text_selector_(this), |
| 453 using_browser_compositor_(CompositorImpl::IsInitialized()), | 460 using_browser_compositor_(CompositorImpl::IsInitialized()), |
| 454 synchronous_compositor_client_(nullptr), | 461 synchronous_compositor_client_(nullptr), |
| 455 frame_evictor_(new DelegatedFrameEvictor(this)), | 462 frame_evictor_(new DelegatedFrameEvictor(this)), |
| (...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1808 | 1815 |
| 1809 if (resize) | 1816 if (resize) |
| 1810 WasResized(); | 1817 WasResized(); |
| 1811 | 1818 |
| 1812 if (!selection_controller_) | 1819 if (!selection_controller_) |
| 1813 selection_controller_ = CreateSelectionController(this, content_view_core_); | 1820 selection_controller_ = CreateSelectionController(this, content_view_core_); |
| 1814 | 1821 |
| 1815 if (!overscroll_controller_ && | 1822 if (!overscroll_controller_ && |
| 1816 view_.GetWindowAndroid()->GetCompositor()) { | 1823 view_.GetWindowAndroid()->GetCompositor()) { |
| 1817 overscroll_controller_ = CreateOverscrollController( | 1824 overscroll_controller_ = CreateOverscrollController( |
| 1818 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1825 content_view_core_, overscroll_refresh_handler_, |
| 1826 ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1819 } | 1827 } |
| 1820 } | 1828 } |
| 1821 | 1829 |
| 1822 void RenderWidgetHostViewAndroid::RunAckCallbacks() { | 1830 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
| 1823 while (!ack_callbacks_.empty()) { | 1831 while (!ack_callbacks_.empty()) { |
| 1824 ack_callbacks_.front().Run(); | 1832 ack_callbacks_.front().Run(); |
| 1825 ack_callbacks_.pop(); | 1833 ack_callbacks_.pop(); |
| 1826 } | 1834 } |
| 1827 } | 1835 } |
| 1828 | 1836 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 | 1883 |
| 1876 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { | 1884 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { |
| 1877 StopObservingRootWindow(); | 1885 StopObservingRootWindow(); |
| 1878 OnDetachCompositor(); | 1886 OnDetachCompositor(); |
| 1879 } | 1887 } |
| 1880 | 1888 |
| 1881 void RenderWidgetHostViewAndroid::OnAttachCompositor() { | 1889 void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
| 1882 DCHECK(content_view_core_); | 1890 DCHECK(content_view_core_); |
| 1883 if (!overscroll_controller_) | 1891 if (!overscroll_controller_) |
| 1884 overscroll_controller_ = CreateOverscrollController( | 1892 overscroll_controller_ = CreateOverscrollController( |
| 1885 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1893 content_view_core_, overscroll_refresh_handler_, |
| 1894 ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1886 ui::WindowAndroidCompositor* compositor = | 1895 ui::WindowAndroidCompositor* compositor = |
| 1887 view_.GetWindowAndroid()->GetCompositor(); | 1896 view_.GetWindowAndroid()->GetCompositor(); |
| 1888 delegated_frame_host_->RegisterFrameSinkHierarchy( | 1897 delegated_frame_host_->RegisterFrameSinkHierarchy( |
| 1889 compositor->GetFrameSinkId()); | 1898 compositor->GetFrameSinkId()); |
| 1890 } | 1899 } |
| 1891 | 1900 |
| 1892 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1901 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1893 DCHECK(content_view_core_); | 1902 DCHECK(content_view_core_); |
| 1894 DCHECK(using_browser_compositor_); | 1903 DCHECK(using_browser_compositor_); |
| 1895 RunAckCallbacks(); | 1904 RunAckCallbacks(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1990 case ui::MotionEvent::ACTION_UP: | 1999 case ui::MotionEvent::ACTION_UP: |
| 1991 case ui::MotionEvent::ACTION_POINTER_UP: | 2000 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1992 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 2001 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1993 delta.InMicroseconds(), 1, 1000000, 50); | 2002 delta.InMicroseconds(), 1, 1000000, 50); |
| 1994 default: | 2003 default: |
| 1995 return; | 2004 return; |
| 1996 } | 2005 } |
| 1997 } | 2006 } |
| 1998 | 2007 |
| 1999 } // namespace content | 2008 } // namespace content |
| OLD | NEW |