| 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 "cc/layers/layer_settings.h" | |
| 11 #include "ui/android/edge_effect_base.h" | 10 #include "ui/android/edge_effect_base.h" |
| 12 #include "ui/android/window_android_compositor.h" | 11 #include "ui/android/window_android_compositor.h" |
| 13 | 12 |
| 14 using std::max; | 13 using std::max; |
| 15 using std::min; | 14 using std::min; |
| 16 | 15 |
| 17 namespace ui { | 16 namespace ui { |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 void OverscrollGlow::Detach() { | 187 void OverscrollGlow::Detach() { |
| 189 if (root_layer_.get()) | 188 if (root_layer_.get()) |
| 190 root_layer_->RemoveFromParent(); | 189 root_layer_->RemoveFromParent(); |
| 191 } | 190 } |
| 192 | 191 |
| 193 bool OverscrollGlow::InitializeIfNecessary() { | 192 bool OverscrollGlow::InitializeIfNecessary() { |
| 194 if (initialized_) | 193 if (initialized_) |
| 195 return true; | 194 return true; |
| 196 | 195 |
| 197 DCHECK(!root_layer_.get()); | 196 DCHECK(!root_layer_.get()); |
| 198 root_layer_ = cc::Layer::Create(cc::LayerSettings()); | 197 root_layer_ = cc::Layer::Create(); |
| 199 for (size_t i = 0; i < EDGE_COUNT; ++i) { | 198 for (size_t i = 0; i < EDGE_COUNT; ++i) { |
| 200 edge_effects_[i] = client_->CreateEdgeEffect(); | 199 edge_effects_[i] = client_->CreateEdgeEffect(); |
| 201 DCHECK(edge_effects_[i]); | 200 DCHECK(edge_effects_[i]); |
| 202 } | 201 } |
| 203 | 202 |
| 204 initialized_ = true; | 203 initialized_ = true; |
| 205 return true; | 204 return true; |
| 206 } | 205 } |
| 207 | 206 |
| 208 void OverscrollGlow::Pull(base::TimeTicks current_time, | 207 void OverscrollGlow::Pull(base::TimeTicks current_time, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 for (size_t i = 0; i < EDGE_COUNT; ++i) | 272 for (size_t i = 0; i < EDGE_COUNT; ++i) |
| 274 edge_effects_[i]->Release(current_time); | 273 edge_effects_[i]->Release(current_time); |
| 275 } | 274 } |
| 276 | 275 |
| 277 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { | 276 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { |
| 278 DCHECK(initialized_); | 277 DCHECK(initialized_); |
| 279 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); | 278 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); |
| 280 } | 279 } |
| 281 | 280 |
| 282 } // namespace ui | 281 } // namespace ui |
| OLD | NEW |