| 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 #include "content/public/browser/android/compositor.h" |
| 9 | 10 |
| 10 using std::max; | 11 using std::max; |
| 11 using std::min; | 12 using std::min; |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 const float kEpsilon = 1e-3f; | 18 const float kEpsilon = 1e-3f; |
| 18 | 19 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void OverscrollGlow::Detach() { | 213 void OverscrollGlow::Detach() { |
| 213 if (root_layer_.get()) | 214 if (root_layer_.get()) |
| 214 root_layer_->RemoveFromParent(); | 215 root_layer_->RemoveFromParent(); |
| 215 } | 216 } |
| 216 | 217 |
| 217 bool OverscrollGlow::InitializeIfNecessary() { | 218 bool OverscrollGlow::InitializeIfNecessary() { |
| 218 if (initialized_) | 219 if (initialized_) |
| 219 return true; | 220 return true; |
| 220 | 221 |
| 221 DCHECK(!root_layer_.get()); | 222 DCHECK(!root_layer_.get()); |
| 222 root_layer_ = cc::Layer::Create(); | 223 root_layer_ = cc::Layer::Create(Compositor::LayerSettings()); |
| 223 for (size_t i = 0; i < EDGE_COUNT; ++i) { | 224 for (size_t i = 0; i < EDGE_COUNT; ++i) { |
| 224 edge_effects_[i] = client_->CreateEdgeEffect(); | 225 edge_effects_[i] = client_->CreateEdgeEffect(); |
| 225 DCHECK(edge_effects_[i]); | 226 DCHECK(edge_effects_[i]); |
| 226 } | 227 } |
| 227 | 228 |
| 228 initialized_ = true; | 229 initialized_ = true; |
| 229 return true; | 230 return true; |
| 230 } | 231 } |
| 231 | 232 |
| 232 void OverscrollGlow::Pull(base::TimeTicks current_time, | 233 void OverscrollGlow::Pull(base::TimeTicks current_time, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 for (size_t i = 0; i < EDGE_COUNT; ++i) | 298 for (size_t i = 0; i < EDGE_COUNT; ++i) |
| 298 edge_effects_[i]->Release(current_time); | 299 edge_effects_[i]->Release(current_time); |
| 299 } | 300 } |
| 300 | 301 |
| 301 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { | 302 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { |
| 302 DCHECK(initialized_); | 303 DCHECK(initialized_); |
| 303 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); | 304 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); |
| 304 } | 305 } |
| 305 | 306 |
| 306 } // namespace content | 307 } // namespace content |
| OLD | NEW |