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

Unified Diff: cc/base/simple_enclosed_region.cc

Issue 2866063002: Improve overdraw with multiple windows (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: cc/base/simple_enclosed_region.cc
diff --git a/cc/base/simple_enclosed_region.cc b/cc/base/simple_enclosed_region.cc
index 50e905bb68c97eebbd74c14345928687780ea560..1882af5c4eeda9e77ff58c8890907551fe4a4399 100644
--- a/cc/base/simple_enclosed_region.cc
+++ b/cc/base/simple_enclosed_region.cc
@@ -9,6 +9,7 @@
#include "base/logging.h"
#include "cc/base/region.h"
+#include "ui/gfx/geometry/rect.h"
namespace cc {
@@ -127,7 +128,15 @@ void SimpleEnclosedRegion::Union(const gfx::Rect& new_rect) {
gfx::Rect adjusted_new_rect(
new_left, new_top, new_right - new_left, new_bottom - new_top);
- if (RectIsLargerArea(adjusted_new_rect, rect_))
+ gfx::Rect overlap = gfx::IntersectRects(rect_, adjusted_new_rect);
+
+ int64_t weighted_rect_area =
danakj 2017/05/15 21:47:42 I suggest to build 3 rects, old_rect_area, overlap
yiyix 2017/05/17 03:00:31 I agree. If the area calculation is done separatel
+ static_cast<int64_t>(rect_.width() * rect_.height()) +
danakj 2017/05/15 21:47:42 cast just the width, that will promote before the
yiyix 2017/05/17 03:00:31 Done.
+ static_cast<int64_t>(overlap.width() * overlap.height());
danakj 2017/05/15 21:47:42 same
yiyix 2017/05/17 03:00:31 Done.
+ int64_t weighted_adjusted_new_rect_area =
+ 2 * static_cast<int64_t>(adjusted_new_rect.width() *
danakj 2017/05/15 21:47:42 same
yiyix 2017/05/17 03:00:31 Done.
+ adjusted_new_rect.height());
+ if (weighted_adjusted_new_rect_area > weighted_rect_area)
danakj 2017/05/15 21:47:42 Can you put a comment here explaining roughly what
yiyix 2017/05/17 03:00:31 I will add this to both. Your wording is better! T
rect_ = adjusted_new_rect;
}
« no previous file with comments | « no previous file | cc/base/simple_enclosed_region_unittest.cc » ('j') | cc/base/simple_enclosed_region_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698