OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ | |
6 #define CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/time.h" | |
11 #include "ui/gfx/size_f.h" | |
12 | |
13 namespace cc { | |
14 class Layer; | |
15 } | |
16 | |
17 namespace content { | |
18 | |
19 /* |EdgeEffect| mirrors its Android counterpart, EdgeEffect.java. | |
20 * The primary difference is ownership; the Android version manages render | |
21 * resources directly, while this version simply applies the effect to | |
22 * existing resources. Conscious tradeoffs were made to align this as closely | |
23 * as possible with the original Android java version. | |
24 */ | |
25 class EdgeEffect { | |
26 public: | |
27 enum Edge { | |
28 EDGE_TOP = 0, | |
29 EDGE_LEFT, | |
30 EDGE_BOTTOM, | |
31 EDGE_RIGHT, | |
32 EDGE_COUNT | |
33 }; | |
34 | |
35 EdgeEffect(scoped_refptr<cc::Layer> edge, scoped_refptr<cc::Layer> glow); | |
36 ~EdgeEffect(); | |
37 | |
38 void Pull(base::TimeTicks current_time, float delta_distance); | |
39 void Absorb(base::TimeTicks current_time, float velocity); | |
40 bool Update(base::TimeTicks current_time); | |
41 void Release(base::TimeTicks current_time); | |
42 | |
43 void Finish(); | |
44 bool IsFinished() const; | |
45 | |
46 void Draw(cc::Layer* parent_layer, gfx::SizeF size, Edge edge); | |
no sievers
2013/05/13 18:38:24
Should this be called something other than Draw(),
jdduke (slow)
2013/05/13 20:44:24
Yeah, I went back and forth on this, particularly
no sievers
2013/05/13 20:53:22
I like ApplyToLayers().
| |
47 | |
48 private: | |
49 | |
50 enum State { | |
51 STATE_IDLE = 0, | |
52 STATE_PULL, | |
53 STATE_ABSORB, | |
54 STATE_RECEDE, | |
55 STATE_PULL_DECAY | |
56 }; | |
57 | |
58 void Attach(cc::Layer* parent_layer); | |
59 void Detach(); | |
60 | |
61 scoped_refptr<cc::Layer> edge_; | |
62 scoped_refptr<cc::Layer> glow_; | |
63 | |
64 float edge_alpha_; | |
65 float edge_scale_y_; | |
66 float glow_alpha_; | |
67 float glow_scale_y_; | |
68 | |
69 float edge_alpha_start_; | |
70 float edge_alpha_finish_; | |
71 float edge_scale_y_start_; | |
72 float edge_scale_y_finish_; | |
73 float glow_alpha_start_; | |
74 float glow_alpha_finish_; | |
75 float glow_scale_y_start_; | |
76 float glow_scale_y_finish_; | |
77 | |
78 base::TimeTicks start_time_; | |
79 base::TimeDelta duration_; | |
80 | |
81 State state_; | |
82 | |
83 float pull_distance_; | |
84 | |
85 DISALLOW_COPY_AND_ASSIGN(EdgeEffect); | |
86 }; | |
87 | |
88 } // namespace content | |
89 | |
90 #endif // CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ | |
OLD | NEW |