Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: webrtc/modules/desktop_capture/desktop_geometry.cc

Issue 2845213002: DesktopRect::UnionWith() to extend current rect to cover the input rect (Closed)
Patch Set: Resolve review comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 left_ = rect.left();
Sergey Ulanov 2017/05/16 19:53:00 *this = rect;
Hzj_jie 2017/05/16 23:04:18 Done.
43 top_ = rect.top();
44 right_ = rect.right();
45 bottom_ = rect.bottom();
46 } else if (!rect.is_empty()) {
Sergey Ulanov 2017/05/16 19:53:00 I'd prefer to format this function as follows:
Hzj_jie 2017/05/16 23:04:18 Done.
47 left_ = std::min(left(), rect.left());
48 top_ = std::min(top(), rect.top());
49 right_ = std::max(right(), rect.right());
50 bottom_ = std::max(bottom(), rect.bottom());
51 }
52 }
53
40 void DesktopRect::Translate(int32_t dx, int32_t dy) { 54 void DesktopRect::Translate(int32_t dx, int32_t dy) {
41 left_ += dx; 55 left_ += dx;
42 top_ += dy; 56 top_ += dy;
43 right_ += dx; 57 right_ += dx;
44 bottom_ += dy; 58 bottom_ += dy;
45 } 59 }
46 60
47 void DesktopRect::Extend(int32_t left_offset, 61 void DesktopRect::Extend(int32_t left_offset,
48 int32_t top_offset, 62 int32_t top_offset,
49 int32_t right_offset, 63 int32_t right_offset,
50 int32_t bottom_offset) { 64 int32_t bottom_offset) {
51 left_ -= left_offset; 65 left_ -= left_offset;
52 top_ -= top_offset; 66 top_ -= top_offset;
53 right_ += right_offset; 67 right_ += right_offset;
54 bottom_ += bottom_offset; 68 bottom_ += bottom_offset;
55 } 69 }
56 70
57 } // namespace webrtc 71 } // namespace webrtc
58 72
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698