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

Unified Diff: cc/base/invalidation_region.cc

Issue 2054473002: Speed up InvalidationRegion (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Limit pending_rects_ to kMaxInvalidationRectCount Created 4 years, 6 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 | « cc/base/invalidation_region.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/invalidation_region.cc
diff --git a/cc/base/invalidation_region.cc b/cc/base/invalidation_region.cc
index 5fbca8d1d180d71c027505595b65a0c46cfa9ff7..09591562c9debe7923a3e86cb86a039be9c15f64 100644
--- a/cc/base/invalidation_region.cc
+++ b/cc/base/invalidation_region.cc
@@ -19,21 +19,38 @@ InvalidationRegion::InvalidationRegion() {}
InvalidationRegion::~InvalidationRegion() {}
void InvalidationRegion::Swap(Region* region) {
+ FinalizePendingRects();
region_.Swap(region);
}
void InvalidationRegion::Clear() {
+ pending_rects_.clear();
region_.Clear();
}
void InvalidationRegion::Union(const gfx::Rect& rect) {
- region_.Union(rect);
- SimplifyIfNeeded();
+ if (pending_rects_.size() >= kMaxInvalidationRectCount)
vmiura 2016/06/10 05:35:48 I just realized after this change, we never get (p
+ pending_rects_[0].Union(rect);
+ else
+ pending_rects_.push_back(rect);
}
-void InvalidationRegion::SimplifyIfNeeded() {
- if (region_.GetRegionComplexity() > kMaxInvalidationRectCount)
- region_ = region_.bounds();
+void InvalidationRegion::FinalizePendingRects() {
+ if (pending_rects_.empty())
+ return;
+
+ if (region_.GetRegionComplexity() + pending_rects_.size() >
+ kMaxInvalidationRectCount) {
+ gfx::Rect pending_bounds = region_.bounds();
+ for (auto& rect : pending_rects_)
+ pending_bounds.Union(rect);
+ region_ = pending_bounds;
+ } else {
+ for (auto& rect : pending_rects_)
+ region_.Union(rect);
+ }
+
+ pending_rects_.clear();
}
} // namespace cc
« no previous file with comments | « cc/base/invalidation_region.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698