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 #include "content/browser/android/overscroll_glow.h" | 5 #include "content/browser/android/overscroll_glow.h" |
6 | 6 |
7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "content/browser/android/edge_effect_base.h" | 8 #include "content/browser/android/edge_effect_base.h" |
9 | 9 |
10 using std::max; | 10 using std::max; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 float OverscrollGlow::GetVisibleAlpha() const { | 105 float OverscrollGlow::GetVisibleAlpha() const { |
106 float max_alpha = 0; | 106 float max_alpha = 0; |
107 for (size_t i = 0; i < EDGE_COUNT; ++i) { | 107 for (size_t i = 0; i < EDGE_COUNT; ++i) { |
108 if (!edge_effects_[i]->IsFinished()) | 108 if (!edge_effects_[i]->IsFinished()) |
109 max_alpha = std::max(max_alpha, edge_effects_[i]->GetAlpha()); | 109 max_alpha = std::max(max_alpha, edge_effects_[i]->GetAlpha()); |
110 } | 110 } |
111 return std::min(max_alpha, 1.f); | 111 return std::min(max_alpha, 1.f); |
112 } | 112 } |
113 | 113 |
114 bool OverscrollGlow::OnOverscrolled(base::TimeTicks current_time, | 114 bool OverscrollGlow::OnOverscrolled(base::TimeTicks current_time, |
115 gfx::Vector2dF accumulated_overscroll, | 115 const gfx::Vector2dF& accumulated_overscroll, |
116 gfx::Vector2dF overscroll_delta, | 116 gfx::Vector2dF overscroll_delta, |
117 gfx::Vector2dF velocity, | 117 gfx::Vector2dF velocity, |
118 gfx::Vector2dF displacement) { | 118 const gfx::Vector2dF& displacement) { |
119 // The size of the glow determines the relative effect of the inputs; an | 119 // The size of the glow determines the relative effect of the inputs; an |
120 // empty-sized effect is effectively disabled. | 120 // empty-sized effect is effectively disabled. |
121 if (viewport_size_.IsEmpty()) | 121 if (viewport_size_.IsEmpty()) |
122 return false; | 122 return false; |
123 | 123 |
124 // Ignore sufficiently small values that won't meaningfuly affect animation. | 124 // Ignore sufficiently small values that won't meaningfuly affect animation. |
125 overscroll_delta = ZeroSmallComponents(overscroll_delta); | 125 overscroll_delta = ZeroSmallComponents(overscroll_delta); |
126 if (overscroll_delta.IsZero()) { | 126 if (overscroll_delta.IsZero()) { |
127 if (initialized_) | 127 if (initialized_) |
128 Release(current_time); | 128 Release(current_time); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 for (size_t i = 0; i < EDGE_COUNT; ++i) | 297 for (size_t i = 0; i < EDGE_COUNT; ++i) |
298 edge_effects_[i]->Release(current_time); | 298 edge_effects_[i]->Release(current_time); |
299 } | 299 } |
300 | 300 |
301 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { | 301 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { |
302 DCHECK(initialized_); | 302 DCHECK(initialized_); |
303 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); | 303 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); |
304 } | 304 } |
305 | 305 |
306 } // namespace content | 306 } // namespace content |
OLD | NEW |