diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-15 12:42:22 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-15 12:42:22 +0100 |
| commit | 13511ed2fcc23f4d5f9c507c775c3c5cfd82d155 (patch) | |
| tree | 5ab1d1600725873a199725e50d67da9791c25d67 /src/lib/util.cc | |
| parent | cb33319a820b17a05cfb2ef78ba1799f4d0c54b9 (diff) | |
| parent | 43990add893eccf350f280e2dd3f947a94f3e9aa (diff) | |
Merge branch 'master' of /home/carl/git/dvdomatic
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 935566440..fbe77461e 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -600,3 +600,24 @@ Socket::read_indefinite (uint8_t* data, int size, int timeout) assert (size >= _buffer_data); memcpy (data, _buffer, size); } + +Rectangle +Rectangle::intersection (Rectangle const & other) const +{ + int const tx = max (x, other.x); + int const ty = max (y, other.y); + + return Rectangle ( + tx, ty, + min (x + w, other.x + other.w) - tx, + min (y + h, other.y + other.h) - ty + ); +} + +int +round_up (int a, int t) +{ + a += (t - 1); + return a - (a % t); +} + |
