Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 1971023006: Add begin frame paused to android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sievers review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/common/view_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 if (!layer_.get()) 1406 if (!layer_.get())
1407 return; 1407 return;
1408 1408
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
1417 // again via |Show()|.
1418 if (!host_ || host_->is_hidden())
1419 return;
1420
1421 // Note that if we're not currently observing the root window, outstanding 1416 // Note that if we're not currently observing the root window, outstanding
1422 // vsync requests will be pushed if/when we resume observing in 1417 // vsync requests will be pushed if/when we resume observing in
1423 // |StartObservingRootWindow()|. 1418 // |StartObservingRootWindow()|.
1424 if (observing_root_window_ && should_request_vsync) 1419 if (observing_root_window_ && should_request_vsync)
1425 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); 1420 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate();
1426 } 1421 }
1427 1422
1428 void RenderWidgetHostViewAndroid::StartObservingRootWindow() { 1423 void RenderWidgetHostViewAndroid::StartObservingRootWindow() {
1429 DCHECK(content_view_core_); 1424 DCHECK(content_view_core_);
1430 // TODO(yusufo): This will need to have a better fallback for cases where 1425 // TODO(yusufo): This will need to have a better fallback for cases where
1431 // setContentViewCore is called with a valid ContentViewCore without a window. 1426 // setContentViewCore is called with a valid ContentViewCore without a window.
1432 DCHECK(content_view_core_->GetWindowAndroid()); 1427 DCHECK(content_view_core_->GetWindowAndroid());
1433 DCHECK(is_showing_); 1428 DCHECK(is_showing_);
1434 if (observing_root_window_) 1429 if (observing_root_window_)
1435 return; 1430 return;
1436 1431
1437 observing_root_window_ = true; 1432 observing_root_window_ = true;
1433 if (host_)
1434 host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), false));
1438 content_view_core_->GetWindowAndroid()->AddObserver(this); 1435 content_view_core_->GetWindowAndroid()->AddObserver(this);
1439 1436
1440 // Clear existing vsync requests to allow a request to the new window. 1437 // Clear existing vsync requests to allow a request to the new window.
1441 uint32_t outstanding_vsync_requests = outstanding_vsync_requests_; 1438 uint32_t outstanding_vsync_requests = outstanding_vsync_requests_;
1442 outstanding_vsync_requests_ = 0; 1439 outstanding_vsync_requests_ = 0;
1443 RequestVSyncUpdate(outstanding_vsync_requests); 1440 RequestVSyncUpdate(outstanding_vsync_requests);
1444 } 1441 }
1445 1442
1446 void RenderWidgetHostViewAndroid::StopObservingRootWindow() { 1443 void RenderWidgetHostViewAndroid::StopObservingRootWindow() {
1447 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) { 1444 if (!content_view_core_ || !(content_view_core_->GetWindowAndroid())) {
1448 DCHECK(!observing_root_window_); 1445 DCHECK(!observing_root_window_);
1449 return; 1446 return;
1450 } 1447 }
1451 1448
1452 if (!observing_root_window_) 1449 if (!observing_root_window_)
1453 return; 1450 return;
1454 1451
1455 // Reset window state variables to their defaults. 1452 // Reset window state variables to their defaults.
1456 is_window_activity_started_ = true; 1453 is_window_activity_started_ = true;
1457 is_window_visible_ = true; 1454 is_window_visible_ = true;
1458 observing_root_window_ = false; 1455 observing_root_window_ = false;
1456 if (host_)
1457 host_->Send(new ViewMsg_SetBeginFramePaused(host_->GetRoutingID(), true));
1459 content_view_core_->GetWindowAndroid()->RemoveObserver(this); 1458 content_view_core_->GetWindowAndroid()->RemoveObserver(this);
1460 } 1459 }
1461 1460
1462 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, 1461 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time,
1463 base::TimeDelta vsync_period) { 1462 base::TimeDelta vsync_period) {
1464 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", 1463 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame",
1465 "frame_time_us", frame_time.ToInternalValue()); 1464 "frame_time_us", frame_time.ToInternalValue());
1466 1465
1467 if (using_browser_compositor_) { 1466 if (using_browser_compositor_) {
1468 // TODO(brianderson): Replace this hardcoded deadline after Android 1467 // TODO(brianderson): Replace this hardcoded deadline after Android
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 void RenderWidgetHostViewAndroid::OnDetachCompositor() { 1866 void RenderWidgetHostViewAndroid::OnDetachCompositor() {
1868 DCHECK(content_view_core_); 1867 DCHECK(content_view_core_);
1869 DCHECK(using_browser_compositor_); 1868 DCHECK(using_browser_compositor_);
1870 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); 1869 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED);
1871 overscroll_controller_.reset(); 1870 overscroll_controller_.reset();
1872 } 1871 }
1873 1872
1874 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, 1873 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time,
1875 base::TimeDelta vsync_period) { 1874 base::TimeDelta vsync_period) {
1876 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); 1875 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync");
1877 if (!host_ || host_->is_hidden()) 1876 if (!host_)
1878 return; 1877 return;
1879 1878
1880 if (outstanding_vsync_requests_ & FLUSH_INPUT) { 1879 if (outstanding_vsync_requests_ & FLUSH_INPUT) {
1881 outstanding_vsync_requests_ &= ~FLUSH_INPUT; 1880 outstanding_vsync_requests_ &= ~FLUSH_INPUT;
1882 host_->FlushInput(); 1881 host_->FlushInput();
1883 } 1882 }
1884 1883
1885 if (outstanding_vsync_requests_ & BEGIN_FRAME || 1884 if (outstanding_vsync_requests_ & BEGIN_FRAME ||
1886 outstanding_vsync_requests_ & PERSISTENT_BEGIN_FRAME) { 1885 outstanding_vsync_requests_ & PERSISTENT_BEGIN_FRAME) {
1887 outstanding_vsync_requests_ &= ~BEGIN_FRAME; 1886 outstanding_vsync_requests_ &= ~BEGIN_FRAME;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 case ui::MotionEvent::ACTION_UP: 2045 case ui::MotionEvent::ACTION_UP:
2047 case ui::MotionEvent::ACTION_POINTER_UP: 2046 case ui::MotionEvent::ACTION_POINTER_UP:
2048 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", 2047 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED",
2049 delta.InMicroseconds(), 1, 1000000, 50); 2048 delta.InMicroseconds(), 1, 1000000, 50);
2050 default: 2049 default:
2051 return; 2050 return;
2052 } 2051 }
2053 } 2052 }
2054 2053
2055 } // namespace content 2054 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698