xref: /aosp_15_r20/external/skia/modules/bentleyottmann/include/Point.h (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1 // Copyright 2023 Google LLC
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 
4 #ifndef Point_DEFINED
5 #define Point_DEFINED
6 
7 #include <cstdint>
8 
9 namespace bentleyottmann {
10 struct Point {
11     int32_t x;
12     int32_t y;
13 
14     // Relation for ordering events.
15     friend bool operator<(const Point& p0, const Point& p1);
16     friend bool operator>(const Point& p0, const Point& p1);
17     friend bool operator>=(const Point& p0, const Point& p1);
18     friend bool operator<=(const Point& p0, const Point& p1);
19 
20     // Equality
21     friend bool operator==(const Point& p0, const Point& p1);
22     friend bool operator!=(const Point& p0, const Point& p1);
23 
24     // Extremes
25     static Point Smallest();
26     static Point Largest();
27     static bool DifferenceTooBig(Point p0, Point p1);
28 
29     // Terms
30     friend Point operator+(const Point& p0, const Point& p1) {
31         return {p0.x + p1.x, p0.y + p1.y};
32     }
33     friend Point operator-(const Point& p0, const Point& p1) {
34         return {p0.x - p1.x, p0.y - p1.y};
35     }
36 };
37 }  // namespace bentleyottmann
38 #endif  // Point_DEFINED
39