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

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: comments 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..5f4d36e4f5eeff5fad9b83c05ff8dddb68f46234 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;
+ FlushPendingFlingAnimation(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,13 @@ BrowserViewRenderer::RootLayerStateAsValue(
return state;
}
+void BrowserViewRenderer::SetNeedsAnimateFling(
+ const AnimationCallback& fling_animation) {
+ // TODO(jdduke): Skip invalidate if animation already pending?
aelias_OOO_until_Jul13 2015/05/09 03:32:04 Resolve this TODO one way or the other? Personall
hush (inactive) 2015/05/12 19:08:45 I will just remove this TODO.
+ pending_fling_animation_ = fling_animation;
+ client_->PostInvalidate();
+}
+
void BrowserViewRenderer::DidOverscroll(gfx::Vector2dF accumulated_overscroll,
gfx::Vector2dF latest_overscroll_delta,
gfx::Vector2dF current_fling_velocity) {
@@ -617,7 +630,19 @@ 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);
+
+ gfx::Vector2dF fling_velocity_pixels =
+ gfx::ScaleVector2d(current_fling_velocity, physical_pixel_scale);
+
+ const bool first_overscroll_x =
+ accumulated_overscroll.x() &&
+ accumulated_overscroll.x() == latest_overscroll_delta.x();
+ const bool first_overscroll_y =
+ accumulated_overscroll.y() &&
+ accumulated_overscroll.y() == latest_overscroll_delta.y();
+
+ client_->DidOverscroll(rounded_overscroll_delta, fling_velocity_pixels,
+ first_overscroll_x, first_overscroll_y);
}
void BrowserViewRenderer::PostInvalidate() {
@@ -694,6 +719,16 @@ void BrowserViewRenderer::ForceFakeCompositeSW() {
CompositeSW(&canvas);
}
+void BrowserViewRenderer::FlushPendingFlingAnimation(
+ base::TimeTicks animation_time) {
+ TRACE_EVENT0("android_webview",
+ "BrowserViewRenderer::FlushPendingFlingAnimation");
+ 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