summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_coordinates.h
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2017-02-22 19:56:15 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-02-23 01:17:40 +0000
commitb147e07ee36be10ca0796a6566be107077c21a03 (patch)
tree637b1b206000a88fb3e198f648e86a9ee5178f1b /core/fxcrt/fx_coordinates.h
parente3f237740fd8bea50b4a6f37f56455dfa0328546 (diff)
downloadpdfium-b147e07ee36be10ca0796a6566be107077c21a03.tar.xz
Convert point x,y into CFX_PointF
This Cl converts the PointX,PointY pairs into a CFX_PointF. Change-Id: I46897832077c317a5bffb4e568550705decbc40c Reviewed-on: https://pdfium-review.googlesource.com/2821 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_coordinates.h')
-rw-r--r--core/fxcrt/fx_coordinates.h97
1 files changed, 49 insertions, 48 deletions
diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h
index d1fa8115b7..a900506fe7 100644
--- a/core/fxcrt/fx_coordinates.h
+++ b/core/fxcrt/fx_coordinates.h
@@ -127,16 +127,16 @@ class CFX_STemplate {
height /= divisor;
return *this;
}
- CFX_STemplate operator+(const CFX_STemplate& other) {
+ CFX_STemplate operator+(const CFX_STemplate& other) const {
return CFX_STemplate(width + other.width, height + other.height);
}
- CFX_STemplate operator-(const CFX_STemplate& other) {
+ CFX_STemplate operator-(const CFX_STemplate& other) const {
return CFX_STemplate(width - other.width, height - other.height);
}
- CFX_STemplate operator*(BaseType factor) {
+ CFX_STemplate operator*(BaseType factor) const {
return CFX_STemplate(width * factor, height * factor);
}
- CFX_STemplate operator/(BaseType divisor) {
+ CFX_STemplate operator/(BaseType divisor) const {
return CFX_STemplate(width / divisor, height / divisor);
}
@@ -192,50 +192,6 @@ using CFX_VectorF = CFX_VTemplate<FX_FLOAT>;
// Rectangles.
// TODO(tsepez): Consolidate all these different rectangle classes.
-// LTRB rectangles (y-axis runs downwards).
-struct FX_RECT {
- FX_RECT() : left(0), top(0), right(0), bottom(0) {}
- FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {}
-
- int Width() const { return right - left; }
- int Height() const { return bottom - top; }
- bool IsEmpty() const { return right <= left || bottom <= top; }
-
- bool Valid() const {
- pdfium::base::CheckedNumeric<int> w = right;
- pdfium::base::CheckedNumeric<int> h = bottom;
- w -= left;
- h -= top;
- return w.IsValid() && h.IsValid();
- }
-
- void Normalize();
-
- void Intersect(const FX_RECT& src);
- void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); }
-
- void Offset(int dx, int dy) {
- left += dx;
- right += dx;
- top += dy;
- bottom += dy;
- }
-
- bool operator==(const FX_RECT& src) const {
- return left == src.left && right == src.right && top == src.top &&
- bottom == src.bottom;
- }
-
- bool Contains(int x, int y) const {
- return x >= left && x < right && y >= top && y < bottom;
- }
-
- int32_t left;
- int32_t top;
- int32_t right;
- int32_t bottom;
-};
-
// LTWH rectangles (y-axis runs downwards).
template <class BaseType>
class CFX_RTemplate {
@@ -450,6 +406,51 @@ class CFX_RTemplate {
using CFX_Rect = CFX_RTemplate<int32_t>;
using CFX_RectF = CFX_RTemplate<FX_FLOAT>;
+// LTRB rectangles (y-axis runs downwards).
+struct FX_RECT {
+ FX_RECT() : left(0), top(0), right(0), bottom(0) {}
+ FX_RECT(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {}
+
+ int Width() const { return right - left; }
+ int Height() const { return bottom - top; }
+ bool IsEmpty() const { return right <= left || bottom <= top; }
+
+ bool Valid() const {
+ pdfium::base::CheckedNumeric<int> w = right;
+ pdfium::base::CheckedNumeric<int> h = bottom;
+ w -= left;
+ h -= top;
+ return w.IsValid() && h.IsValid();
+ }
+
+ void Normalize();
+
+ void Intersect(const FX_RECT& src);
+ void Intersect(int l, int t, int r, int b) { Intersect(FX_RECT(l, t, r, b)); }
+
+ void Offset(int dx, int dy) {
+ left += dx;
+ right += dx;
+ top += dy;
+ bottom += dy;
+ }
+
+ bool operator==(const FX_RECT& src) const {
+ return left == src.left && right == src.right && top == src.top &&
+ bottom == src.bottom;
+ }
+
+ bool Contains(int x, int y) const {
+ return x >= left && x < right && y >= top && y < bottom;
+ }
+
+ int32_t left;
+ int32_t top;
+ int32_t right;
+ int32_t bottom;
+};
+
+// LTRB rectangles (y-axis runs upwards).
class CFX_FloatRect {
public:
CFX_FloatRect() : CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f) {}