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

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: Resolve review comments 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..37b31998272afdb01f66402b8a6dca3e74bd8544 100644
--- a/webrtc/modules/desktop_capture/desktop_geometry.cc
+++ b/webrtc/modules/desktop_capture/desktop_geometry.cc
@@ -37,6 +37,20 @@ void DesktopRect::IntersectWith(const DesktopRect& rect) {
}
}
+void DesktopRect::UnionWith(const DesktopRect& rect) {
+ if (is_empty()) {
+ left_ = rect.left();
Sergey Ulanov 2017/05/16 19:53:00 *this = rect;
Hzj_jie 2017/05/16 23:04:18 Done.
+ top_ = rect.top();
+ right_ = rect.right();
+ bottom_ = rect.bottom();
+ } 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.
+ left_ = std::min(left(), rect.left());
+ top_ = std::min(top(), rect.top());
+ right_ = std::max(right(), rect.right());
+ bottom_ = std::max(bottom(), rect.bottom());
+ }
+}
+
void DesktopRect::Translate(int32_t dx, int32_t dy) {
left_ += dx;
top_ += dy;

Powered by Google App Engine
This is Rietveld 408576698