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

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

Powered by Google App Engine
This is Rietveld 408576698