Line data Source code
1 : /*
2 : * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 : *
4 : * Use of this source code is governed by a BSD-style license
5 : * that can be found in the LICENSE file in the root of the source
6 : * tree. An additional intellectual property rights grant can be found
7 : * in the file PATENTS. All contributing project authors may
8 : * be found in the AUTHORS file in the root of the source tree.
9 : */
10 :
11 : #include "webrtc/modules/desktop_capture/desktop_geometry.h"
12 :
13 : #include <algorithm>
14 :
15 : namespace webrtc {
16 :
17 0 : bool DesktopRect::Contains(const DesktopVector& point) const {
18 0 : return point.x() >= left() && point.x() < right() &&
19 0 : point.y() >= top() && point.y() < bottom();
20 : }
21 :
22 0 : bool DesktopRect::ContainsRect(const DesktopRect& rect) const {
23 0 : return rect.left() >= left() && rect.right() <= right() &&
24 0 : rect.top() >= top() && rect.bottom() <= bottom();
25 : }
26 :
27 0 : void DesktopRect::IntersectWith(const DesktopRect& rect) {
28 0 : left_ = std::max(left(), rect.left());
29 0 : top_ = std::max(top(), rect.top());
30 0 : right_ = std::min(right(), rect.right());
31 0 : bottom_ = std::min(bottom(), rect.bottom());
32 0 : if (is_empty()) {
33 0 : left_ = 0;
34 0 : top_ = 0;
35 0 : right_ = 0;
36 0 : bottom_ = 0;
37 : }
38 0 : }
39 :
40 0 : void DesktopRect::Translate(int32_t dx, int32_t dy) {
41 0 : left_ += dx;
42 0 : top_ += dy;
43 0 : right_ += dx;
44 0 : bottom_ += dy;
45 0 : }
46 :
47 0 : void DesktopRect::Extend(int32_t left_offset,
48 : int32_t top_offset,
49 : int32_t right_offset,
50 : int32_t bottom_offset) {
51 0 : left_ -= left_offset;
52 0 : top_ -= top_offset;
53 0 : right_ += right_offset;
54 0 : bottom_ += bottom_offset;
55 0 : }
56 :
57 : } // namespace webrtc
58 :
|