| 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, |
| 33 float displacement) OVERRIDE; |
| 34 virtual void Absorb(base::TimeTicks current_time, float velocity) OVERRIDE; |
| 35 virtual bool Update(base::TimeTicks current_time) OVERRIDE; |
| 36 virtual void Release(base::TimeTicks current_time) OVERRIDE; |
| 42 | 37 |
| 43 void Pull(base::TimeTicks current_time, float delta_distance); | 38 virtual void Finish() OVERRIDE; |
| 44 void Absorb(base::TimeTicks current_time, float velocity); | 39 virtual bool IsFinished() const OVERRIDE; |
| 45 bool Update(base::TimeTicks current_time); | |
| 46 void Release(base::TimeTicks current_time); | |
| 47 | 40 |
| 48 void Finish(); | 41 virtual void ApplyToLayers(const gfx::SizeF& size, |
| 49 bool IsFinished() const; | 42 const gfx::Transform& transform) OVERRIDE; |
| 43 virtual void SetParent(cc::Layer* parent) OVERRIDE; |
| 50 | 44 |
| 51 void ApplyToLayers(gfx::SizeF window_size, | 45 // 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); | 46 static void PreloadResources(ui::SystemUIResourceManager* resource_manager); |
| 60 | 47 |
| 61 private: | 48 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; | 49 class EffectLayer; |
| 71 scoped_ptr<EffectLayer> edge_; | 50 scoped_ptr<EffectLayer> edge_; |
| 72 scoped_ptr<EffectLayer> glow_; | 51 scoped_ptr<EffectLayer> glow_; |
| 73 | 52 |
| 53 float base_edge_height_; |
| 54 float base_glow_height_; |
| 55 |
| 74 float edge_alpha_; | 56 float edge_alpha_; |
| 75 float edge_scale_y_; | 57 float edge_scale_y_; |
| 76 float glow_alpha_; | 58 float glow_alpha_; |
| 77 float glow_scale_y_; | 59 float glow_scale_y_; |
| 78 | 60 |
| 79 float edge_alpha_start_; | 61 float edge_alpha_start_; |
| 80 float edge_alpha_finish_; | 62 float edge_alpha_finish_; |
| 81 float edge_scale_y_start_; | 63 float edge_scale_y_start_; |
| 82 float edge_scale_y_finish_; | 64 float edge_scale_y_finish_; |
| 83 float glow_alpha_start_; | 65 float glow_alpha_start_; |
| 84 float glow_alpha_finish_; | 66 float glow_alpha_finish_; |
| 85 float glow_scale_y_start_; | 67 float glow_scale_y_start_; |
| 86 float glow_scale_y_finish_; | 68 float glow_scale_y_finish_; |
| 87 | 69 |
| 88 base::TimeTicks start_time_; | 70 base::TimeTicks start_time_; |
| 89 base::TimeDelta duration_; | 71 base::TimeDelta duration_; |
| 90 | 72 |
| 91 State state_; | 73 State state_; |
| 92 | 74 |
| 93 float pull_distance_; | 75 float pull_distance_; |
| 94 | 76 |
| 95 DISALLOW_COPY_AND_ASSIGN(EdgeEffect); | 77 DISALLOW_COPY_AND_ASSIGN(EdgeEffect); |
| 96 }; | 78 }; |
| 97 | 79 |
| 98 } // namespace content | 80 } // namespace content |
| 99 | 81 |
| 100 #endif // CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ | 82 #endif // CONTENT_BROWSER_ANDROID_EDGE_EFFECT_H_ |
| OLD | NEW |