Chromium Code Reviews| 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 |