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..70c8751579f7c89bdb8aeead00f0d944ed145e1f |
--- /dev/null |
+++ b/content/browser/android/overscroll_glow.h |
@@ -0,0 +1,72 @@ |
+// 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); |
+ void set_parent_layer(scoped_refptr<cc::Layer> parent_layer); |
+ |
+ private: |
+ enum { EDGE_COUNT = EdgeEffect::EDGE_COUNT }; |
+ |
+ OverscrollGlow(const SkBitmap& edge, const SkBitmap& glow); |
+ |
+ void Pull(base::TimeTicks current_time, |
+ const gfx::Vector2dF& added_overscroll); |
+ void Absorb(base::TimeTicks current_time, |
+ const gfx::Vector2dF& velocity, |
+ const gfx::Vector2dF& overscroll, |
+ const gfx::Vector2dF& old_overscroll); |
+ |
+ EdgeEffect* GetOppositeEdge(int edge_index); |
+ |
+ scoped_ptr<EdgeEffect> edge_effects_[EDGE_COUNT]; |
+ |
+ gfx::SizeF size_; |
+ gfx::Vector2dF old_overscroll_; |
+ bool horizontal_overscroll_enabled_; |
+ |
+ scoped_refptr<cc::Layer> parent_layer_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(OverscrollGlow); |
+}; |
+ |
+} // namespace content |
+ |
+#endif // CONTENT_BROWSER_ANDROID_SCROLL_GLOW_H_ |