Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1062)

Unified Diff: ash/laser/laser_pointer_view.cc

Issue 2772703002: ash: Improve laser pointer prediction calculations at stylus down. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/laser/laser_pointer_view.cc
diff --git a/ash/laser/laser_pointer_view.cc b/ash/laser/laser_pointer_view.cc
index d567506ef0ace5cd4a0bf9c863dea651d0e14a59..40c268648dcffbfc79e00453d89f1c6dd95bfdf0 100644
--- a/ash/laser/laser_pointer_view.cc
+++ b/ash/laser/laser_pointer_view.cc
@@ -294,7 +294,9 @@ void LaserPointerView::AddNewPoint(const gfx::PointF& new_point,
base::TimeDelta::FromMilliseconds(kPredictionIntervalMs);
base::TimeDelta max_point_interval =
base::TimeDelta::FromMilliseconds(kMaxPointIntervalMs);
- base::TimeTicks last_point_time = current_time;
+ base::TimeTicks last_point_time = new_time;
+ gfx::PointF last_point_location =
+ gfx::ScalePoint(new_point, scale.x(), scale.y());
// Use the last four points for prediction.
using PositionArray = std::array<gfx::PointF, 4>;
@@ -306,15 +308,16 @@ void LaserPointerView::AddNewPoint(const gfx::PointF& new_point,
if ((last_point_time - point.time) > max_point_interval)
break;
- *it++ = gfx::ScalePoint(point.location, scale.x(), scale.y());
last_point_time = point.time;
+ last_point_location = gfx::ScalePoint(point.location, scale.x(), scale.y());
+ *it++ = last_point_location;
// Stop when no more positions are needed.
if (it == position.end())
break;
}
// Pad with last point if needed.
- std::fill(it, position.end(), *(it - 1));
+ std::fill(it, position.end(), last_point_location);
// Note: Currently there's no need to divide by the time delta between
// points as we assume a constant delta between points that matches the
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698