| 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 "ui/android/overscroll_glow.h" | 5 #include "ui/android/overscroll_glow.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
| 10 #include "ui/android/edge_effect_base.h" | 10 #include "ui/android/edge_effect_base.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 float OverscrollGlow::GetVisibleAlpha() const { | 67 float OverscrollGlow::GetVisibleAlpha() const { |
| 68 float max_alpha = 0; | 68 float max_alpha = 0; |
| 69 for (size_t i = 0; i < EDGE_COUNT; ++i) { | 69 for (size_t i = 0; i < EDGE_COUNT; ++i) { |
| 70 if (!edge_effects_[i]->IsFinished()) | 70 if (!edge_effects_[i]->IsFinished()) |
| 71 max_alpha = std::max(max_alpha, edge_effects_[i]->GetAlpha()); | 71 max_alpha = std::max(max_alpha, edge_effects_[i]->GetAlpha()); |
| 72 } | 72 } |
| 73 return std::min(max_alpha, 1.f); | 73 return std::min(max_alpha, 1.f); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool OverscrollGlow::OnOverscrolled(base::TimeTicks current_time, | 76 bool OverscrollGlow::OnOverscrolled(base::TimeTicks current_time, |
| 77 const gfx::Vector2dF& accumulated_overscroll, | 77 gfx::Vector2dF accumulated_overscroll, |
| 78 gfx::Vector2dF overscroll_delta, | 78 gfx::Vector2dF overscroll_delta, |
| 79 gfx::Vector2dF velocity, | 79 gfx::Vector2dF velocity, |
| 80 const gfx::Vector2dF& overscroll_location) { | 80 gfx::Vector2dF overscroll_location) { |
| 81 // The size of the glow determines the relative effect of the inputs; an | 81 // The size of the glow determines the relative effect of the inputs; an |
| 82 // empty-sized effect is effectively disabled. | 82 // empty-sized effect is effectively disabled. |
| 83 if (viewport_size_.IsEmpty()) | 83 if (viewport_size_.IsEmpty()) |
| 84 return false; | 84 return false; |
| 85 | 85 |
| 86 if (!allow_horizontal_overscroll_) { | 86 if (!allow_horizontal_overscroll_) { |
| 87 overscroll_delta.set_x(0); | 87 overscroll_delta.set_x(0); |
| 88 velocity.set_x(0); | 88 velocity.set_x(0); |
| 89 } | 89 } |
| 90 if (!allow_vertical_overscroll_) { | 90 if (!allow_vertical_overscroll_) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 for (size_t i = 0; i < EDGE_COUNT; ++i) | 272 for (size_t i = 0; i < EDGE_COUNT; ++i) |
| 273 edge_effects_[i]->Release(current_time); | 273 edge_effects_[i]->Release(current_time); |
| 274 } | 274 } |
| 275 | 275 |
| 276 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { | 276 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { |
| 277 DCHECK(initialized_); | 277 DCHECK(initialized_); |
| 278 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); | 278 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace ui | 281 } // namespace ui |
| OLD | NEW |