| Index: chrome/renderer/paint_aggregator.cc
|
| ===================================================================
|
| --- chrome/renderer/paint_aggregator.cc (revision 68349)
|
| +++ chrome/renderer/paint_aggregator.cc (working copy)
|
| @@ -34,6 +34,10 @@
|
| // a paint rect can be significant.
|
| static const size_t kMaxPaintRects = 5;
|
|
|
| +// If the combined area of paint rects divided by the area of the union of all
|
| +// paint rects exceeds this threshold, then we will combine the paint rects.
|
| +static const float kMaxPaintRectsAreaRatio = 0.3f;
|
| +
|
| PaintAggregator::PendingUpdate::PendingUpdate() {}
|
|
|
| PaintAggregator::PendingUpdate::~PendingUpdate() {}
|
| @@ -89,6 +93,24 @@
|
| update_ = PendingUpdate();
|
| }
|
|
|
| +const PaintAggregator::PendingUpdate& PaintAggregator::GetPendingUpdate() {
|
| + // Combine paint rects if their combined area is not sufficiently less than
|
| + // the area of the union of all paint rects. We skip this if there is a
|
| + // scroll rect since scrolling benefits from smaller paint rects.
|
| + if (update_.scroll_rect.IsEmpty() && update_.paint_rects.size() > 1) {
|
| + int paint_area = 0;
|
| + gfx::Rect union_rect;
|
| + for (size_t i = 0; i < update_.paint_rects.size(); ++i) {
|
| + paint_area += update_.paint_rects[i].size().GetArea();
|
| + union_rect = union_rect.Union(update_.paint_rects[i]);
|
| + }
|
| + int union_area = union_rect.size().GetArea();
|
| + if (float(paint_area) / float(union_area) > kMaxPaintRectsAreaRatio)
|
| + CombinePaintRects();
|
| + }
|
| + return update_;
|
| +}
|
| +
|
| void PaintAggregator::InvalidateRect(const gfx::Rect& rect) {
|
| // Combine overlapping paints using smallest bounding box.
|
| for (size_t i = 0; i < update_.paint_rects.size(); ++i) {
|
|
|