| 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 "ui/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 "ui/android/edge_effect_base.h" |
| 9 #include "content/public/browser/android/compositor.h" | 9 #include "ui/android/window_android_compositor.h" |
| 10 | 10 |
| 11 using std::max; | 11 using std::max; |
| 12 using std::min; | 12 using std::min; |
| 13 | 13 |
| 14 namespace content { | 14 namespace ui { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const float kEpsilon = 1e-3f; | 18 const float kEpsilon = 1e-3f; |
| 19 | 19 |
| 20 bool IsApproxZero(float value) { | 20 bool IsApproxZero(float value) { |
| 21 return std::abs(value) < kEpsilon; | 21 return std::abs(value) < kEpsilon; |
| 22 } | 22 } |
| 23 | 23 |
| 24 gfx::Vector2dF ZeroSmallComponents(gfx::Vector2dF vector) { | 24 gfx::Vector2dF ZeroSmallComponents(gfx::Vector2dF vector) { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 void OverscrollGlow::Detach() { | 185 void OverscrollGlow::Detach() { |
| 186 if (root_layer_.get()) | 186 if (root_layer_.get()) |
| 187 root_layer_->RemoveFromParent(); | 187 root_layer_->RemoveFromParent(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 bool OverscrollGlow::InitializeIfNecessary() { | 190 bool OverscrollGlow::InitializeIfNecessary() { |
| 191 if (initialized_) | 191 if (initialized_) |
| 192 return true; | 192 return true; |
| 193 | 193 |
| 194 DCHECK(!root_layer_.get()); | 194 DCHECK(!root_layer_.get()); |
| 195 root_layer_ = cc::Layer::Create(Compositor::LayerSettings()); | 195 root_layer_ = cc::Layer::Create(WindowAndroidCompositor::LayerSettings()); |
| 196 for (size_t i = 0; i < EDGE_COUNT; ++i) { | 196 for (size_t i = 0; i < EDGE_COUNT; ++i) { |
| 197 edge_effects_[i] = client_->CreateEdgeEffect(); | 197 edge_effects_[i] = client_->CreateEdgeEffect(); |
| 198 DCHECK(edge_effects_[i]); | 198 DCHECK(edge_effects_[i]); |
| 199 } | 199 } |
| 200 | 200 |
| 201 initialized_ = true; | 201 initialized_ = true; |
| 202 return true; | 202 return true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 void OverscrollGlow::Pull(base::TimeTicks current_time, | 205 void OverscrollGlow::Pull(base::TimeTicks current_time, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 DCHECK(initialized_); | 269 DCHECK(initialized_); |
| 270 for (size_t i = 0; i < EDGE_COUNT; ++i) | 270 for (size_t i = 0; i < EDGE_COUNT; ++i) |
| 271 edge_effects_[i]->Release(current_time); | 271 edge_effects_[i]->Release(current_time); |
| 272 } | 272 } |
| 273 | 273 |
| 274 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { | 274 EdgeEffectBase* OverscrollGlow::GetOppositeEdge(int edge_index) { |
| 275 DCHECK(initialized_); | 275 DCHECK(initialized_); |
| 276 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); | 276 return edge_effects_[(edge_index + 2) % EDGE_COUNT].get(); |
| 277 } | 277 } |
| 278 | 278 |
| 279 } // namespace content | 279 } // namespace ui |
| OLD | NEW |