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

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 LazyInstance for overscroll resources Created 7 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
« no previous file with comments | « content/browser/android/edge_effect.cc ('k') | content/browser/android/overscroll_glow.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a0ca321ef2a03ab8c0eb3ee36968d161bac9f2b6
--- /dev/null
+++ b/content/browser/android/overscroll_glow.h
@@ -0,0 +1,91 @@
+// 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);
+ // Returns true if the effect still needs animation ticks.
+ bool Animate(base::TimeTicks current_time);
+ void Finish();
+
+ // Returns true if the effect needs animation ticks.
+ bool IsActive() const;
+
+ // The root layer of the effect (not necessarily of the tree).
+ scoped_refptr<cc::Layer> root_layer() const {
+ return root_layer_;
+ }
+
+ void set_horizontal_overscroll_enabled(bool enabled) {
+ horizontal_overscroll_enabled_ = enabled;
+ }
+ void set_vertical_overscroll_enabled(bool enabled) {
+ vertical_overscroll_enabled_ = enabled;
+ }
+
+ void set_size(gfx::SizeF size) {
+ size_ = size;
+ }
+
+ private:
+ enum Axis { AXIS_X, AXIS_Y };
+
+ OverscrollGlow(const SkBitmap& edge, const SkBitmap& glow);
+
+ void Pull(base::TimeTicks current_time,
+ gfx::Vector2dF added_overscroll);
+ void Absorb(base::TimeTicks current_time,
+ gfx::Vector2dF velocity,
+ gfx::Vector2dF overscroll,
+ gfx::Vector2dF old_overscroll);
+
+ void Release(base::TimeTicks current_time);
+ void Release(Axis axis, base::TimeTicks current_time);
+
+ EdgeEffect* GetOppositeEdge(int edge_index);
+
+ scoped_ptr<EdgeEffect> edge_effects_[EdgeEffect::EDGE_COUNT];
+
+ gfx::SizeF size_;
+ gfx::Vector2dF old_overscroll_;
+ gfx::Vector2dF old_velocity_;
+ bool horizontal_overscroll_enabled_;
+ bool vertical_overscroll_enabled_;
+
+ scoped_refptr<cc::Layer> root_layer_;
+
+ DISALLOW_COPY_AND_ASSIGN(OverscrollGlow);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_ANDROID_SCROLL_GLOW_H_
« no previous file with comments | « content/browser/android/edge_effect.cc ('k') | content/browser/android/overscroll_glow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698