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

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: Rebase Created 5 years, 9 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 SkColor color) { 770 SkColor color) {
771 if (cached_background_color_ == color) 771 if (cached_background_color_ == color)
772 return; 772 return;
773 773
774 cached_background_color_ = color; 774 cached_background_color_ = color;
775 if (content_view_core_) 775 if (content_view_core_)
776 content_view_core_->OnBackgroundColorChanged(color); 776 content_view_core_->OnBackgroundColorChanged(color);
777 } 777 }
778 778
779 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames(bool enabled) { 779 void RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames(bool enabled) {
780 DCHECK(using_browser_compositor_);
781 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames", 780 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::OnSetNeedsBeginFrames",
782 "enabled", enabled); 781 "enabled", enabled);
783 if (enabled) 782 if (enabled)
784 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); 783 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME);
785 else 784 else
786 outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME; 785 outstanding_vsync_requests_ &= ~PERSISTENT_BEGIN_FRAME;
787 } 786 }
788 787
789 void RenderWidgetHostViewAndroid::OnStartContentIntent( 788 void RenderWidgetHostViewAndroid::OnStartContentIntent(
790 const GURL& content_url) { 789 const GURL& content_url) {
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 1522
1524 if (!layer_.get()) 1523 if (!layer_.get())
1525 return; 1524 return;
1526 1525
1527 content_view_core_->RemoveLayer(layer_); 1526 content_view_core_->RemoveLayer(layer_);
1528 if (overscroll_controller_) 1527 if (overscroll_controller_)
1529 overscroll_controller_->Disable(); 1528 overscroll_controller_->Disable();
1530 } 1529 }
1531 1530
1532 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32 requests) { 1531 void RenderWidgetHostViewAndroid::RequestVSyncUpdate(uint32 requests) {
1533 // The synchronous compositor does not requre BeginFrame messages.
1534 if (!using_browser_compositor_)
1535 requests &= FLUSH_INPUT;
1536
1537 bool should_request_vsync = !outstanding_vsync_requests_ && requests; 1532 bool should_request_vsync = !outstanding_vsync_requests_ && requests;
1538 outstanding_vsync_requests_ |= requests; 1533 outstanding_vsync_requests_ |= requests;
1539 1534
1540 // If the host has been hidden, defer vsync requests until it is shown 1535 // If the host has been hidden, defer vsync requests until it is shown
1541 // again via |Show()|. 1536 // again via |Show()|.
1542 if (!host_ || host_->is_hidden()) 1537 if (!host_ || host_->is_hidden())
1543 return; 1538 return;
1544 1539
1545 // Note that if we're not currently observing the root window, outstanding 1540 // Note that if we're not currently observing the root window, outstanding
1546 // vsync requests will be pushed if/when we resume observing in 1541 // vsync requests will be pushed if/when we resume observing in
(...skipping 27 matching lines...) Expand all
1574 return; 1569 return;
1575 1570
1576 observing_root_window_ = false; 1571 observing_root_window_ = false;
1577 content_view_core_->GetWindowAndroid()->RemoveObserver(this); 1572 content_view_core_->GetWindowAndroid()->RemoveObserver(this);
1578 } 1573 }
1579 1574
1580 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time, 1575 void RenderWidgetHostViewAndroid::SendBeginFrame(base::TimeTicks frame_time,
1581 base::TimeDelta vsync_period) { 1576 base::TimeDelta vsync_period) {
1582 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame", 1577 TRACE_EVENT1("cc", "RenderWidgetHostViewAndroid::SendBeginFrame",
1583 "frame_time_us", frame_time.ToInternalValue()); 1578 "frame_time_us", frame_time.ToInternalValue());
1584 base::TimeTicks display_time = frame_time + vsync_period;
1585 1579
1586 base::TimeTicks deadline = 1580 if (using_browser_compositor_) {
1587 display_time - host_->GetEstimatedBrowserCompositeTime(); 1581 base::TimeTicks display_time = frame_time + vsync_period;
1588 1582
1589 host_->Send(new ViewMsg_BeginFrame( 1583 base::TimeTicks deadline =
1590 host_->GetRoutingID(), 1584 display_time - host_->GetEstimatedBrowserCompositeTime();
1591 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline, 1585
1592 vsync_period, cc::BeginFrameArgs::NORMAL))); 1586 host_->Send(new ViewMsg_BeginFrame(
1587 host_->GetRoutingID(),
1588 cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline,
1589 vsync_period, cc::BeginFrameArgs::NORMAL)));
1590 } else {
1591 SynchronousCompositorImpl* compositor = SynchronousCompositorImpl::FromID(
1592 host_->GetProcess()->GetID(), host_->GetRoutingID());
1593
1594 compositor->SendBeginFrame(cc::BeginFrameArgs::Create(
1595 BEGINFRAME_FROM_HERE, frame_time, base::TimeTicks(), vsync_period,
1596 cc::BeginFrameArgs::NORMAL));
1597 }
1593 } 1598 }
1594 1599
1595 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) { 1600 bool RenderWidgetHostViewAndroid::Animate(base::TimeTicks frame_time) {
1596 bool needs_animate = false; 1601 bool needs_animate = false;
1597 if (overscroll_controller_) { 1602 if (overscroll_controller_) {
1598 needs_animate |= overscroll_controller_->Animate( 1603 needs_animate |= overscroll_controller_->Animate(
1599 frame_time, content_view_core_->GetLayer().get()); 1604 frame_time, content_view_core_->GetLayer().get());
1600 } 1605 }
1601 if (selection_controller_) 1606 if (selection_controller_)
1602 needs_animate |= selection_controller_->Animate(frame_time); 1607 needs_animate |= selection_controller_->Animate(frame_time);
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED); 1922 RunAckCallbacks(cc::SurfaceDrawStatus::DRAW_SKIPPED);
1918 overscroll_controller_.reset(); 1923 overscroll_controller_.reset();
1919 } 1924 }
1920 1925
1921 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time, 1926 void RenderWidgetHostViewAndroid::OnVSync(base::TimeTicks frame_time,
1922 base::TimeDelta vsync_period) { 1927 base::TimeDelta vsync_period) {
1923 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync"); 1928 TRACE_EVENT0("cc,benchmark", "RenderWidgetHostViewAndroid::OnVSync");
1924 if (!host_ || host_->is_hidden()) 1929 if (!host_ || host_->is_hidden())
1925 return; 1930 return;
1926 1931
1927 const uint32 current_vsync_requests = outstanding_vsync_requests_; 1932 if (outstanding_vsync_requests_ & FLUSH_INPUT) {
1928 outstanding_vsync_requests_ = 0; 1933 outstanding_vsync_requests_ &= ~FLUSH_INPUT;
1934 host_->FlushInput();
1935 }
1929 1936
1930 if (current_vsync_requests & FLUSH_INPUT) 1937 if (outstanding_vsync_requests_ & BEGIN_FRAME ||
1931 host_->FlushInput(); 1938 outstanding_vsync_requests_ & PERSISTENT_BEGIN_FRAME) {
1932 1939 outstanding_vsync_requests_ &= ~BEGIN_FRAME;
1933 if (current_vsync_requests & BEGIN_FRAME ||
1934 current_vsync_requests & PERSISTENT_BEGIN_FRAME) {
1935 SendBeginFrame(frame_time, vsync_period); 1940 SendBeginFrame(frame_time, vsync_period);
1936 } 1941 }
1937 1942
1938 if (current_vsync_requests & PERSISTENT_BEGIN_FRAME) 1943 // This allows for SendBeginFrame to modify outstanding_vsync_requests.
1939 RequestVSyncUpdate(PERSISTENT_BEGIN_FRAME); 1944 uint32 outstanding_vsync_requests = outstanding_vsync_requests_;
1945 outstanding_vsync_requests_ = 0;
1946 RequestVSyncUpdate(outstanding_vsync_requests);
1940 } 1947 }
1941 1948
1942 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) { 1949 void RenderWidgetHostViewAndroid::OnAnimate(base::TimeTicks begin_frame_time) {
1943 if (Animate(begin_frame_time)) 1950 if (Animate(begin_frame_time))
1944 SetNeedsAnimate(); 1951 SetNeedsAnimate();
1945 } 1952 }
1946 1953
1947 void RenderWidgetHostViewAndroid::OnActivityPaused() { 1954 void RenderWidgetHostViewAndroid::OnActivityPaused() {
1948 TRACE_EVENT0("browser", "RenderWidgetHostViewAndroid::OnActivityPaused"); 1955 TRACE_EVENT0("browser", "RenderWidgetHostViewAndroid::OnActivityPaused");
1949 DCHECK(is_showing_); 1956 DCHECK(is_showing_);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 results->orientationAngle = display.RotationAsDegree(); 2105 results->orientationAngle = display.RotationAsDegree();
2099 results->orientationType = 2106 results->orientationType =
2100 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 2107 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
2101 gfx::DeviceDisplayInfo info; 2108 gfx::DeviceDisplayInfo info;
2102 results->depth = info.GetBitsPerPixel(); 2109 results->depth = info.GetBitsPerPixel();
2103 results->depthPerComponent = info.GetBitsPerComponent(); 2110 results->depthPerComponent = info.GetBitsPerComponent();
2104 results->isMonochrome = (results->depthPerComponent == 0); 2111 results->isMonochrome = (results->depthPerComponent == 0);
2105 } 2112 }
2106 2113
2107 } // namespace content 2114 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698