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

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

Issue 377013002: android: Use UIResource for overscroll glow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "cc/resources/ui_resource_client.h"
11 #include "ui/gfx/size_f.h" 12 #include "ui/gfx/size_f.h"
12 13
13 namespace cc { 14 namespace cc {
14 class Layer; 15 class UIResourceLayer;
15 } 16 }
16 17
17 namespace content { 18 namespace content {
18 19
19 /* |EdgeEffect| mirrors its Android counterpart, EdgeEffect.java. 20 /* |EdgeEffect| mirrors its Android counterpart, EdgeEffect.java.
20 * The primary difference is ownership; the Android version manages render 21 * The primary difference is ownership; the Android version manages render
21 * resources directly, while this version simply applies the effect to 22 * resources directly, while this version simply applies the effect to
22 * existing resources. Conscious tradeoffs were made to align this as closely 23 * existing resources. Conscious tradeoffs were made to align this as closely
23 * as possible with the original Android java version. 24 * as possible with the original Android java version.
24 * All coordinates and dimensions are in device pixels. 25 * All coordinates and dimensions are in device pixels.
25 */ 26 */
26 class EdgeEffect { 27 class EdgeEffect {
27 public: 28 public:
28 enum Edge { 29 enum Edge {
29 EDGE_TOP = 0, 30 EDGE_TOP = 0,
30 EDGE_LEFT, 31 EDGE_LEFT,
31 EDGE_BOTTOM, 32 EDGE_BOTTOM,
32 EDGE_RIGHT, 33 EDGE_RIGHT,
33 EDGE_COUNT 34 EDGE_COUNT
34 }; 35 };
35 36
36 EdgeEffect(scoped_refptr<cc::Layer> edge, scoped_refptr<cc::Layer> glow); 37 EdgeEffect(scoped_refptr<cc::UIResourceLayer> edge,
38 scoped_refptr<cc::UIResourceLayer> glow);
37 ~EdgeEffect(); 39 ~EdgeEffect();
38 40
39 void Pull(base::TimeTicks current_time, float delta_distance); 41 void Pull(base::TimeTicks current_time, float delta_distance);
40 void Absorb(base::TimeTicks current_time, float velocity); 42 void Absorb(base::TimeTicks current_time, float velocity);
41 bool Update(base::TimeTicks current_time); 43 bool Update(base::TimeTicks current_time);
42 void Release(base::TimeTicks current_time); 44 void Release(base::TimeTicks current_time);
43 45
44 void Finish(); 46 void Finish();
45 bool IsFinished() const; 47 bool IsFinished() const;
46 48
47 void ApplyToLayers(gfx::SizeF window_size, 49 void ApplyToLayers(gfx::SizeF window_size,
48 Edge edge, 50 Edge edge,
49 float edge_height, 51 float edge_height,
50 float glow_height, 52 float glow_height,
51 float offset); 53 float offset);
52 54
55 void SetUIResources(cc::UIResourceId edge_resource,
56 cc::UIResourceId glow_resource);
57
53 private: 58 private:
54 59
55 enum State { 60 enum State {
56 STATE_IDLE = 0, 61 STATE_IDLE = 0,
57 STATE_PULL, 62 STATE_PULL,
58 STATE_ABSORB, 63 STATE_ABSORB,
59 STATE_RECEDE, 64 STATE_RECEDE,
60 STATE_PULL_DECAY 65 STATE_PULL_DECAY
61 }; 66 };
62 67
63 scoped_refptr<cc::Layer> edge_; 68 scoped_refptr<cc::UIResourceLayer> edge_;
64 scoped_refptr<cc::Layer> glow_; 69 scoped_refptr<cc::UIResourceLayer> glow_;
65 70
66 float edge_alpha_; 71 float edge_alpha_;
67 float edge_scale_y_; 72 float edge_scale_y_;
68 float glow_alpha_; 73 float glow_alpha_;
69 float glow_scale_y_; 74 float glow_scale_y_;
70 75
71 float edge_alpha_start_; 76 float edge_alpha_start_;
72 float edge_alpha_finish_; 77 float edge_alpha_finish_;
73 float edge_scale_y_start_; 78 float edge_scale_y_start_;
74 float edge_scale_y_finish_; 79 float edge_scale_y_finish_;
75 float glow_alpha_start_; 80 float glow_alpha_start_;
76 float glow_alpha_finish_; 81 float glow_alpha_finish_;
77 float glow_scale_y_start_; 82 float glow_scale_y_start_;
78 float glow_scale_y_finish_; 83 float glow_scale_y_finish_;
79 84
80 base::TimeTicks start_time_; 85 base::TimeTicks start_time_;
81 base::TimeDelta duration_; 86 base::TimeDelta duration_;
82 87
83 State state_; 88 State state_;
84 89
85 float pull_distance_; 90 float pull_distance_;
86 91
87 DISALLOW_COPY_AND_ASSIGN(EdgeEffect); 92 DISALLOW_COPY_AND_ASSIGN(EdgeEffect);
88 }; 93 };
89 94
90 } // namespace content 95 } // namespace content
91 96
92 #endif // CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ 97 #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.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698