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