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