summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/include/fxcrt/fx_coordinates.h19
-rw-r--r--core/src/fxcrt/fx_basic_coords.cpp20
2 files changed, 22 insertions, 17 deletions
diff --git a/core/include/fxcrt/fx_coordinates.h b/core/include/fxcrt/fx_coordinates.h
index 2cd249310e..2f52f78b8f 100644
--- a/core/include/fxcrt/fx_coordinates.h
+++ b/core/include/fxcrt/fx_coordinates.h
@@ -185,10 +185,10 @@ struct FX_RECT {
static_cast<uint16_t>(right), static_cast<uint16_t>(bottom));
}
- int left;
- int top;
- int right;
- int bottom;
+ int32_t left;
+ int32_t top;
+ int32_t right;
+ int32_t bottom;
};
// LBRT rectangles (y-axis runs upwards).
@@ -220,9 +220,9 @@ class CFX_FloatRect {
top = 0.0f;
}
- FX_BOOL IsEmpty() const { return left >= right || bottom >= top; }
- FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
- FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
+ bool IsEmpty() const { return left >= right || bottom >= top; }
+ bool Contains(const CFX_FloatRect& other_rect) const;
+ bool Contains(FX_FLOAT x, FX_FLOAT y) const;
void Transform(const CFX_Matrix* pMatrix);
void Intersect(const CFX_FloatRect& other_rect);
@@ -300,6 +300,11 @@ class CFX_FloatRect {
static CFX_FloatRect GetBBox(const CFX_PointF* pPoints, int nPoints);
+ FX_RECT ToFxRect() const {
+ return FX_RECT(static_cast<int32_t>(left), static_cast<int32_t>(top),
+ static_cast<int32_t>(right), static_cast<int32_t>(bottom));
+ }
+
FX_FLOAT left;
FX_FLOAT bottom;
FX_FLOAT right;
diff --git a/core/src/fxcrt/fx_basic_coords.cpp b/core/src/fxcrt/fx_basic_coords.cpp
index 27feb55113..4f723ef919 100644
--- a/core/src/fxcrt/fx_basic_coords.cpp
+++ b/core/src/fxcrt/fx_basic_coords.cpp
@@ -187,22 +187,22 @@ FX_RECT CFX_FloatRect::GetClosestRect() const {
rect.Normalize();
return rect;
}
-FX_BOOL CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const {
- CFX_FloatRect n1 = *this;
+
+bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const {
+ CFX_FloatRect n1(*this);
+ CFX_FloatRect n2(other_rect);
n1.Normalize();
- CFX_FloatRect n2 = other_rect;
n2.Normalize();
- if (n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom &&
- n2.top <= n1.top) {
- return TRUE;
- }
- return FALSE;
+ return n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom &&
+ n2.top <= n1.top;
}
-FX_BOOL CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const {
- CFX_FloatRect n1 = *this;
+
+bool CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const {
+ CFX_FloatRect n1(*this);
n1.Normalize();
return x <= n1.right && x >= n1.left && y <= n1.top && y >= n1.bottom;
}
+
void CFX_FloatRect::UpdateRect(FX_FLOAT x, FX_FLOAT y) {
if (left > x) {
left = x;