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