Index: ui/compositor/layer.cc |
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc |
index 3e61d40b95a2c02151bf44dd5418c2d74cc655c8..914e000feedff6be8b423b1b2aa44a573e3a6bc2 100644 |
--- a/ui/compositor/layer.cc |
+++ b/ui/compositor/layer.cc |
@@ -657,11 +657,7 @@ bool Layer::SchedulePaint(const gfx::Rect& invalid_rect) { |
type_ == LAYER_NINE_PATCH || (!delegate_ && !mailbox_.IsValid())) |
return false; |
- damaged_region_.op(invalid_rect.x(), |
- invalid_rect.y(), |
- invalid_rect.right(), |
- invalid_rect.bottom(), |
- SkRegion::kUnion_Op); |
+ damaged_region_.Union(invalid_rect); |
ScheduleDraw(); |
return true; |
} |
@@ -673,20 +669,17 @@ void Layer::ScheduleDraw() { |
} |
void Layer::SendDamagedRects() { |
- if ((delegate_ || mailbox_.IsValid()) && !damaged_region_.isEmpty()) { |
- for (SkRegion::Iterator iter(damaged_region_); !iter.done(); iter.next()) { |
- const SkIRect& sk_damaged = iter.rect(); |
- gfx::Rect damaged( |
- sk_damaged.x(), |
- sk_damaged.y(), |
- sk_damaged.width(), |
- sk_damaged.height()); |
- cc_layer_->SetNeedsDisplayRect(damaged); |
- } |
- damaged_region_.setEmpty(); |
- } |
- for (size_t i = 0; i < children_.size(); ++i) |
- children_[i]->SendDamagedRects(); |
+ if (damaged_region_.IsEmpty()) |
+ return; |
+ if (!delegate_ && !mailbox_.IsValid()) |
+ return; |
+ |
+ for (cc::Region::Iterator iter(damaged_region_); iter.has_rect(); iter.next()) |
+ cc_layer_->SetNeedsDisplayRect(iter.rect()); |
+} |
+ |
+void Layer::ClearDamagedRects() { |
+ damaged_region_.Clear(); |
} |
void Layer::CompleteAllAnimations() { |
@@ -745,6 +738,7 @@ void Layer::PaintContents( |
const gfx::Rect& clip, |
ContentLayerClient::PaintingControlSetting painting_control) { |
TRACE_EVENT1("ui", "Layer::PaintContents", "name", name_); |
+ ClearDamagedRects(); |
scoped_ptr<gfx::Canvas> canvas(gfx::Canvas::CreateCanvasWithoutScaling( |
sk_canvas, device_scale_factor_)); |
if (delegate_) |
@@ -756,15 +750,16 @@ void Layer::PaintContentsToDisplayList( |
const gfx::Rect& clip, |
ContentLayerClient::PaintingControlSetting painting_control) { |
TRACE_EVENT1("ui", "Layer::PaintContentsToDisplayList", "name", name_); |
- if (delegate_) { |
- // TODO(danakj): Save the invalidation on the layer and pass that down |
- // instead of the |clip| here. That will break everything until View |
- // early-outs emit cached display items instead of nothing. |
- gfx::Rect invalidation = clip; |
- DCHECK(clip.Contains(invalidation)); |
- delegate_->OnPaintLayer( |
- PaintContext(display_list, device_scale_factor_, clip, invalidation)); |
- } |
+ ClearDamagedRects(); |
+ if (!delegate_) |
+ return; |
+ // TODO(danakj): Save the invalidation on the layer and pass that down |
+ // instead of the |clip| here. That will break everything until View |
+ // early-outs emit cached display items instead of nothing. |
+ gfx::Rect invalidation = clip; |
+ DCHECK(clip.Contains(invalidation)); |
+ delegate_->OnPaintLayer( |
+ PaintContext(display_list, device_scale_factor_, clip, invalidation)); |
} |
bool Layer::FillsBoundsCompletely() const { return fills_bounds_completely_; } |