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..af8402fa2bbbb7bd313e49d7a4c122fdb07a6262 100644 |
--- a/cc/resources/raster_source_helper.cc |
+++ b/cc/resources/raster_source_helper.cc |
@@ -14,16 +14,29 @@ namespace cc { |
void RasterSourceHelper::PrepareForPlaybackToCanvas( |
SkCanvas* canvas, |
- const gfx::Rect& canvas_rect, |
+ const gfx::Rect& canvas_bitmap_rect, |
+ const gfx::Rect& canvas_playback_rect, |
const gfx::Rect& source_rect, |
float contents_scale, |
SkColor background_color, |
bool clear_canvas_with_debug_color, |
bool requires_clear) { |
- canvas->discard(); |
+ bool partial_update = canvas_bitmap_rect != canvas_playback_rect; |
+ gfx::Rect canvas_rect = |
+ canvas_playback_rect - canvas_bitmap_rect.OffsetFromOrigin(); |
+ |
+ 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(canvas_rect)); |
+ canvas->drawColor(DebugColors::NonPaintedFillColor()); |
+ canvas->restore(); |
+ } |
} |
// If this raster source has opaque contents, it is guaranteeing that it will |
@@ -33,7 +46,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(canvas_rect)); |
+ 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 |