| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/edge_effect_l.h" | 5 #include "content/browser/android/edge_effect_l.h" |
| 6 | 6 |
| 7 #include "cc/layers/ui_resource_layer.h" | 7 #include "cc/layers/ui_resource_layer.h" |
| 8 #include "content/browser/android/animation_utils.h" | 8 #include "content/browser/android/animation_utils.h" |
| 9 #include "content/public/browser/android/compositor.h" | 9 #include "content/public/browser/android/compositor.h" |
| 10 #include "ui/android/resources/resource_manager.h" | 10 #include "ui/android/resources/resource_manager.h" |
| 11 #include "ui/android/resources/system_ui_resource_type.h" | 11 #include "ui/android/resources/system_ui_resource_type.h" |
| 12 #include "ui/gfx/geometry/rect_f.h" |
| 12 #include "ui/gfx/geometry/size_conversions.h" | 13 #include "ui/gfx/geometry/size_conversions.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Time it will take the effect to fully recede in ms | 19 // Time it will take the effect to fully recede in ms |
| 19 const int kRecedeTimeMs = 600; | 20 const int kRecedeTimeMs = 600; |
| 20 | 21 |
| 21 // Time it will take before a pulled glow begins receding in ms | 22 // Time it will take before a pulled glow begins receding in ms |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 bounds_ = gfx::Size(size.width(), (int)std::min(size.height(), h)); | 242 bounds_ = gfx::Size(size.width(), (int)std::min(size.height(), h)); |
| 242 gfx::Size image_bounds( | 243 gfx::Size image_bounds( |
| 243 r, std::min(1.f, glow_scale_y_) * base_glow_scale * bounds_.height()); | 244 r, std::min(1.f, glow_scale_y_) * base_glow_scale * bounds_.height()); |
| 244 | 245 |
| 245 // Compute the displaced image rect. This includes both the horizontal | 246 // Compute the displaced image rect. This includes both the horizontal |
| 246 // offset from the |displacement_| factor, as well as the vertical edge offset | 247 // offset from the |displacement_| factor, as well as the vertical edge offset |
| 247 // provided by the method call. | 248 // provided by the method call. |
| 248 const float displacement = Clamp(displacement_, 0.f, 1.f) - 0.5f; | 249 const float displacement = Clamp(displacement_, 0.f, 1.f) - 0.5f; |
| 249 const float displacement_offset_x = bounds_.width() * displacement * 0.5f; | 250 const float displacement_offset_x = bounds_.width() * displacement * 0.5f; |
| 250 const float image_offset_x = (bounds_.width() - image_bounds.width()) * 0.5f; | 251 const float image_offset_x = (bounds_.width() - image_bounds.width()) * 0.5f; |
| 251 gfx::RectF image_rect(image_bounds); | 252 gfx::RectF image_rect = gfx::RectF(gfx::SizeF(image_bounds)); |
| 252 image_rect.Offset(image_offset_x - displacement_offset_x, -std::abs(offset)); | 253 image_rect.Offset(image_offset_x - displacement_offset_x, -std::abs(offset)); |
| 253 | 254 |
| 254 // Clip the image rect against the viewport. If either rect is empty there's | 255 // Clip the image rect against the viewport. If either rect is empty there's |
| 255 // no need to draw anything further. | 256 // no need to draw anything further. |
| 256 gfx::RectF clipped_rect(size.width(), size.height()); | 257 gfx::RectF clipped_rect(size.width(), size.height()); |
| 257 clipped_rect.Intersect(image_rect); | 258 clipped_rect.Intersect(image_rect); |
| 258 if (clipped_rect.IsEmpty() || image_rect.IsEmpty()) { | 259 if (clipped_rect.IsEmpty() || image_rect.IsEmpty()) { |
| 259 glow_->SetIsDrawable(false); | 260 glow_->SetIsDrawable(false); |
| 260 return; | 261 return; |
| 261 } | 262 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 291 } | 292 } |
| 292 | 293 |
| 293 // static | 294 // static |
| 294 void EdgeEffectL::PreloadResources(ui::ResourceManager* resource_manager) { | 295 void EdgeEffectL::PreloadResources(ui::ResourceManager* resource_manager) { |
| 295 DCHECK(resource_manager); | 296 DCHECK(resource_manager); |
| 296 resource_manager->PreloadResource(ui::ANDROID_RESOURCE_TYPE_SYSTEM, | 297 resource_manager->PreloadResource(ui::ANDROID_RESOURCE_TYPE_SYSTEM, |
| 297 kResourceId); | 298 kResourceId); |
| 298 } | 299 } |
| 299 | 300 |
| 300 } // namespace content | 301 } // namespace content |
| OLD | NEW |