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

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

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

Powered by Google App Engine
This is Rietveld 408576698