| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #include "gpu/command_buffer/client/gles2_interface.h" | 72 #include "gpu/command_buffer/client/gles2_interface.h" |
| 73 #include "gpu/config/gpu_driver_bug_workaround_type.h" | 73 #include "gpu/config/gpu_driver_bug_workaround_type.h" |
| 74 #include "ipc/ipc_message_macros.h" | 74 #include "ipc/ipc_message_macros.h" |
| 75 #include "ipc/ipc_message_start.h" | 75 #include "ipc/ipc_message_start.h" |
| 76 #include "skia/ext/image_operations.h" | 76 #include "skia/ext/image_operations.h" |
| 77 #include "third_party/khronos/GLES2/gl2.h" | 77 #include "third_party/khronos/GLES2/gl2.h" |
| 78 #include "third_party/khronos/GLES2/gl2ext.h" | 78 #include "third_party/khronos/GLES2/gl2ext.h" |
| 79 #include "third_party/skia/include/core/SkCanvas.h" | 79 #include "third_party/skia/include/core/SkCanvas.h" |
| 80 #include "ui/android/window_android.h" | 80 #include "ui/android/window_android.h" |
| 81 #include "ui/android/window_android_compositor.h" | 81 #include "ui/android/window_android_compositor.h" |
| 82 #include "ui/base/layout.h" |
| 82 #include "ui/display/display.h" | 83 #include "ui/display/display.h" |
| 83 #include "ui/display/screen.h" | 84 #include "ui/display/screen.h" |
| 84 #include "ui/events/blink/blink_event_util.h" | 85 #include "ui/events/blink/blink_event_util.h" |
| 85 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 86 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| 86 #include "ui/events/gesture_detection/motion_event.h" | 87 #include "ui/events/gesture_detection/motion_event.h" |
| 87 #include "ui/gfx/android/device_display_info.h" | 88 #include "ui/gfx/android/device_display_info.h" |
| 88 #include "ui/gfx/android/java_bitmap.h" | 89 #include "ui/gfx/android/java_bitmap.h" |
| 89 #include "ui/gfx/android/view_configuration.h" | 90 #include "ui/gfx/android/view_configuration.h" |
| 90 #include "ui/gfx/geometry/dip_util.h" | 91 #include "ui/gfx/geometry/dip_util.h" |
| 91 #include "ui/gfx/geometry/size_conversions.h" | 92 #include "ui/gfx/geometry/size_conversions.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 config.enable_adaptive_handle_orientation = | 264 config.enable_adaptive_handle_orientation = |
| 264 base::CommandLine::ForCurrentProcess()->HasSwitch( | 265 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 265 switches::kEnableAdaptiveSelectionHandleOrientation); | 266 switches::kEnableAdaptiveSelectionHandleOrientation); |
| 266 config.enable_longpress_drag_selection = | 267 config.enable_longpress_drag_selection = |
| 267 base::CommandLine::ForCurrentProcess()->HasSwitch( | 268 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 268 switches::kEnableLongpressDragSelection); | 269 switches::kEnableLongpressDragSelection); |
| 269 return base::WrapUnique(new ui::TouchSelectionController(client, config)); | 270 return base::WrapUnique(new ui::TouchSelectionController(client, config)); |
| 270 } | 271 } |
| 271 | 272 |
| 272 std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( | 273 std::unique_ptr<OverscrollControllerAndroid> CreateOverscrollController( |
| 273 ContentViewCoreImpl* content_view_core) { | 274 ContentViewCoreImpl* content_view_core, |
| 274 return base::WrapUnique(new OverscrollControllerAndroid(content_view_core)); | 275 float dpi_scale) { |
| 276 return base::WrapUnique( |
| 277 new OverscrollControllerAndroid(content_view_core, dpi_scale)); |
| 275 } | 278 } |
| 276 | 279 |
| 277 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { | 280 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
| 278 gfx::RectF rect = controller.GetRectBetweenBounds(); | 281 gfx::RectF rect = controller.GetRectBetweenBounds(); |
| 279 if (rect.IsEmpty()) | 282 if (rect.IsEmpty()) |
| 280 return rect; | 283 return rect; |
| 281 | 284 |
| 282 rect.Union(controller.GetStartHandleRect()); | 285 rect.Union(controller.GetStartHandleRect()); |
| 283 rect.Union(controller.GetEndHandleRect()); | 286 rect.Union(controller.GetEndHandleRect()); |
| 284 return rect; | 287 return rect; |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 } | 1180 } |
| 1178 content_view_core_->OnSelectionEvent( | 1181 content_view_core_->OnSelectionEvent( |
| 1179 event, selection_controller_->GetStartPosition(), | 1182 event, selection_controller_->GetStartPosition(), |
| 1180 GetSelectionRect(*selection_controller_)); | 1183 GetSelectionRect(*selection_controller_)); |
| 1181 } | 1184 } |
| 1182 | 1185 |
| 1183 std::unique_ptr<ui::TouchHandleDrawable> | 1186 std::unique_ptr<ui::TouchHandleDrawable> |
| 1184 RenderWidgetHostViewAndroid::CreateDrawable() { | 1187 RenderWidgetHostViewAndroid::CreateDrawable() { |
| 1185 DCHECK(content_view_core_); | 1188 DCHECK(content_view_core_); |
| 1186 if (!using_browser_compositor_) | 1189 if (!using_browser_compositor_) |
| 1187 return PopupTouchHandleDrawable::Create(content_view_core_); | 1190 return PopupTouchHandleDrawable::Create( |
| 1191 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1188 | 1192 |
| 1189 return std::unique_ptr< | 1193 return std::unique_ptr< |
| 1190 ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( | 1194 ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( |
| 1191 content_view_core_->GetLayer(), content_view_core_->GetDpiScale(), | 1195 content_view_core_->GetLayer(), |
| 1196 ui::GetScaleFactorForNativeView(GetNativeView()), |
| 1192 // Use the activity context (instead of the application context) to ensure | 1197 // Use the activity context (instead of the application context) to ensure |
| 1193 // proper handle theming. | 1198 // proper handle theming. |
| 1194 content_view_core_->GetContext().obj())); | 1199 content_view_core_->GetContext().obj())); |
| 1195 } | 1200 } |
| 1196 | 1201 |
| 1197 void RenderWidgetHostViewAndroid::SynchronousCopyContents( | 1202 void RenderWidgetHostViewAndroid::SynchronousCopyContents( |
| 1198 const gfx::Rect& src_subrect_in_pixel, | 1203 const gfx::Rect& src_subrect_in_pixel, |
| 1199 const gfx::Size& dst_size_in_pixel, | 1204 const gfx::Size& dst_size_in_pixel, |
| 1200 const ReadbackRequestCallback& callback, | 1205 const ReadbackRequestCallback& callback, |
| 1201 const SkColorType color_type) { | 1206 const SkColorType color_type) { |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1728 StartObservingRootWindow(); | 1733 StartObservingRootWindow(); |
| 1729 | 1734 |
| 1730 if (resize) | 1735 if (resize) |
| 1731 WasResized(); | 1736 WasResized(); |
| 1732 | 1737 |
| 1733 if (!selection_controller_) | 1738 if (!selection_controller_) |
| 1734 selection_controller_ = CreateSelectionController(this, content_view_core_); | 1739 selection_controller_ = CreateSelectionController(this, content_view_core_); |
| 1735 | 1740 |
| 1736 if (!overscroll_controller_ && | 1741 if (!overscroll_controller_ && |
| 1737 content_view_core_->GetWindowAndroid()->GetCompositor()) { | 1742 content_view_core_->GetWindowAndroid()->GetCompositor()) { |
| 1738 overscroll_controller_ = CreateOverscrollController(content_view_core_); | 1743 overscroll_controller_ = CreateOverscrollController( |
| 1744 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1739 } | 1745 } |
| 1740 | 1746 |
| 1741 if (!sync_compositor_) { | 1747 if (!sync_compositor_) { |
| 1742 sync_compositor_ = SynchronousCompositorHost::Create( | 1748 sync_compositor_ = SynchronousCompositorHost::Create( |
| 1743 this, content_view_core_->GetWebContents()); | 1749 this, content_view_core_->GetWebContents()); |
| 1744 } | 1750 } |
| 1745 } | 1751 } |
| 1746 | 1752 |
| 1747 void RenderWidgetHostViewAndroid::RunAckCallbacks( | 1753 void RenderWidgetHostViewAndroid::RunAckCallbacks( |
| 1748 cc::SurfaceDrawStatus status) { | 1754 cc::SurfaceDrawStatus status) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1800 } | 1806 } |
| 1801 | 1807 |
| 1802 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { | 1808 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { |
| 1803 StopObservingRootWindow(); | 1809 StopObservingRootWindow(); |
| 1804 OnDetachCompositor(); | 1810 OnDetachCompositor(); |
| 1805 } | 1811 } |
| 1806 | 1812 |
| 1807 void RenderWidgetHostViewAndroid::OnAttachCompositor() { | 1813 void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
| 1808 DCHECK(content_view_core_); | 1814 DCHECK(content_view_core_); |
| 1809 if (!overscroll_controller_) | 1815 if (!overscroll_controller_) |
| 1810 overscroll_controller_ = CreateOverscrollController(content_view_core_); | 1816 overscroll_controller_ = CreateOverscrollController( |
| 1817 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1811 } | 1818 } |
| 1812 | 1819 |
| 1813 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1820 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1814 DCHECK(content_view_core_); | 1821 DCHECK(content_view_core_); |
| 1815 DCHECK(using_browser_compositor_); | 1822 DCHECK(using_browser_compositor_); |
| 1816 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1823 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); |
| 1817 overscroll_controller_.reset(); | 1824 overscroll_controller_.reset(); |
| 1818 } | 1825 } |
| 1819 | 1826 |
| 1820 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1827 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1993 case ui::MotionEvent::ACTION_UP: | 2000 case ui::MotionEvent::ACTION_UP: |
| 1994 case ui::MotionEvent::ACTION_POINTER_UP: | 2001 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1995 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 2002 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1996 delta.InMicroseconds(), 1, 1000000, 50); | 2003 delta.InMicroseconds(), 1, 1000000, 50); |
| 1997 default: | 2004 default: |
| 1998 return; | 2005 return; |
| 1999 } | 2006 } |
| 2000 } | 2007 } |
| 2001 | 2008 |
| 2002 } // namespace content | 2009 } // namespace content |
| OLD | NEW |