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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 } | 585 } |
586 | 586 |
587 void RenderWidgetHostViewAndroid::ReleaseLocksOnSurface() { | 587 void RenderWidgetHostViewAndroid::ReleaseLocksOnSurface() { |
588 if (!frame_evictor_->HasFrame()) { | 588 if (!frame_evictor_->HasFrame()) { |
589 DCHECK_EQ(locks_on_frame_count_, 0u); | 589 DCHECK_EQ(locks_on_frame_count_, 0u); |
590 return; | 590 return; |
591 } | 591 } |
592 while (locks_on_frame_count_ > 0) { | 592 while (locks_on_frame_count_ > 0) { |
593 UnlockCompositingSurface(); | 593 UnlockCompositingSurface(); |
594 } | 594 } |
595 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 595 RunAckCallbacks(); |
596 } | 596 } |
597 | 597 |
598 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { | 598 gfx::Rect RenderWidgetHostViewAndroid::GetViewBounds() const { |
599 if (!content_view_core_) | 599 if (!content_view_core_) |
600 return gfx::Rect(default_size_); | 600 return gfx::Rect(default_size_); |
601 | 601 |
602 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 602 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
603 switches::kEnableOSKOverscroll)) | 603 switches::kEnableOSKOverscroll)) |
604 return gfx::Rect(content_view_core_->GetViewSizeWithOSKHidden()); | 604 return gfx::Rect(content_view_core_->GetViewSizeWithOSKHidden()); |
605 | 605 |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 if (!has_content) { | 1053 if (!has_content) { |
1054 DestroyDelegatedContent(); | 1054 DestroyDelegatedContent(); |
1055 } else { | 1055 } else { |
1056 SubmitCompositorFrame(std::move(frame)); | 1056 SubmitCompositorFrame(std::move(frame)); |
1057 view_.GetLayer()->SetIsDrawable(true); | 1057 view_.GetLayer()->SetIsDrawable(true); |
1058 view_.GetLayer()->SetContentsOpaque(true); | 1058 view_.GetLayer()->SetContentsOpaque(true); |
1059 view_.GetLayer()->SetBounds(texture_size_in_layer_); | 1059 view_.GetLayer()->SetBounds(texture_size_in_layer_); |
1060 } | 1060 } |
1061 | 1061 |
1062 if (host_->is_hidden()) | 1062 if (host_->is_hidden()) |
1063 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1063 RunAckCallbacks(); |
1064 frame_evictor_->SwappedFrame(!host_->is_hidden()); | 1064 frame_evictor_->SwappedFrame(!host_->is_hidden()); |
1065 | 1065 |
1066 // As the metadata update may trigger view invalidation, always call it after | 1066 // As the metadata update may trigger view invalidation, always call it after |
1067 // any potential compositor scheduling. | 1067 // any potential compositor scheduling. |
1068 OnFrameMetadataUpdated(std::move(metadata)); | 1068 OnFrameMetadataUpdated(std::move(metadata)); |
1069 } | 1069 } |
1070 | 1070 |
1071 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( | 1071 void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( |
1072 uint32_t output_surface_id, | 1072 uint32_t output_surface_id, |
1073 cc::CompositorFrame frame) { | 1073 cc::CompositorFrame frame) { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 DCHECK(!is_showing_); | 1330 DCHECK(!is_showing_); |
1331 StopObservingRootWindow(); | 1331 StopObservingRootWindow(); |
1332 } | 1332 } |
1333 | 1333 |
1334 if (!host_ || host_->is_hidden()) | 1334 if (!host_ || host_->is_hidden()) |
1335 return; | 1335 return; |
1336 | 1336 |
1337 if (overscroll_controller_) | 1337 if (overscroll_controller_) |
1338 overscroll_controller_->Disable(); | 1338 overscroll_controller_->Disable(); |
1339 | 1339 |
1340 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1340 RunAckCallbacks(); |
1341 | 1341 |
1342 // Inform the renderer that we are being hidden so it can reduce its resource | 1342 // Inform the renderer that we are being hidden so it can reduce its resource |
1343 // utilization. | 1343 // utilization. |
1344 host_->WasHidden(); | 1344 host_->WasHidden(); |
1345 } | 1345 } |
1346 | 1346 |
1347 void RenderWidgetHostViewAndroid::AttachLayers() { | 1347 void RenderWidgetHostViewAndroid::AttachLayers() { |
1348 if (!content_view_core_) | 1348 if (!content_view_core_) |
1349 return; | 1349 return; |
1350 if (!view_.GetLayer()) | 1350 if (!view_.GetLayer()) |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1739 overscroll_controller_ = CreateOverscrollController( | 1739 overscroll_controller_ = CreateOverscrollController( |
1740 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1740 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); |
1741 } | 1741 } |
1742 | 1742 |
1743 if (!sync_compositor_) { | 1743 if (!sync_compositor_) { |
1744 sync_compositor_ = SynchronousCompositorHost::Create( | 1744 sync_compositor_ = SynchronousCompositorHost::Create( |
1745 this, content_view_core_->GetWebContents()); | 1745 this, content_view_core_->GetWebContents()); |
1746 } | 1746 } |
1747 } | 1747 } |
1748 | 1748 |
1749 void RenderWidgetHostViewAndroid::RunAckCallbacks( | 1749 void RenderWidgetHostViewAndroid::RunAckCallbacks() { |
1750 cc::SurfaceDrawStatus status) { | |
1751 while (!ack_callbacks_.empty()) { | 1750 while (!ack_callbacks_.empty()) { |
1752 ack_callbacks_.front().Run(); | 1751 ack_callbacks_.front().Run(); |
1753 ack_callbacks_.pop(); | 1752 ack_callbacks_.pop(); |
1754 } | 1753 } |
1755 } | 1754 } |
1756 | 1755 |
1757 void RenderWidgetHostViewAndroid::OnGestureEvent( | 1756 void RenderWidgetHostViewAndroid::OnGestureEvent( |
1758 const ui::GestureEventData& gesture) { | 1757 const ui::GestureEventData& gesture) { |
1759 blink::WebGestureEvent web_gesture = | 1758 blink::WebGestureEvent web_gesture = |
1760 ui::CreateWebGestureEventFromGestureEventData(gesture); | 1759 ui::CreateWebGestureEventFromGestureEventData(gesture); |
1761 // TODO(jdduke): Remove this workaround after Android fixes UiAutomator to | 1760 // TODO(jdduke): Remove this workaround after Android fixes UiAutomator to |
1762 // stop providing shift meta values to synthetic MotionEvents. This prevents | 1761 // stop providing shift meta values to synthetic MotionEvents. This prevents |
1763 // unintended shift+click interpretation of all accessibility clicks. | 1762 // unintended shift+click interpretation of all accessibility clicks. |
1764 // See crbug.com/443247. | 1763 // See crbug.com/443247. |
1765 if (web_gesture.type == blink::WebInputEvent::GestureTap && | 1764 if (web_gesture.type == blink::WebInputEvent::GestureTap && |
1766 web_gesture.modifiers == blink::WebInputEvent::ShiftKey) { | 1765 web_gesture.modifiers == blink::WebInputEvent::ShiftKey) { |
1767 web_gesture.modifiers = 0; | 1766 web_gesture.modifiers = 0; |
1768 } | 1767 } |
1769 SendGestureEvent(web_gesture); | 1768 SendGestureEvent(web_gesture); |
1770 } | 1769 } |
1771 | 1770 |
1772 void RenderWidgetHostViewAndroid::OnContentViewCoreDestroyed() { | 1771 void RenderWidgetHostViewAndroid::OnContentViewCoreDestroyed() { |
1773 SetContentViewCore(NULL); | 1772 SetContentViewCore(NULL); |
1774 } | 1773 } |
1775 | 1774 |
1776 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { | 1775 void RenderWidgetHostViewAndroid::OnCompositingDidCommit() { |
1777 RunAckCallbacks(cc::SurfaceDrawStatus::DRAWN); | 1776 RunAckCallbacks(); |
1778 } | 1777 } |
1779 | 1778 |
1780 void RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged(bool visible) { | 1779 void RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged(bool visible) { |
1781 TRACE_EVENT1("browser", | 1780 TRACE_EVENT1("browser", |
1782 "RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged", | 1781 "RenderWidgetHostViewAndroid::OnRootWindowVisibilityChanged", |
1783 "visible", visible); | 1782 "visible", visible); |
1784 DCHECK(observing_root_window_); | 1783 DCHECK(observing_root_window_); |
1785 if (is_window_visible_ == visible) | 1784 if (is_window_visible_ == visible) |
1786 return; | 1785 return; |
1787 | 1786 |
(...skipping 21 matching lines...) Expand all Loading... |
1809 void RenderWidgetHostViewAndroid::OnAttachCompositor() { | 1808 void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
1810 DCHECK(content_view_core_); | 1809 DCHECK(content_view_core_); |
1811 if (!overscroll_controller_) | 1810 if (!overscroll_controller_) |
1812 overscroll_controller_ = CreateOverscrollController( | 1811 overscroll_controller_ = CreateOverscrollController( |
1813 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1812 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); |
1814 } | 1813 } |
1815 | 1814 |
1816 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1815 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
1817 DCHECK(content_view_core_); | 1816 DCHECK(content_view_core_); |
1818 DCHECK(using_browser_compositor_); | 1817 DCHECK(using_browser_compositor_); |
1819 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1818 RunAckCallbacks(); |
1820 overscroll_controller_.reset(); | 1819 overscroll_controller_.reset(); |
1821 } | 1820 } |
1822 | 1821 |
1823 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1822 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
1824 base::TimeDelta vsync_period) { | 1823 base::TimeDelta vsync_period) { |
1825 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); | 1824 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); |
1826 if (!host_) | 1825 if (!host_) |
1827 return; | 1826 return; |
1828 | 1827 |
1829 if (outstanding_vsync_requests_ & FLUSH_INPUT) { | 1828 if (outstanding_vsync_requests_ & FLUSH_INPUT) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1996 case ui::MotionEvent::ACTION_UP: | 1995 case ui::MotionEvent::ACTION_UP: |
1997 case ui::MotionEvent::ACTION_POINTER_UP: | 1996 case ui::MotionEvent::ACTION_POINTER_UP: |
1998 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1997 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
1999 delta.InMicroseconds(), 1, 1000000, 50); | 1998 delta.InMicroseconds(), 1, 1000000, 50); |
2000 default: | 1999 default: |
2001 return; | 2000 return; |
2002 } | 2001 } |
2003 } | 2002 } |
2004 | 2003 |
2005 } // namespace content | 2004 } // namespace content |
OLD | NEW |