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

Unified Diff: webrtc/modules/desktop_capture/desktop_geometry.cc

Issue 2845213002: DesktopRect::UnionWith() to extend current rect to cover the input rect (Closed)
Patch Set: Rename JoinWith to UnionWith Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/desktop_capture/desktop_geometry.cc
diff --git a/webrtc/modules/desktop_capture/desktop_geometry.cc b/webrtc/modules/desktop_capture/desktop_geometry.cc
index 2af8cf826e4dc70193e58569b0e6824eddc140de..6c85d7a869408553fc2c132a5e466db8406413ab 100644
--- a/webrtc/modules/desktop_capture/desktop_geometry.cc
+++ b/webrtc/modules/desktop_capture/desktop_geometry.cc
@@ -54,5 +54,19 @@ void DesktopRect::Extend(int32_t left_offset,
bottom_ += bottom_offset;
}
+void DesktopRect::UnionWith(const DesktopRect& rect) {
+ if (is_empty()) {
+ left_ = rect.left();
+ top_ = rect.top();
+ right_ = rect.right();
+ bottom_ = rect.bottom();
+ } else {
+ left_ = std::min(left(), rect.left());
+ top_ = std::min(top(), rect.top());
+ right_ = std::max(right(), rect.right());
+ bottom_ = std::max(bottom(), rect.bottom());
+ }
+}
+
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698