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

Unified Diff: cc/base/simple_enclosed_region.cc

Issue 2866063002: Improve overdraw with multiple windows (Closed)
Patch Set: remove occlusion_track_unittests and rebase 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
« no previous file with comments | « no previous file | cc/base/simple_enclosed_region_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d3f3385cb9ce9ba7ddbd810d8c51a50f337f3a76 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 {
@@ -124,10 +125,22 @@ void SimpleEnclosedRegion::Union(const gfx::Rect& new_rect) {
}
rect_.SetRect(left, top, right - left, bottom - top);
-
+ int64_t rect_area = static_cast<int64_t>(rect_.width()) * rect_.height();
gfx::Rect adjusted_new_rect(
new_left, new_top, new_right - new_left, new_bottom - new_top);
- if (RectIsLargerArea(adjusted_new_rect, rect_))
+ int64_t adjust_new_rect_area =
+ static_cast<int64_t>(adjusted_new_rect.width()) *
+ adjusted_new_rect.height();
+ gfx::Rect overlap = gfx::IntersectRects(rect_, adjusted_new_rect);
+ int64_t overlap_area =
+ static_cast<int64_t>(overlap.width()) * overlap.height();
+
+ // Based on the assumption that as we compute occlusion, each step is
+ // more likely to be occluded by things added to this region more recently due
+ // to the way we build scenes with overlapping elements adjacent to each other
+ // in the Z order. So, the area of the new rect has a weight of 2 in the
+ // weighted area calculation.
+ if (adjust_new_rect_area * 2 > rect_area + overlap_area)
rect_ = adjusted_new_rect;
}
« no previous file with comments | « no previous file | cc/base/simple_enclosed_region_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698