Index: cc/resources/raster_source_helper.cc |
diff --git a/cc/resources/raster_source_helper.cc b/cc/resources/raster_source_helper.cc |
index 34436e4a3f04c4d33cdc0afc28885581c4472a3b..ff6afddf68f497b607c78e639c6539c25d4afe5e 100644 |
--- a/cc/resources/raster_source_helper.cc |
+++ b/cc/resources/raster_source_helper.cc |
@@ -19,11 +19,20 @@ void RasterSourceHelper::PrepareForPlaybackToCanvas( |
float contents_scale, |
SkColor background_color, |
bool clear_canvas_with_debug_color, |
- bool requires_clear) { |
- canvas->discard(); |
+ bool requires_clear, |
+ bool partial_update) { |
+ if (!partial_update) |
+ canvas->discard(); |
if (clear_canvas_with_debug_color) { |
// Any non-painted areas in the content bounds will be left in this color. |
- canvas->clear(DebugColors::NonPaintedFillColor()); |
+ if (!partial_update) { |
+ canvas->clear(DebugColors::NonPaintedFillColor()); |
+ } else { |
+ canvas->save(); |
+ canvas->clipRect(gfx::RectToSkRect(gfx::Rect(canvas_rect.size()))); |
+ canvas->drawColor(DebugColors::NonPaintedFillColor()); |
+ canvas->restore(); |
+ } |
} |
// If this raster source has opaque contents, it is guaranteeing that it will |
@@ -33,7 +42,14 @@ void RasterSourceHelper::PrepareForPlaybackToCanvas( |
TRACE_EVENT_INSTANT0("cc", "SkCanvas::clear", TRACE_EVENT_SCOPE_THREAD); |
// Clearing is about ~4x faster than drawing a rect even if the content |
// isn't covering a majority of the canvas. |
- canvas->clear(SK_ColorTRANSPARENT); |
+ if (!partial_update) { |
+ canvas->clear(SK_ColorTRANSPARENT); |
+ } else { |
+ canvas->save(); |
+ canvas->clipRect(gfx::RectToSkRect(gfx::Rect(canvas_rect.size()))); |
+ canvas->drawColor(SK_ColorTRANSPARENT); |
+ canvas->restore(); |
+ } |
} else { |
// Even if completely covered, for rasterizations that touch the edge of the |
// layer, we also need to raster the background color underneath the last |