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 #ifndef ASH_LASER_LASER_POINTER_POINTS_H_ | 5 #ifndef ASH_LASER_LASER_POINTER_POINTS_H_ |
6 #define ASH_LASER_LASER_POINTER_POINTS_H_ | 6 #define ASH_LASER_LASER_POINTER_POINTS_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... | |
26 base::Time creation_time; | 26 base::Time creation_time; |
27 }; | 27 }; |
28 | 28 |
29 // Constructor with a parameter to choose the fade out time of the points in | 29 // Constructor with a parameter to choose the fade out time of the points in |
30 // the collection. | 30 // the collection. |
31 explicit LaserPointerPoints(base::TimeDelta life_duration); | 31 explicit LaserPointerPoints(base::TimeDelta life_duration); |
32 ~LaserPointerPoints(); | 32 ~LaserPointerPoints(); |
33 | 33 |
34 // Adds a point. Automatically clears points that are too old. | 34 // Adds a point. Automatically clears points that are too old. |
35 void AddPoint(const gfx::Point& point); | 35 void AddPoint(const gfx::Point& point); |
36 // Updates the collection latest time. Automatically clears points that are | |
37 // too | |
jdufault
2016/09/23 23:59:19
Fix formatting
sammiequon
2016/09/26 19:30:38
Done.
| |
38 // old. | |
39 void MoveForwardInTime(); | |
40 void MoveForwardInTime(const base::Time& new_latest_time); | |
36 // Removes all points. | 41 // Removes all points. |
37 void Clear(); | 42 void Clear(); |
38 // Gets the bounding box of the points. | 43 // Gets the bounding box of the points. |
39 gfx::Rect GetBoundingBox(); | 44 gfx::Rect GetBoundingBox(); |
40 // Returns the oldest point in the collection. | 45 // Returns the oldest point in the collection. |
41 LaserPoint GetOldest() const; | 46 LaserPoint GetOldest() const; |
42 // Returns the newest point in the collection. | 47 // Returns the newest point in the collection. |
43 LaserPoint GetNewest() const; | 48 LaserPoint GetNewest() const; |
49 // Returns the latest time of the collection. | |
50 base::Time GetCollectionLatestTime() const; | |
51 // Returns the earliest time of the collection. | |
52 base::Time GetCollectionEarliestTime() const; | |
44 // Returns the number of points in the collection. | 53 // Returns the number of points in the collection. |
45 int GetNumberOfPoints() const; | 54 int GetNumberOfPoints() const; |
46 // Whether there are any points or not. | 55 // Whether there are any points or not. |
47 bool IsEmpty() const; | 56 bool IsEmpty() const; |
48 // Expose the collection so callers can work with the points. | 57 // Expose the collection so callers can work with the points. |
49 const std::deque<LaserPoint>& laser_points(); | 58 const std::deque<LaserPoint>& laser_points(); |
50 | 59 |
51 private: | 60 private: |
52 friend class LaserPointerPointsTestApi; | 61 friend class LaserPointerPointsTestApi; |
53 | 62 |
54 void ClearOldPoints(); | 63 void ClearOldPoints(); |
55 | 64 |
56 base::TimeDelta life_duration_; | 65 base::TimeDelta life_duration_; |
57 std::deque<LaserPoint> points_; | 66 std::deque<LaserPoint> points_; |
67 // The latest time of the collection of points. This gets updated when new | |
68 // points are added or when MoveForwardInTime is called. | |
69 base::Time collection_latest_time_; | |
58 | 70 |
59 DISALLOW_COPY_AND_ASSIGN(LaserPointerPoints); | 71 DISALLOW_COPY_AND_ASSIGN(LaserPointerPoints); |
60 }; | 72 }; |
61 | 73 |
62 } // namespace ash | 74 } // namespace ash |
63 | 75 |
64 #endif // ASH_LASER_LASER_POINTER_POINTS_H_ | 76 #endif // ASH_LASER_LASER_POINTER_POINTS_H_ |
OLD | NEW |