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