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

Unified Diff: android_webview/browser/browser_view_renderer.cc

Issue 1063853005: Unify Android Webview and Chrome's fling (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: add a todo Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/browser_view_renderer.cc
diff --git a/android_webview/browser/browser_view_renderer.cc b/android_webview/browser/browser_view_renderer.cc
index b9336d6119a230f9ccef7ac87c39bad71015c35d..91110c1be67e60d83c0c42c471b96fe1b68d042c 100644
--- a/android_webview/browser/browser_view_renderer.cc
+++ b/android_webview/browser/browser_view_renderer.cc
@@ -414,6 +414,12 @@ void BrowserViewRenderer::OnDetachedFromWindow() {
UpdateCompositorIsActive();
}
+void BrowserViewRenderer::OnComputeScroll(base::TimeTicks animation_time) {
+ if (pending_fling_animation_.is_null())
+ return;
+ FlushPendingScrollAnimation(animation_time);
+}
+
void BrowserViewRenderer::ReleaseHardware() {
DCHECK(hardware_enabled_);
ReturnUnusedResource(shared_renderer_state_.PassUncommittedFrameOnUI());
@@ -550,8 +556,8 @@ gfx::Vector2dF BrowserViewRenderer::GetTotalRootLayerScrollOffset() {
return scroll_offset_dip_;
}
-bool BrowserViewRenderer::IsExternalFlingActive() const {
- return client_->IsFlingActive();
+bool BrowserViewRenderer::IsExternalScrollActive() const {
+ return client_->IsSmoothScrollingActive();
}
void BrowserViewRenderer::UpdateRootLayerState(
@@ -605,6 +611,12 @@ BrowserViewRenderer::RootLayerStateAsValue(
return state;
}
+void BrowserViewRenderer::SetNeedsAnimateScroll(
+ const AnimationCallback& scroll_animation) {
+ pending_fling_animation_ = scroll_animation;
+ client_->PostInvalidate();
boliu 2015/05/29 19:42:47 Conceptually this feels wrong. What does "SetNeedA
hush (inactive) 2015/06/05 21:47:21 We've discussed this in person. The fling animatio
+}
+
void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll,
gfx::Vector2dF latest_overscroll_delta,
gfx::Vector2dF current_fling_velocity) {
@@ -617,7 +629,11 @@ void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll,
scaled_overscroll_delta + overscroll_rounding_error_);
overscroll_rounding_error_ =
scaled_overscroll_delta - rounded_overscroll_delta;
- client_->DidOverscroll(rounded_overscroll_delta);
+
boliu 2015/05/29 19:42:47 nit: blank lines
hush (inactive) 2015/06/05 21:47:21 Done.
+ gfx::Vector2dF fling_velocity_pixels =
+ gfx::ScaleVector2d(current_fling_velocity, physical_pixel_scale);
+
+ client_->DidOverscroll(rounded_overscroll_delta, fling_velocity_pixels);
}
void BrowserViewRenderer::PostInvalidate() {
@@ -694,6 +710,16 @@ void BrowserViewRenderer::ForceFakeCompositeSW() {
CompositeSW(&canvas);
}
+void BrowserViewRenderer::FlushPendingScrollAnimation(
boliu 2015/05/29 19:42:47 There is only one call site. Just inline this?
hush (inactive) 2015/06/05 21:47:21 Done.
+ base::TimeTicks animation_time) {
+ TRACE_EVENT0("android_webview",
+ "BrowserViewRenderer::FlushPendingScrollAnimation");
+ DCHECK(!pending_fling_animation_.is_null());
+ AnimationCallback animation = pending_fling_animation_;
+ pending_fling_animation_.Reset();
+ animation.Run(animation_time);
+}
+
bool BrowserViewRenderer::CompositeSW(SkCanvas* canvas) {
DCHECK(compositor_);
CancelFallbackTick();

Powered by Google App Engine
This is Rietveld 408576698