Fix Rect::Compare bugs (flutter/engine#10)
This commit is contained in:
committed by
Dan Field
parent
bfdba8de0b
commit
a7c10ebfab
@@ -310,5 +310,30 @@ TEST(GeometryTest, RectIntersection) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(GeometryTest, RectContainsPoint) {
|
||||
{
|
||||
// Origin is inclusive
|
||||
Rect r(100, 100, 100, 100);
|
||||
Point p(100, 100);
|
||||
ASSERT_TRUE(r.Contains(p));
|
||||
}
|
||||
{
|
||||
// Size is exclusive
|
||||
Rect r(100, 100, 100, 100);
|
||||
Point p(200, 200);
|
||||
ASSERT_FALSE(r.Contains(p));
|
||||
}
|
||||
{
|
||||
Rect r(100, 100, 100, 100);
|
||||
Point p(99, 99);
|
||||
ASSERT_FALSE(r.Contains(p));
|
||||
}
|
||||
{
|
||||
Rect r(100, 100, 100, 100);
|
||||
Point p(199, 199);
|
||||
ASSERT_TRUE(r.Contains(p));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
} // namespace impeller
|
||||
|
||||
@@ -80,8 +80,8 @@ struct TRect {
|
||||
}
|
||||
|
||||
constexpr bool Contains(const TPoint<Type>& p) const {
|
||||
return p.x >= origin.x && p.x <= size.width && p.y >= origin.y &&
|
||||
p.y <= size.height;
|
||||
return p.x >= origin.x && p.x < origin.x + size.width && p.y >= origin.y &&
|
||||
p.y < origin.y + size.height;
|
||||
}
|
||||
|
||||
constexpr bool IsZero() const { return size.IsZero(); }
|
||||
|
||||
Reference in New Issue
Block a user