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

Unified Diff: content/browser/android/overscroll_glow.h

Issue 14268004: Add overscroll edge effect animations for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use vsync ticks to drive overscroll animation Created 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/overscroll_glow.h
diff --git a/content/browser/android/overscroll_glow.h b/content/browser/android/overscroll_glow.h
new file mode 100644
index 0000000000000000000000000000000000000000..23722e5d3e76d978db49e9e2042e8fc3b7f5ccf2
--- /dev/null
+++ b/content/browser/android/overscroll_glow.h
@@ -0,0 +1,76 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_
+#define CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time.h"
+#include "content/browser/android/edge_effect.h"
+#include "ui/gfx/size_f.h"
+#include "ui/gfx/vector2d_f.h"
+
+class SkBitmap;
+
+namespace cc {
+class Layer;
+}
+
+namespace content {
+
+/* |OverscrollGlow| mirrors its Android counterpart, EdgeEffect.java.
+ * Conscious tradeoffs were made to align this as closely as possible with the
+ * original Android java version.
+ */
+class OverscrollGlow {
+ public:
+ static scoped_ptr<OverscrollGlow> Create();
+
+ ~OverscrollGlow();
+
+ void OnOverscrolled(base::TimeTicks current_time,
+ gfx::Vector2dF overscroll,
+ gfx::Vector2dF velocity);
+ bool Animate(base::TimeTicks current_time);
+ bool IsAnimating() const;
+ void Release(base::TimeTicks current_time);
+ void Finish();
+
+ void set_horizontal_overscroll_enabled(bool enabled);
+ void set_size(const gfx::SizeF& size);
aelias_OOO_until_Jul13 2013/04/22 23:46:48 Just gfx::SizeF
jdduke (slow) 2013/04/23 16:02:13 Done.
+ void set_parent_layer(scoped_refptr<cc::Layer> parent_layer);
+
+ private:
+ enum { EDGE_COUNT = EdgeEffect::EDGE_COUNT };
aelias_OOO_until_Jul13 2013/04/22 23:46:48 Seems unnecessary, please use EdgeEffect::EDGE_COU
jdduke (slow) 2013/04/23 16:02:13 Done.
+ enum Axis { AXIS_X, AXIS_Y };
+
+ OverscrollGlow(const SkBitmap& edge, const SkBitmap& glow);
+
+ void Pull(base::TimeTicks current_time,
+ const gfx::Vector2dF& added_overscroll);
aelias_OOO_until_Jul13 2013/04/22 23:46:48 Just gfx::Vector2dF all through here
jdduke (slow) 2013/04/23 16:02:13 Done.
+ void Absorb(base::TimeTicks current_time,
+ const gfx::Vector2dF& velocity,
+ const gfx::Vector2dF& overscroll,
+ const gfx::Vector2dF& old_overscroll);
+
+ void Release(Axis axis, base::TimeTicks current_time);
+
+ EdgeEffect* GetOppositeEdge(int edge_index);
+
+ scoped_ptr<EdgeEffect> edge_effects_[EDGE_COUNT];
+
+ gfx::SizeF size_;
+ gfx::Vector2dF old_overscroll_;
+ gfx::Vector2dF old_velocity_;
+ bool horizontal_overscroll_enabled_;
+
+ scoped_refptr<cc::Layer> parent_layer_;
+
+ DISALLOW_COPY_AND_ASSIGN(OverscrollGlow);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_ANDROID_SCROLL_GLOW_H_

Powered by Google App Engine
This is Rietveld 408576698