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..00a7b904e02c5f2ab7567c5ada76b70b5a697c1e 100644 |
| --- a/cc/base/invalidation_region.cc |
| +++ b/cc/base/invalidation_region.cc |
| @@ -19,21 +19,35 @@ 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(); |
| + pending_rects_.push_back(rect); |
|
enne (OOO)
2016/06/08 19:05:14
I'm prematurely optimizing here, but what about ea
vmiura
2016/06/08 19:54:27
Done.
|
| } |
| -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 |