| 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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 | 1380 |
| 1381 observing_root_window_ = true; | 1381 observing_root_window_ = true; |
| 1382 if (host_) | 1382 if (host_) |
| 1383 host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), false)); | 1383 host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), false)); |
| 1384 content_view_core_->GetWindowAndroid()->AddObserver(this); | 1384 content_view_core_->GetWindowAndroid()->AddObserver(this); |
| 1385 | 1385 |
| 1386 // Clear existing vsync requests to allow a request to the new window. | 1386 // Clear existing vsync requests to allow a request to the new window. |
| 1387 uint32_t outstanding_vsync_requests = outstanding_vsync_requests_; | 1387 uint32_t outstanding_vsync_requests = outstanding_vsync_requests_; |
| 1388 outstanding_vsync_requests_ = 0; | 1388 outstanding_vsync_requests_ = 0; |
| 1389 RequestVSyncUpdate(outstanding_vsync_requests); | 1389 RequestVSyncUpdate(outstanding_vsync_requests); |
| 1390 |
| 1391 ui::WindowAndroidCompositor* compositor = |
| 1392 content_view_core_->GetWindowAndroid()->GetCompositor(); |
| 1393 if (compositor) { |
| 1394 delegated_frame_host_->RegisterSurfaceNamespaceHierarchy( |
| 1395 compositor->GetSurfaceClientId()); |
| 1396 } |
| 1390 } | 1397 } |
| 1391 | 1398 |
| 1392 void RenderWidgetHostViewAndroid::StopObservingRootWindow() { | 1399 void RenderWidgetHostViewAndroid::StopObservingRootWindow() { |
| 1393 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) { | 1400 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) { |
| 1394 DCHECK(!observing_root_window_); | 1401 DCHECK(!observing_root_window_); |
| 1395 return; | 1402 return; |
| 1396 } | 1403 } |
| 1397 | 1404 |
| 1398 if (!observing_root_window_) | 1405 if (!observing_root_window_) |
| 1399 return; | 1406 return; |
| 1400 | 1407 |
| 1401 // Reset window state variables to their defaults. | 1408 // Reset window state variables to their defaults. |
| 1402 is_window_activity_started_ = true; | 1409 is_window_activity_started_ = true; |
| 1403 is_window_visible_ = true; | 1410 is_window_visible_ = true; |
| 1404 observing_root_window_ = false; | 1411 observing_root_window_ = false; |
| 1405 if (host_) | 1412 if (host_) |
| 1406 host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), true)); | 1413 host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), true)); |
| 1407 content_view_core_->GetWindowAndroid()->RemoveObserver(this); | 1414 content_view_core_->GetWindowAndroid()->RemoveObserver(this); |
| 1415 // If the DFH has already been destroyed, it will have cleaned itself up. |
| 1416 // This happens in some WebView cases. |
| 1417 if (delegated_frame_host_) |
| 1418 delegated_frame_host_->UnregisterSurfaceNamespaceHierarchy(); |
| 1408 } | 1419 } |
| 1409 | 1420 |
| 1410 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, | 1421 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, |
| 1411 base::TimeDelta vsync_period) { | 1422 base::TimeDelta vsync_period) { |
| 1412 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", | 1423 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", |
| 1413 "frame_time_us", frame_time.ToInternalValue()); | 1424 "frame_time_us", frame_time.ToInternalValue()); |
| 1414 | 1425 |
| 1415 // Synchronous compositor does not use deadline-based scheduling. | 1426 // Synchronous compositor does not use deadline-based scheduling. |
| 1416 // TODO(brianderson): Replace this hardcoded deadline after Android | 1427 // TODO(brianderson): Replace this hardcoded deadline after Android |
| 1417 // switches to Surfaces and the Browser's commit isn't in the critcal path. | 1428 // switches to Surfaces and the Browser's commit isn't in the critcal path. |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { | 1805 void RenderWidgetHostViewAndroid::OnDetachedFromWindow() { |
| 1795 StopObservingRootWindow(); | 1806 StopObservingRootWindow(); |
| 1796 OnDetachCompositor(); | 1807 OnDetachCompositor(); |
| 1797 } | 1808 } |
| 1798 | 1809 |
| 1799 void RenderWidgetHostViewAndroid::OnAttachCompositor() { | 1810 void RenderWidgetHostViewAndroid::OnAttachCompositor() { |
| 1800 DCHECK(content_view_core_); | 1811 DCHECK(content_view_core_); |
| 1801 if (!overscroll_controller_) | 1812 if (!overscroll_controller_) |
| 1802 overscroll_controller_ = CreateOverscrollController( | 1813 overscroll_controller_ = CreateOverscrollController( |
| 1803 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); | 1814 content_view_core_, ui::GetScaleFactorForNativeView(GetNativeView())); |
| 1815 ui::WindowAndroidCompositor* compositor = |
| 1816 content_view_core_->GetWindowAndroid()->GetCompositor(); |
| 1817 delegated_frame_host_->RegisterSurfaceNamespaceHierarchy( |
| 1818 compositor->GetSurfaceClientId()); |
| 1804 } | 1819 } |
| 1805 | 1820 |
| 1806 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1821 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1807 DCHECK(content_view_core_); | 1822 DCHECK(content_view_core_); |
| 1808 DCHECK(using_browser_compositor_); | 1823 DCHECK(using_browser_compositor_); |
| 1809 RunAckCallbacks(); | 1824 RunAckCallbacks(); |
| 1810 overscroll_controller_.reset(); | 1825 overscroll_controller_.reset(); |
| 1826 delegated_frame_host_->UnregisterSurfaceNamespaceHierarchy(); |
| 1811 } | 1827 } |
| 1812 | 1828 |
| 1813 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1829 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
| 1814 base::TimeDelta vsync_period) { | 1830 base::TimeDelta vsync_period) { |
| 1815 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); | 1831 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); |
| 1816 if (!host_) | 1832 if (!host_) |
| 1817 return; | 1833 return; |
| 1818 | 1834 |
| 1819 if (outstanding_vsync_requests_ & FLUSH_INPUT) { | 1835 if (outstanding_vsync_requests_ & FLUSH_INPUT) { |
| 1820 outstanding_vsync_requests_ &= ~FLUSH_INPUT; | 1836 outstanding_vsync_requests_ &= ~FLUSH_INPUT; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1964 case ui::MotionEvent::ACTION_UP: | 1980 case ui::MotionEvent::ACTION_UP: |
| 1965 case ui::MotionEvent::ACTION_POINTER_UP: | 1981 case ui::MotionEvent::ACTION_POINTER_UP: |
| 1966 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1982 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 1967 delta.InMicroseconds(), 1, 1000000, 50); | 1983 delta.InMicroseconds(), 1, 1000000, 50); |
| 1968 default: | 1984 default: |
| 1969 return; | 1985 return; |
| 1970 } | 1986 } |
| 1971 } | 1987 } |
| 1972 | 1988 |
| 1973 } // namespace content | 1989 } // namespace content |
| OLD | NEW |