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

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

Issue 367173003: [Android] Implementation of overscroll effect for Android L (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review Created 6 years, 4 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_l.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
index 750094053887357d5885df7dc6de893ff1821512..878d39aec1288b4ed12c68a4933b529ad5673d51 100644
--- a/content/browser/android/overscroll_glow.h
+++ b/content/browser/android/overscroll_glow.h
@@ -5,32 +5,36 @@
#ifndef CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_
#define CONTENT_BROWSER_ANDROID_OVERSCROLL_GLOW_H_
+#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
-#include "content/browser/android/edge_effect.h"
#include "ui/gfx/size_f.h"
#include "ui/gfx/vector2d_f.h"
-class SkBitmap;
-
-namespace ui {
-class SystemUIResourceManager;
+namespace cc {
+class Layer;
}
namespace content {
+class EdgeEffectBase;
+
/* |OverscrollGlow| mirrors its Android counterpart, OverscrollGlow.java.
* Conscious tradeoffs were made to align this as closely as possible with the
* original Android Java version.
*/
class OverscrollGlow {
public:
- // Create a new effect. |resource_manager| provides the resource for the
- // effect. |resource_manager| must outlive the effect. The effect is
- // activated by default.
- static scoped_ptr<OverscrollGlow> Create(
- ui::SystemUIResourceManager* resource_manager);
+ enum Edge { EDGE_TOP = 0, EDGE_LEFT, EDGE_BOTTOM, EDGE_RIGHT, EDGE_COUNT };
+
+ // Allows lazy creation of the edge effects.
+ typedef base::Callback<scoped_ptr<EdgeEffectBase>(void)> EdgeEffectProvider;
+
+ // |edge_effect_provider| must be valid for the duration of the effect's
+ // lifetime. The effect is enabled by default, but will remain dormant until
+ // the first overscroll event.
+ explicit OverscrollGlow(const EdgeEffectProvider& edge_effect_provider);
~OverscrollGlow();
@@ -50,7 +54,8 @@ class OverscrollGlow {
base::TimeTicks current_time,
gfx::Vector2dF accumulated_overscroll,
gfx::Vector2dF overscroll_delta,
- gfx::Vector2dF velocity);
+ gfx::Vector2dF velocity,
+ gfx::Vector2dF overscroll_location);
// Returns true if the effect still needs animation ticks.
// Note: The effect will detach itself when no further animation is required.
@@ -61,40 +66,37 @@ class OverscrollGlow {
struct DisplayParameters {
DisplayParameters();
gfx::SizeF size;
- float edge_offsets[EdgeEffect::EDGE_COUNT];
- float device_scale_factor;
+ float edge_offsets[EDGE_COUNT];
};
void UpdateDisplayParameters(const DisplayParameters& params);
-
private:
enum Axis { AXIS_X, AXIS_Y };
- explicit OverscrollGlow(ui::SystemUIResourceManager* resource_manager);
-
// Returns whether the effect is initialized.
bool InitializeIfNecessary();
bool NeedsAnimate() const;
void UpdateLayerAttachment(cc::Layer* parent);
void Detach();
- void Pull(base::TimeTicks current_time, gfx::Vector2dF overscroll_delta);
+ void Pull(base::TimeTicks current_time,
+ const gfx::Vector2dF& overscroll_delta,
+ const gfx::Vector2dF& overscroll_location);
void Absorb(base::TimeTicks current_time,
- gfx::Vector2dF velocity,
+ const gfx::Vector2dF& velocity,
bool x_overscroll_started,
bool y_overscroll_started);
void Release(base::TimeTicks current_time);
- void ReleaseAxis(Axis axis, base::TimeTicks current_time);
- EdgeEffect* GetOppositeEdge(int edge_index);
+ EdgeEffectBase* GetOppositeEdge(int edge_index);
- scoped_ptr<EdgeEffect> edge_effects_[EdgeEffect::EDGE_COUNT];
+ EdgeEffectProvider edge_effect_provider_;
+ scoped_ptr<EdgeEffectBase> edge_effects_[EDGE_COUNT];
DisplayParameters display_params_;
bool enabled_;
bool initialized_;
scoped_refptr<cc::Layer> root_layer_;
- ui::SystemUIResourceManager* resource_manager_;
DISALLOW_COPY_AND_ASSIGN(OverscrollGlow);
};
« no previous file with comments | « content/browser/android/edge_effect_l.cc ('k') | content/browser/android/overscroll_glow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698