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

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

Issue 817603002: cc: Make scheduling be driven by vsync for android webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix regression caused by last patch on dynamic pages Created 5 years, 10 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
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 "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 SkColor color) { 740 SkColor color) {
741 if (cached_background_color_ == color) 741 if (cached_background_color_ == color)
742 return; 742 return;
743 743
744 cached_background_color_ = color; 744 cached_background_color_ = color;
745 if (content_view_core_) 745 if (content_view_core_)
746 content_view_core_->OnBackgroundColorChanged(color); 746 content_view_core_->OnBackgroundColorChanged(color);
747 } 747 }
748 748
749 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames(bool enabled) { 749 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames(bool enabled) {
750 DCHECK(using_browser_compositor_);
751 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames", 750 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames",
752 "enabled", enabled); 751 "enabled", enabled);
753 if (enabled) 752 if (enabled)
754 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); 753 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME);
755 else 754 else
756 outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME; 755 outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME;
757 } 756 }
758 757
759 void RenderWidgetHostViewAndroid::OnStartContentIntent( 758 void RenderWidgetHostViewAndroid::OnStartContentIntent(
760 const GURL& content_url) { 759 const GURL& content_url) {
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 1369
1371 if (!layer_.get()) 1370 if (!layer_.get())
1372 return; 1371 return;
1373 1372
1374 content_view_core_->RemoveLayer(layer_); 1373 content_view_core_->RemoveLayer(layer_);
1375 if (overscroll_controller_) 1374 if (overscroll_controller_)
1376 overscroll_controller_->Disable(); 1375 overscroll_controller_->Disable();
1377 } 1376 }
1378 1377
1379 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32 requests) { 1378 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32 requests) {
1380 // The synchronous compositor does not requre BeginFrame messages.
1381 if (!using_browser_compositor_)
1382 requests &= FLUSH_INPUT;
1383
1384 bool should_request_vsync = !outstanding_vsync_requests_ && requests; 1379 bool should_request_vsync = !outstanding_vsync_requests_ && requests;
1385 outstanding_vsync_requests_ |= requests; 1380 outstanding_vsync_requests_ |= requests;
1386 // Note that if we're not currently observing the root window, outstanding 1381 // Note that if we're not currently observing the root window, outstanding
1387 // vsync requests will be pushed if/when we resume observing in 1382 // vsync requests will be pushed if/when we resume observing in
1388 // |StartObservingRootWindow()|. 1383 // |StartObservingRootWindow()|.
1389 if (observing_root_window_ && should_request_vsync) 1384 if (observing_root_window_ && should_request_vsync)
1390 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate(); 1385 content_view_core_->GetWindowAndroid()->RequestVSyncUpdate();
1391 } 1386 }
1392 1387
1393 void RenderWidgetHostViewAndroid::StartObservingRootWindow() { 1388 void RenderWidgetHostViewAndroid::StartObservingRootWindow() {
(...skipping 20 matching lines...) Expand all
1414 return; 1409 return;
1415 1410
1416 observing_root_window_ = false; 1411 observing_root_window_ = false;
1417 content_view_core_->GetWindowAndroid()->RemoveObserver(this); 1412 content_view_core_->GetWindowAndroid()->RemoveObserver(this);
1418 } 1413 }
1419 1414
1420 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, 1415 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time,
1421 base::TimeDelta vsync_period) { 1416 base::TimeDelta vsync_period) {
1422 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", 1417 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame",
1423 "frame_time_us", frame_time.ToInternalValue()); 1418 "frame_time_us", frame_time.ToInternalValue());
1424 base::TimeTicks display_time = frame_time + vsync_period;
1425 1419
1426 base::TimeTicks deadline = 1420 if (using_browser_compositor_) {
1427 display_time - host_->GetEstimatedBrowserCompositeTime(); 1421 base::TimeTicks display_time = frame_time + vsync_period;
1428 1422
1429 host_->Send(new ViewMsg_BeginFrame( 1423 base::TimeTicks deadline =
1430 host_->GetRoutingID(), 1424 display_time - host_->GetEstimatedBrowserCompositeTime();
1431 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, 1425
1432 vsync_period, cc::BeginFrameArgs::NORMAL))); 1426 host_->Send(new ViewMsg_BeginFrame(
1427 host_->GetRoutingID(),
1428 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline,
1429 vsync_period, cc::BeginFrameArgs::NORMAL)));
1430 } else {
1431 SynchronousCompositorImpl* compositor = SynchronousCompositorImpl::FromID(
1432 host_->GetProcess()->GetID(), host_->GetRoutingID());
1433
1434 compositor->SendBeginFrame(cc::BeginFrameArgs::Create(
1435 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period,
1436 cc::BeginFrameArgs::NORMAL));
1437 }
1433 } 1438 }
1434 1439
1435 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { 1440 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) {
1436 bool needs_animate = false; 1441 bool needs_animate = false;
1437 if (overscroll_controller_) { 1442 if (overscroll_controller_) {
1438 needs_animate |= overscroll_controller_->Animate( 1443 needs_animate |= overscroll_controller_->Animate(
1439 frame_time, content_view_core_->GetLayer().get()); 1444 frame_time, content_view_core_->GetLayer().get());
1440 } 1445 }
1441 if (selection_controller_) 1446 if (selection_controller_)
1442 needs_animate |= selection_controller_->Animate(frame_time); 1447 needs_animate |= selection_controller_->Animate(frame_time);
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 RunAckCallbacks(); 1749 RunAckCallbacks();
1745 overscroll_controller_.reset(); 1750 overscroll_controller_.reset();
1746 } 1751 }
1747 1752
1748 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, 1753 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time,
1749 base::TimeDelta vsync_period) { 1754 base::TimeDelta vsync_period) {
1750 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); 1755 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync");
1751 if (!host_) 1756 if (!host_)
1752 return; 1757 return;
1753 1758
1754 const uint32 current_vsync_requests = outstanding_vsync_requests_; 1759 if (outstanding_vsync_requests_ & FLUSH_INPUT) {
1755 outstanding_vsync_requests_ = 0; 1760 outstanding_vsync_requests_ &= ~FLUSH_INPUT;
1761 host_->FlushInput();
1762 }
1756 1763
1757 if (current_vsync_requests & FLUSH_INPUT) 1764 if (outstanding_vsync_requests_ & BEGIN_FRAME ||
1758 host_->FlushInput(); 1765 outstanding_vsync_requests_ & PERSISTENT_BEGIN_FRAME) {
1759 1766 outstanding_vsync_requests_ &= ~BEGIN_FRAME;
1760 if (current_vsync_requests & BEGIN_FRAME ||
1761 current_vsync_requests & PERSISTENT_BEGIN_FRAME) {
1762 SendBeginFrame(frame_time, vsync_period); 1767 SendBeginFrame(frame_time, vsync_period);
1763 } 1768 }
1764 1769
1765 if (current_vsync_requests & PERSISTENT_BEGIN_FRAME) 1770 // This allows for SendBeginFrame to modify outstanding_vsync_requests.
1766 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); 1771 uint32 outstanding_vsync_requests = outstanding_vsync_requests_;
1772 outstanding_vsync_requests_ = 0;
1773 RequestVSyncUpdate(outstanding_vsync_requests);
1767 } 1774 }
1768 1775
1769 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) { 1776 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) {
1770 if (Animate(begin_frame_time)) 1777 if (Animate(begin_frame_time))
1771 SetNeedsAnimate(); 1778 SetNeedsAnimate();
1772 } 1779 }
1773 1780
1774 void RenderWidgetHostViewAndroid::OnLostResources() { 1781 void RenderWidgetHostViewAndroid::OnLostResources() {
1775 ReleaseLocksOnSurface(); 1782 ReleaseLocksOnSurface();
1776 if (layer_.get()) 1783 if (layer_.get())
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 results->orientationAngle = display.RotationAsDegree(); 1918 results->orientationAngle = display.RotationAsDegree();
1912 results->orientationType = 1919 results->orientationType =
1913 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 1920 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
1914 gfx::DeviceDisplayInfo info; 1921 gfx::DeviceDisplayInfo info;
1915 results->depth = info.GetBitsPerPixel(); 1922 results->depth = info.GetBitsPerPixel();
1916 results->depthPerComponent = info.GetBitsPerComponent(); 1923 results->depthPerComponent = info.GetBitsPerComponent();
1917 results->isMonochrome = (results->depthPerComponent == 0); 1924 results->isMonochrome = (results->depthPerComponent == 0);
1918 } 1925 }
1919 1926
1920 } // namespace content 1927 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698