12#ifndef UI_GFX_GEOMETRY_RECT_H_
13#define UI_GFX_GEOMETRY_RECT_H_
27typedef struct tagRECT RECT;
28#elif defined(OS_APPLE)
29typedef struct CGRect CGRect;
38 constexpr Rect() =
default;
41 : origin_(
x,
y), size_(GetClampedValue(
x,
width), GetClampedValue(
y,
height)) {}
45 size_(GetClampedValue(origin.
x(),
size.
width()),
49 explicit Rect(
const RECT& r);
50#elif defined(OS_APPLE)
51 explicit Rect(
const CGRect& r);
57#elif defined(OS_APPLE)
59 CGRect ToCGRect()
const;
62 constexpr int x()
const {
return origin_.x(); }
66 size_.set_width(GetClampedValue(
x,
width()));
69 constexpr int y()
const {
return origin_.y(); }
73 size_.set_height(GetClampedValue(
y,
height()));
76 constexpr int width()
const {
return size_.width(); }
79 constexpr int height()
const {
return size_.height(); }
90 constexpr const Size&
size()
const {
return size_; }
92 set_width(
size.width());
93 set_height(
size.height());
111 origin_.SetPoint(
x,
y);
120 void SetByBounds(
int left,
int top,
int right,
int bottom);
123 void Inset(
int horizontal,
int vertical) {
Inset(horizontal, vertical, horizontal, vertical); }
126 void Inset(
const Insets& insets);
129 void Inset(
int left,
int top,
int right,
int bottom);
132 void Offset(
int horizontal,
int vertical);
140 bool IsEmpty()
const {
return size_.IsEmpty(); }
153 bool Contains(
int point_x,
int point_y)
const;
163 bool Intersects(
const Rect&
rect)
const;
184 Point CenterPoint()
const;
188 void ClampToCenteredSize(
const Size&
size);
194 void SplitVertically(
Rect* left_half,
Rect* right_half)
const;
198 bool SharesEdgeWith(
const Rect&
rect)
const;
202 int ManhattanDistanceToPoint(
const Point& point)
const;
208 int ManhattanInternalDistance(
const Rect&
rect)
const;
212 bool ApproximatelyEqual(
const Rect&
rect,
int tolerance)
const;
219 static constexpr bool AddWouldOverflow(
int a,
int b) {
226 return a > 0 &&
b > 0 &&
234 static constexpr int GetClampedValue(
int origin,
int size) {
244 return !(lhs == rhs);
270 if (x_scale == 1.f && y_scale == 1.f)
296 if (x_scale == 1.f && y_scale == 1.f)
310 if (x_scale == 1.f && y_scale == 1.f)
334 if (x_scale == 1.f && y_scale == 1.f)
static void round(SkPoint *p)
static void Union(SkRegion *rgn, const SkIRect &rect)
constexpr int height() const
void set_width(int width)
void set_origin(const Point &origin)
bool Contains(const Point &point) const
constexpr Rect(int width, int height)
constexpr int right() const
void Offset(const Vector2d &distance)
constexpr const Point & origin() const
constexpr int bottom() const
void set_size(const Size &size)
void set_height(int height)
constexpr Point left_center() const
constexpr Rect(int x, int y, int width, int height)
constexpr Point bottom_right() const
constexpr const Size & size() const
constexpr Rect(const Point &origin, const Size &size)
constexpr Point top_right() const
constexpr Point bottom_center() const
constexpr Point bottom_left() const
constexpr Point right_center() const
void Inset(int horizontal, int vertical)
void SetRect(int x, int y, int width, int height)
Vector2d OffsetFromOrigin() const
constexpr Point top_center() const
constexpr Rect(const Size &size)
constexpr int width() const
static float max(float r, float g, float b)
sk_sp< SkBlender > blender SkRect rect
Dst ClampFloor(Src value)
bool Contains(const Container &container, const Value &value)
Rect BoundingRect(const Point &p1, const Point &p2)
Rect IntersectRects(const Rect &a, const Rect &b)
Insets operator+(Insets lhs, const Insets &rhs)
Rect UnionRects(const Rect &a, const Rect &b)
Rect SubtractRects(const Rect &a, const Rect &b)
Rect ScaleToEnclosedRect(const Rect &rect, float x_scale, float y_scale)
void PrintTo(const Point &point, ::std::ostream *os)
Insets operator-(Insets lhs, const Insets &rhs)
Rect ScaleToRoundedRect(const Rect &rect, float x_scale, float y_scale)
bool operator==(const Point &lhs, const Point &rhs)
Rect ScaleToEnclosingRectSafe(const Rect &rect, float x_scale, float y_scale)
Rect ScaleToEnclosingRect(const Rect &rect, float x_scale, float y_scale)
constexpr size_t size(const T(&array)[N]) noexcept
bool operator!=(const Point &lhs, const Point &rhs)
static std::string ToString(CompilerBackend::Type type)
constexpr bool operator<(const EnumType &lhs, const Mask< EnumType > &rhs)
SINT Vec< N, T > & operator-=(Vec< N, T > &x, const Vec< N, T > &y)
SINT Vec< N, T > & operator+=(Vec< N, T > &x, const Vec< N, T > &y)
SIN Vec< N, float > floor(const Vec< N, float > &x)
SIN Vec< N, float > ceil(const Vec< N, float > &x)
#define BASE_DCHECK(condition)