Chromium Code Reviews| 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 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1409 content_view_core_->RemoveLayer(layer_); | 1409 content_view_core_->RemoveLayer(layer_); |
| 1410 } | 1410 } |
| 1411 | 1411 |
| 1412 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32_t requests) { | 1412 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32_t requests) { |
| 1413 bool should_request_vsync = !outstanding_vsync_requests_ && requests; | 1413 bool should_request_vsync = !outstanding_vsync_requests_ && requests; |
| 1414 outstanding_vsync_requests_ |= requests; | 1414 outstanding_vsync_requests_ |= requests; |
| 1415 | 1415 |
| 1416 // If the host has been hidden, defer vsync requests until it is shown | 1416 // If the host has been hidden, defer vsync requests until it is shown |
| 1417 // again via |Show()|. | 1417 // again via |Show()|. |
| 1418 if (!host_ || host_->is_hidden()) | 1418 if (!host_ || host_->is_hidden()) |
| 1419 return; | 1419 return; |
|
no sievers
2016/06/01 20:12:53
remove this
boliu
2016/06/01 21:07:26
Done.
| |
| 1420 | 1420 |
| 1421 // Note that if we're not currently observing the root window, outstanding | 1421 // Note that if we're not currently observing the root window, outstanding |
| 1422 // vsync requests will be pushed if/when we resume observing in | 1422 // vsync requests will be pushed if/when we resume observing in |
| 1423 // |StartObservingRootWindow()|. | 1423 // |StartObservingRootWindow()|. |
| 1424 if (observing_root_window_ && should_request_vsync) | 1424 if (observing_root_window_ && should_request_vsync) |
| 1425 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); | 1425 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); |
| 1426 } | 1426 } |
| 1427 | 1427 |
| 1428 void RenderWidgetHostViewAndroid::StartObservingRootWindow() { | 1428 void RenderWidgetHostViewAndroid::StartObservingRootWindow() { |
| 1429 DCHECK(content_view_core_); | 1429 DCHECK(content_view_core_); |
| 1430 // TODO(yusufo): This will need to have a better fallback for cases where | 1430 // TODO(yusufo): This will need to have a better fallback for cases where |
| 1431 // setContentViewCore is called with a valid ContentViewCore without a window. | 1431 // setContentViewCore is called with a valid ContentViewCore without a window. |
| 1432 DCHECK(content_view_core_->GetWindowAndroid()); | 1432 DCHECK(content_view_core_->GetWindowAndroid()); |
| 1433 DCHECK(is_showing_); | 1433 DCHECK(is_showing_); |
| 1434 if (observing_root_window_) | 1434 if (observing_root_window_) |
| 1435 return; | 1435 return; |
| 1436 | 1436 |
| 1437 observing_root_window_ = true; | 1437 observing_root_window_ = true; |
| 1438 if (host_) | |
| 1439 host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), false)); | |
| 1438 content_view_core_->GetWindowAndroid()->AddObserver(this); | 1440 content_view_core_->GetWindowAndroid()->AddObserver(this); |
| 1439 | 1441 |
| 1440 // Clear existing vsync requests to allow a request to the new window. | 1442 // Clear existing vsync requests to allow a request to the new window. |
| 1441 uint32_t outstanding_vsync_requests = outstanding_vsync_requests_; | 1443 uint32_t outstanding_vsync_requests = outstanding_vsync_requests_; |
| 1442 outstanding_vsync_requests_ = 0; | 1444 outstanding_vsync_requests_ = 0; |
| 1443 RequestVSyncUpdate(outstanding_vsync_requests); | 1445 RequestVSyncUpdate(outstanding_vsync_requests); |
| 1444 } | 1446 } |
| 1445 | 1447 |
| 1446 void RenderWidgetHostViewAndroid::StopObservingRootWindow() { | 1448 void RenderWidgetHostViewAndroid::StopObservingRootWindow() { |
| 1447 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) { | 1449 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) { |
| 1448 DCHECK(!observing_root_window_); | 1450 DCHECK(!observing_root_window_); |
| 1449 return; | 1451 return; |
| 1450 } | 1452 } |
| 1451 | 1453 |
| 1452 if (!observing_root_window_) | 1454 if (!observing_root_window_) |
| 1453 return; | 1455 return; |
| 1454 | 1456 |
| 1455 // Reset window state variables to their defaults. | 1457 // Reset window state variables to their defaults. |
| 1456 is_window_activity_started_ = true; | 1458 is_window_activity_started_ = true; |
| 1457 is_window_visible_ = true; | 1459 is_window_visible_ = true; |
| 1458 observing_root_window_ = false; | 1460 observing_root_window_ = false; |
| 1461 if (host_) | |
| 1462 host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), true)); | |
| 1459 content_view_core_->GetWindowAndroid()->RemoveObserver(this); | 1463 content_view_core_->GetWindowAndroid()->RemoveObserver(this); |
| 1460 } | 1464 } |
| 1461 | 1465 |
| 1462 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, | 1466 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, |
| 1463 base::TimeDelta vsync_period) { | 1467 base::TimeDelta vsync_period) { |
| 1464 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", | 1468 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", |
| 1465 "frame_time_us", frame_time.ToInternalValue()); | 1469 "frame_time_us", frame_time.ToInternalValue()); |
| 1466 | 1470 |
| 1467 if (using_browser_compositor_) { | 1471 if (using_browser_compositor_) { |
| 1468 // TODO(brianderson): Replace this hardcoded deadline after Android | 1472 // TODO(brianderson): Replace this hardcoded deadline after Android |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1867 void RenderWidgetHostViewAndroid::OnDetachCompositor() { | 1871 void RenderWidgetHostViewAndroid::OnDetachCompositor() { |
| 1868 DCHECK(content_view_core_); | 1872 DCHECK(content_view_core_); |
| 1869 DCHECK(using_browser_compositor_); | 1873 DCHECK(using_browser_compositor_); |
| 1870 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); | 1874 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); |
| 1871 overscroll_controller_.reset(); | 1875 overscroll_controller_.reset(); |
| 1872 } | 1876 } |
| 1873 | 1877 |
| 1874 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, | 1878 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, |
| 1875 base::TimeDelta vsync_period) { | 1879 base::TimeDelta vsync_period) { |
| 1876 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); | 1880 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); |
| 1877 if (!host_ || host_->is_hidden()) | 1881 if (!host_ || host_->is_hidden()) |
|
no sievers
2016/06/01 20:12:53
remove "| host_->is_hidden()'
boliu
2016/06/01 21:07:26
Done.
| |
| 1878 return; | 1882 return; |
| 1879 | 1883 |
| 1880 if (outstanding_vsync_requests_ & FLUSH_INPUT) { | 1884 if (outstanding_vsync_requests_ & FLUSH_INPUT) { |
| 1881 outstanding_vsync_requests_ &= ~FLUSH_INPUT; | 1885 outstanding_vsync_requests_ &= ~FLUSH_INPUT; |
| 1882 host_->FlushInput(); | 1886 host_->FlushInput(); |
| 1883 } | 1887 } |
| 1884 | 1888 |
| 1885 if (outstanding_vsync_requests_ & BEGIN_FRAME || | 1889 if (outstanding_vsync_requests_ & BEGIN_FRAME || |
| 1886 outstanding_vsync_requests_ & PERSISTENT_BEGIN_FRAME) { | 1890 outstanding_vsync_requests_ & PERSISTENT_BEGIN_FRAME) { |
| 1887 outstanding_vsync_requests_ &= ~BEGIN_FRAME; | 1891 outstanding_vsync_requests_ &= ~BEGIN_FRAME; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2046 case ui::MotionEvent::ACTION_UP: | 2050 case ui::MotionEvent::ACTION_UP: |
| 2047 case ui::MotionEvent::ACTION_POINTER_UP: | 2051 case ui::MotionEvent::ACTION_POINTER_UP: |
| 2048 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 2052 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
| 2049 delta.InMicroseconds(), 1, 1000000, 50); | 2053 delta.InMicroseconds(), 1, 1000000, 50); |
| 2050 default: | 2054 default: |
| 2051 return; | 2055 return; |
| 2052 } | 2056 } |
| 2053 } | 2057 } |
| 2054 | 2058 |
| 2055 } // namespace content | 2059 } // namespace content |
| OLD | NEW |