Index: cc/resources/picture_pile_impl.cc |
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc |
index 052e075173810dc92b569739f225ed0bca6aa09c..ffa074094aa44b042e9cbf5f0d29043026fda546 100644 |
--- a/cc/resources/picture_pile_impl.cc |
+++ b/cc/resources/picture_pile_impl.cc |
@@ -74,15 +74,13 @@ PicturePileImpl* PicturePileImpl::GetCloneForDrawingOnThread( |
return clones_for_drawing_.clones_[thread_index]; |
} |
-void PicturePileImpl::Raster( |
+void PicturePileImpl::RasterDirect( |
SkCanvas* canvas, |
gfx::Rect canvas_rect, |
float contents_scale, |
RasterStats* raster_stats) { |
- |
DCHECK(contents_scale >= min_contents_scale_); |
- canvas->save(); |
canvas->translate(-canvas_rect.x(), -canvas_rect.y()); |
gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), |
@@ -91,32 +89,12 @@ void PicturePileImpl::Raster( |
gfx::Rect content_rect = total_content_rect; |
content_rect.Intersect(canvas_rect); |
- // Clear one texel inside the right/bottom edge of the content rect, |
- // as it may only be partially covered by the picture playback. |
- // Also clear one texel outside the right/bottom edge of the content rect, |
- // as it may get blended in by linear filtering when zoomed in. |
- gfx::Rect deflated_content_rect = total_content_rect; |
- deflated_content_rect.Inset(0, 0, 1, 1); |
- |
- gfx::Rect canvas_outside_content_rect = canvas_rect; |
- canvas_outside_content_rect.Subtract(deflated_content_rect); |
- |
- if (!canvas_outside_content_rect.IsEmpty()) { |
- gfx::Rect inflated_content_rect = total_content_rect; |
- inflated_content_rect.Inset(0, 0, -1, -1); |
- canvas->clipRect(gfx::RectToSkRect(inflated_content_rect), |
- SkRegion::kReplace_Op); |
- canvas->clipRect(gfx::RectToSkRect(deflated_content_rect), |
- SkRegion::kDifference_Op); |
- canvas->drawColor(background_color_, SkXfermode::kSrc_Mode); |
- } |
- |
// Rasterize the collection of relevant picture piles. |
gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
content_rect, 1.f / contents_scale); |
canvas->clipRect(gfx::RectToSkRect(content_rect), |
- SkRegion::kReplace_Op); |
+ SkRegion::kIntersect_Op); |
Region unclipped(content_rect); |
if (raster_stats) { |
@@ -217,8 +195,57 @@ void PicturePileImpl::Raster( |
// We should always paint some part of |content_rect|. |
DCHECK(!unclipped.Contains(content_rect)); |
+} |
+ |
+void PicturePileImpl::RasterToBitmap( |
+ SkCanvas* canvas, |
+ gfx::Rect canvas_rect, |
+ float contents_scale, |
+ RasterStats* raster_stats) { |
+ |
+ canvas->save(); |
+ canvas->translate(-canvas_rect.x(), -canvas_rect.y()); |
+ |
+ gfx::SizeF total_content_size = gfx::ScaleSize(tiling_.total_size(), |
+ contents_scale); |
+ gfx::Rect total_content_rect(gfx::ToCeiledSize(total_content_size)); |
+ gfx::Rect content_rect = total_content_rect; |
+ content_rect.Intersect(canvas_rect); |
+ |
+#ifndef NDEBUG |
+ // Any non-painted areas will be left in this color. |
+ canvas->clear(DebugColors::NonPaintedFillColor()); |
+#endif // NDEBUG |
+ |
+ // TODO(enne): this needs to be rolled together with the border clear |
+ SkPaint paint; |
+ paint.setAntiAlias(false); |
+ paint.setXfermodeMode(SkXfermode::kClear_Mode); |
+ canvas->drawRect(gfx::RectToSkRect(content_rect), paint); |
+ |
+ // Clear one texel inside the right/bottom edge of the content rect, |
+ // as it may only be partially covered by the picture playback. |
+ // Also clear one texel outside the right/bottom edge of the content rect, |
+ // as it may get blended in by linear filtering when zoomed in. |
+ gfx::Rect deflated_content_rect = total_content_rect; |
+ deflated_content_rect.Inset(0, 0, 1, 1); |
+ |
+ gfx::Rect canvas_outside_content_rect = canvas_rect; |
+ canvas_outside_content_rect.Subtract(deflated_content_rect); |
+ |
+ if (!canvas_outside_content_rect.IsEmpty()) { |
+ gfx::Rect inflated_content_rect = total_content_rect; |
+ inflated_content_rect.Inset(0, 0, -1, -1); |
+ canvas->clipRect(gfx::RectToSkRect(inflated_content_rect), |
+ SkRegion::kReplace_Op); |
+ canvas->clipRect(gfx::RectToSkRect(deflated_content_rect), |
+ SkRegion::kDifference_Op); |
+ canvas->drawColor(background_color_, SkXfermode::kSrc_Mode); |
+ } |
canvas->restore(); |
+ |
+ RasterDirect(canvas, canvas_rect, contents_scale, raster_stats); |
} |
skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { |
@@ -234,7 +261,7 @@ skia::RefPtr<SkPicture> PicturePileImpl::GetFlattenedPicture() { |
layer_rect.height(), |
SkPicture::kUsePathBoundsForClip_RecordingFlag); |
- Raster(canvas, layer_rect, 1.0, NULL); |
+ RasterToBitmap(canvas, layer_rect, 1.0, NULL); |
picture->endRecording(); |
return picture; |
@@ -258,7 +285,7 @@ void PicturePileImpl::AnalyzeInRect(gfx::Rect content_rect, |
skia::AnalysisDevice device(empty_bitmap); |
skia::AnalysisCanvas canvas(&device); |
- Raster(&canvas, layer_rect, 1.0f, NULL); |
+ RasterDirect(&canvas, layer_rect, 1.0f, NULL); |
analysis->is_solid_color = canvas.getColorIfSolid(&analysis->solid_color); |
analysis->has_text = canvas.hasText(); |