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

Side by Side Diff: content/browser/android/edge_effect.h

Issue 367173003: [Android] Implementation of overscroll effect for Android L (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ 5 #ifndef CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_
6 #define CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ 6 #define CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_
7 7
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h" 9 #include "base/memory/scoped_ptr.h"
11 #include "ui/gfx/size_f.h" 10 #include "content/browser/android/edge_effect_base.h"
12 11
13 namespace cc { 12 namespace cc {
14 class Layer; 13 class Layer;
15 } 14 }
16 15
17 namespace content { 16 namespace content {
18 17
19 /* |EdgeEffect| mirrors its Android counterpart, EdgeEffect.java. 18 // |EdgeEffect| mirrors its Android counterpart, EdgeEffect.java.
20 * The primary difference is ownership; the Android version manages render 19 // Conscious tradeoffs were made to align this as closely as possible with the
21 * resources directly, while this version simply applies the effect to 20 // the original Android java version.
22 * existing resources. Conscious tradeoffs were made to align this as closely 21 // All coordinates and dimensions are in device pixels.
23 * as possible with the original Android java version. 22 class EdgeEffect : public EdgeEffectBase {
24 * All coordinates and dimensions are in device pixels.
25 */
26 class EdgeEffect {
27 public: 23 public:
28 enum Edge { 24 static scoped_ptr<EdgeEffect> Create(cc::Layer* root_layer,
29 EDGE_TOP = 0, 25 float device_scale_factor);
30 EDGE_LEFT,
31 EDGE_BOTTOM,
32 EDGE_RIGHT,
33 EDGE_COUNT
34 };
35 26
36 EdgeEffect(scoped_refptr<cc::Layer> edge, scoped_refptr<cc::Layer> glow); 27 virtual ~EdgeEffect();
37 ~EdgeEffect();
38 28
39 void Pull(base::TimeTicks current_time, float delta_distance); 29 virtual void Pull(base::TimeTicks current_time,
40 void Absorb(base::TimeTicks current_time, float velocity); 30 float delta_distance) OVERRIDE;
41 bool Update(base::TimeTicks current_time); 31 virtual void Pull(base::TimeTicks current_time,
42 void Release(base::TimeTicks current_time); 32 float delta_distance,
33 float displacement) OVERRIDE;
34 virtual void Absorb(base::TimeTicks current_time, float velocity) OVERRIDE;
35 virtual bool Update(base::TimeTicks current_time) OVERRIDE;
36 virtual void Release(base::TimeTicks current_time) OVERRIDE;
43 37
44 void Finish(); 38 virtual void Finish() OVERRIDE;
45 bool IsFinished() const; 39 virtual bool IsFinished() const OVERRIDE;
46 40
47 void ApplyToLayers(gfx::SizeF window_size, 41 virtual void ApplyToLayers(const gfx::SizeF& size,
48 Edge edge, 42 const gfx::Transform& transform) OVERRIDE;
49 float edge_height, 43
50 float glow_height, 44 // Thread-safe trigger to load resources.
51 float offset); 45 static void EnsureResources();
52 46
53 private: 47 private:
54 48 EdgeEffect(const scoped_refptr<cc::Layer>& edge,
55 enum State { 49 const scoped_refptr<cc::Layer>& glow,
56 STATE_IDLE = 0, 50 float device_scale_factor);
57 STATE_PULL,
58 STATE_ABSORB,
59 STATE_RECEDE,
60 STATE_PULL_DECAY
61 };
62 51
63 scoped_refptr<cc::Layer> edge_; 52 scoped_refptr<cc::Layer> edge_;
64 scoped_refptr<cc::Layer> glow_; 53 scoped_refptr<cc::Layer> glow_;
65 54
55 float base_edge_height_;
56 float base_glow_height_;
57
66 float edge_alpha_; 58 float edge_alpha_;
67 float edge_scale_y_; 59 float edge_scale_y_;
68 float glow_alpha_; 60 float glow_alpha_;
69 float glow_scale_y_; 61 float glow_scale_y_;
70 62
71 float edge_alpha_start_; 63 float edge_alpha_start_;
72 float edge_alpha_finish_; 64 float edge_alpha_finish_;
73 float edge_scale_y_start_; 65 float edge_scale_y_start_;
74 float edge_scale_y_finish_; 66 float edge_scale_y_finish_;
75 float glow_alpha_start_; 67 float glow_alpha_start_;
76 float glow_alpha_finish_; 68 float glow_alpha_finish_;
77 float glow_scale_y_start_; 69 float glow_scale_y_start_;
78 float glow_scale_y_finish_; 70 float glow_scale_y_finish_;
79 71
80 base::TimeTicks start_time_; 72 base::TimeTicks start_time_;
81 base::TimeDelta duration_; 73 base::TimeDelta duration_;
82 74
83 State state_; 75 State state_;
84 76
85 float pull_distance_; 77 float pull_distance_;
86 78
87 DISALLOW_COPY_AND_ASSIGN(EdgeEffect); 79 DISALLOW_COPY_AND_ASSIGN(EdgeEffect);
88 }; 80 };
89 81
90 } // namespace content 82 } // namespace content
91 83
92 #endif // CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ 84 #endif // CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/android/edge_effect.cc » ('j') | content/browser/android/edge_effect_l.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698