1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11 #include "gfxLineSegment.h"
15 gfxQuad(const gfxPoint
& aOne
, const gfxPoint
& aTwo
, const gfxPoint
& aThree
,
16 const gfxPoint
& aFour
) {
23 bool Contains(const gfxPoint
& aPoint
) {
24 return (gfxLineSegment(mPoints
[0], mPoints
[1])
25 .PointsOnSameSide(aPoint
, mPoints
[2]) &&
26 gfxLineSegment(mPoints
[1], mPoints
[2])
27 .PointsOnSameSide(aPoint
, mPoints
[3]) &&
28 gfxLineSegment(mPoints
[2], mPoints
[3])
29 .PointsOnSameSide(aPoint
, mPoints
[0]) &&
30 gfxLineSegment(mPoints
[3], mPoints
[0])
31 .PointsOnSameSide(aPoint
, mPoints
[1]));
35 gfxFloat min_x
, max_x
;
36 gfxFloat min_y
, max_y
;
38 min_x
= max_x
= mPoints
[0].x
;
39 min_y
= max_y
= mPoints
[0].y
;
41 for (int i
= 1; i
< 4; i
++) {
42 min_x
= std::min(mPoints
[i
].x
.value
, min_x
);
43 max_x
= std::max(mPoints
[i
].x
.value
, max_x
);
44 min_y
= std::min(mPoints
[i
].y
.value
, min_y
);
45 max_y
= std::max(mPoints
[i
].y
.value
, max_y
);
47 return gfxRect(min_x
, min_y
, max_x
- min_x
, max_y
- min_y
);
53 #endif /* GFX_QUAD_H */