10#define _SRect_DEFINED_
17inline void STSwap(T &a, T &b)
26struct SOUI_EXP SRect :
public fRect
28 static SRect IMake(
const RECT &src)
40 return fLeft >= fRight || fTop >= fBottom;
43 bool isLargest()
const
45 return SK_ScalarMin == fLeft && SK_ScalarMin == fTop && SK_ScalarMax == fRight && SK_ScalarMax == fBottom;
62 SASSERT(0 == accum || !(accum == accum));
66 return accum == accum;
95 return fRight - fLeft;
99 return fBottom - fTop;
101 float centerX()
const
103 return SFloatHalf(fLeft + fRight);
105 float centerY()
const
107 return SFloatHalf(fTop + fBottom);
110 friend bool operator==(
const SRect &a,
const SRect &b)
112 return SFloatsEqual((
float *)&a, (
float *)&b, 4);
115 friend bool operator!=(
const SRect &a,
const SRect &b)
117 return !SFloatsEqual((
float *)&a, (
float *)&b, 4);
123 void toQuad(SPoint quad[4])
const;
129 memset(
this, 0,
sizeof(*
this));
132 void iset(
const RECT &src)
134 fLeft = SkIntToScalar(src.left);
135 fTop = SkIntToScalar(src.top);
136 fRight = SkIntToScalar(src.right);
137 fBottom = SkIntToScalar(src.bottom);
143 rc.left = sk_float_floor2int(fLeft);
144 rc.top = sk_float_floor2int(fTop);
145 rc.right = sk_float_ceil2int(fRight);
146 rc.bottom = sk_float_ceil2int(fBottom);
150 void set(
float left,
float top,
float right,
float bottom)
161 void iset(
int left,
int top,
int right,
int bottom)
163 fLeft = SkIntToScalar(left);
164 fTop = SkIntToScalar(top);
165 fRight = SkIntToScalar(right);
166 fBottom = SkIntToScalar(bottom);
173 void set(
const SPoint pts[],
int count)
178 (void)this->setBoundsCheck(pts, count);
182 void setBounds(
const SPoint pts[],
int count)
184 (void)this->setBoundsCheck(pts, count);
192 bool setBoundsCheck(
const SPoint pts[],
int count);
194 void set(
const SPoint &p0,
const SPoint &p1)
196 fLeft = SkMinScalar(p0.fX, p1.fX);
197 fRight = SkMaxScalar(p0.fX, p1.fX);
198 fTop = SkMinScalar(p0.fY, p1.fY);
199 fBottom = SkMaxScalar(p0.fY, p1.fY);
205 void offset(
float dx,
float dy)
213 void offset(
const SPoint &delta)
215 this->offset(delta.fX, delta.fY);
221 void offsetTo(
float newX,
float newY)
223 fRight += newX - fLeft;
224 fBottom += newY - fTop;
234 void inset(
float dx,
float dy)
247 void outset(
float dx,
float dy)
249 this->inset(-dx, -dy);
263 const float *asScalars()
const
269struct SOUI_EXP STriangle
272 bool contains(
const SPoint &pt)
const;
278 bool contains(
const SPoint &pt)
const;