| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/laser/laser_pointer_view.h" | 5 #include "ash/laser/laser_pointer_view.h" |
| 6 | 6 |
| 7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
| 8 #include <GLES2/gl2ext.h> | 8 #include <GLES2/gl2ext.h> |
| 9 #include <GLES2/gl2extchromium.h> | 9 #include <GLES2/gl2extchromium.h> |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 namespace ash { | 39 namespace ash { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 // Variables for rendering the laser. Radius in DIP. | 42 // Variables for rendering the laser. Radius in DIP. |
| 43 const float kPointInitialRadius = 5.0f; | 43 const float kPointInitialRadius = 5.0f; |
| 44 const float kPointFinalRadius = 0.25f; | 44 const float kPointFinalRadius = 0.25f; |
| 45 const int kPointInitialOpacity = 200; | 45 const int kPointInitialOpacity = 200; |
| 46 const int kPointFinalOpacity = 10; | 46 const int kPointFinalOpacity = 10; |
| 47 const SkColor kPointColor = SkColorSetRGB(255, 0, 0); | 47 const SkColor kPointColor = SkColorSetRGB(255, 0, 0); |
| 48 | 48 |
| 49 float DistanceBetweenPoints(const gfx::Point& point1, | 49 float DistanceBetweenPoints(const gfx::PointF& point1, |
| 50 const gfx::Point& point2) { | 50 const gfx::PointF& point2) { |
| 51 return (point1 - point2).Length(); | 51 return (point1 - point2).Length(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 float LinearInterpolate(float initial_value, | 54 float LinearInterpolate(float initial_value, |
| 55 float final_value, | 55 float final_value, |
| 56 float progress) { | 56 float progress) { |
| 57 return initial_value + (final_value - initial_value) * progress; | 57 return initial_value + (final_value - initial_value) * progress; |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace | 60 } // namespace |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 if (gpu_memory_buffer_) | 238 if (gpu_memory_buffer_) |
| 239 gpu_memory_buffer_->Unmap(); | 239 gpu_memory_buffer_->Unmap(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void LaserPointerView::Stop() { | 242 void LaserPointerView::Stop() { |
| 243 buffer_damage_rect_.Union(GetBoundingBox()); | 243 buffer_damage_rect_.Union(GetBoundingBox()); |
| 244 laser_points_.Clear(); | 244 laser_points_.Clear(); |
| 245 OnPointsUpdated(); | 245 OnPointsUpdated(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void LaserPointerView::AddNewPoint(const gfx::Point& new_point) { | 248 void LaserPointerView::AddNewPoint(const gfx::PointF& new_point) { |
| 249 buffer_damage_rect_.Union(GetBoundingBox()); | 249 buffer_damage_rect_.Union(GetBoundingBox()); |
| 250 laser_points_.AddPoint(new_point); | 250 laser_points_.AddPoint(new_point); |
| 251 buffer_damage_rect_.Union(GetBoundingBox()); | 251 buffer_damage_rect_.Union(GetBoundingBox()); |
| 252 OnPointsUpdated(); | 252 OnPointsUpdated(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 void LaserPointerView::UpdateTime() { | 255 void LaserPointerView::UpdateTime() { |
| 256 buffer_damage_rect_.Union(GetBoundingBox()); | 256 buffer_damage_rect_.Union(GetBoundingBox()); |
| 257 // Do not add the point but advance the time if the view is in process of | 257 // Do not add the point but advance the time if the view is in process of |
| 258 // fading away. | 258 // fading away. |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 pending_draw_surface_ = true; | 592 pending_draw_surface_ = true; |
| 593 } | 593 } |
| 594 | 594 |
| 595 void LaserPointerView::OnDidDrawSurface() { | 595 void LaserPointerView::OnDidDrawSurface() { |
| 596 pending_draw_surface_ = false; | 596 pending_draw_surface_ = false; |
| 597 if (needs_update_surface_) | 597 if (needs_update_surface_) |
| 598 UpdateSurface(); | 598 UpdateSurface(); |
| 599 } | 599 } |
| 600 | 600 |
| 601 } // namespace ash | 601 } // namespace ash |
| OLD | NEW |