OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 right_ = std::min(right(), rect.right()); | 30 right_ = std::min(right(), rect.right()); |
31 bottom_ = std::min(bottom(), rect.bottom()); | 31 bottom_ = std::min(bottom(), rect.bottom()); |
32 if (is_empty()) { | 32 if (is_empty()) { |
33 left_ = 0; | 33 left_ = 0; |
34 top_ = 0; | 34 top_ = 0; |
35 right_ = 0; | 35 right_ = 0; |
36 bottom_ = 0; | 36 bottom_ = 0; |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
| 40 void DesktopRect::UnionWith(const DesktopRect& rect) { |
| 41 if (is_empty()) { |
| 42 *this = rect; |
| 43 return; |
| 44 } |
| 45 |
| 46 if (rect.is_empty()) { |
| 47 return; |
| 48 } |
| 49 |
| 50 left_ = std::min(left(), rect.left()); |
| 51 top_ = std::min(top(), rect.top()); |
| 52 right_ = std::max(right(), rect.right()); |
| 53 bottom_ = std::max(bottom(), rect.bottom()); |
| 54 } |
| 55 |
40 void DesktopRect::Translate(int32_t dx, int32_t dy) { | 56 void DesktopRect::Translate(int32_t dx, int32_t dy) { |
41 left_ += dx; | 57 left_ += dx; |
42 top_ += dy; | 58 top_ += dy; |
43 right_ += dx; | 59 right_ += dx; |
44 bottom_ += dy; | 60 bottom_ += dy; |
45 } | 61 } |
46 | 62 |
47 void DesktopRect::Extend(int32_t left_offset, | 63 void DesktopRect::Extend(int32_t left_offset, |
48 int32_t top_offset, | 64 int32_t top_offset, |
49 int32_t right_offset, | 65 int32_t right_offset, |
50 int32_t bottom_offset) { | 66 int32_t bottom_offset) { |
51 left_ -= left_offset; | 67 left_ -= left_offset; |
52 top_ -= top_offset; | 68 top_ -= top_offset; |
53 right_ += right_offset; | 69 right_ += right_offset; |
54 bottom_ += bottom_offset; | 70 bottom_ += bottom_offset; |
55 } | 71 } |
56 | 72 |
57 } // namespace webrtc | 73 } // namespace webrtc |
58 | 74 |
OLD | NEW |