blob: 2c47f43b88798d995c2258774105e9cc2afad538 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkPathOpsRect_DEFINED
#define SkPathOpsRect_DEFINED
#include "SkPathOpsPoint.h"
struct SkDRect {
double fLeft, fTop, fRight, fBottom;
void add(const SkDPoint& pt) {
if (fLeft > pt.fX) {
fLeft = pt.fX;
}
if (fTop > pt.fY) {
fTop = pt.fY;
}
if (fRight < pt.fX) {
fRight = pt.fX;
}
if (fBottom < pt.fY) {
fBottom = pt.fY;
}
}
bool contains(const SkDPoint& pt) const {
return approximately_between(fLeft, pt.fX, fRight)
&& approximately_between(fTop, pt.fY, fBottom);
}
bool intersects(SkDRect* r) const {
SkASSERT(fLeft <= fRight);
SkASSERT(fTop <= fBottom);
SkASSERT(r->fLeft <= r->fRight);
SkASSERT(r->fTop <= r->fBottom);
return r->fLeft <= fRight && fLeft <= r->fRight && r->fTop <= fBottom && fTop <= r->fBottom;
}
void set(const SkDPoint& pt) {
fLeft = fRight = pt.fX;
fTop = fBottom = pt.fY;
}
double width() const {
return fRight - fLeft;
}
double height() const {
return fBottom - fTop;
}
void setBounds(const SkDLine&);
void setBounds(const SkDCubic&);
void setBounds(const SkDQuad&);
void setRawBounds(const SkDCubic&);
void setRawBounds(const SkDQuad&);
};
#endif
|