Index: cc/resources/picture_pile_impl.cc |
diff --git a/cc/resources/picture_pile_impl.cc b/cc/resources/picture_pile_impl.cc |
index cde5cb5a55724a7250de01a4fe3f89b2d8b85665..b6f4d77156f57c8d94ffdd377c948e97674cf37a 100644 |
--- a/cc/resources/picture_pile_impl.cc |
+++ b/cc/resources/picture_pile_impl.cc |
@@ -74,9 +74,20 @@ |
float contents_scale, |
RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
RasterCommon(canvas, |
+ NULL, |
canvas_rect, |
contents_scale, |
- rendering_stats_instrumentation); |
+ rendering_stats_instrumentation, |
+ false); |
+} |
+ |
+void PicturePileImpl::RasterForAnalysis( |
+ skia::AnalysisCanvas* canvas, |
+ gfx::Rect canvas_rect, |
+ float contents_scale, |
+ RenderingStatsInstrumentation* stats_instrumentation) { |
+ RasterCommon( |
+ canvas, canvas, canvas_rect, contents_scale, stats_instrumentation, true); |
} |
void PicturePileImpl::RasterToBitmap( |
@@ -127,9 +138,11 @@ |
} |
RasterCommon(canvas, |
+ NULL, |
canvas_rect, |
contents_scale, |
- rendering_stats_instrumentation); |
+ rendering_stats_instrumentation, |
+ false); |
} |
void PicturePileImpl::CoalesceRasters(gfx::Rect canvas_rect, |
@@ -193,9 +206,11 @@ |
void PicturePileImpl::RasterCommon( |
SkCanvas* canvas, |
+ SkDrawPictureCallback* callback, |
gfx::Rect canvas_rect, |
float contents_scale, |
- RenderingStatsInstrumentation* rendering_stats_instrumentation) { |
+ RenderingStatsInstrumentation* rendering_stats_instrumentation, |
+ bool is_analysis) { |
DCHECK(contents_scale >= min_contents_scale_); |
canvas->translate(-canvas_rect.x(), -canvas_rect.y()); |
@@ -241,7 +256,7 @@ |
start_time = rendering_stats_instrumentation->StartRecording(); |
rasterized_pixel_count = picture->Raster( |
- canvas, negated_clip_region, contents_scale); |
+ canvas, callback, negated_clip_region, contents_scale); |
if (rendering_stats_instrumentation) { |
base::TimeDelta duration = |
@@ -251,8 +266,13 @@ |
} |
if (rendering_stats_instrumentation) { |
- rendering_stats_instrumentation->AddRaster(best_duration, |
- rasterized_pixel_count); |
+ if (is_analysis) { |
+ rendering_stats_instrumentation->AddAnalysis(best_duration, |
+ rasterized_pixel_count); |
+ } else { |
+ rendering_stats_instrumentation->AddRaster(best_duration, |
+ rasterized_pixel_count); |
+ } |
} |
} |
@@ -288,6 +308,39 @@ |
return picture; |
} |
+void PicturePileImpl::AnalyzeInRect( |
+ gfx::Rect content_rect, |
+ float contents_scale, |
+ PicturePileImpl::Analysis* analysis) { |
+ AnalyzeInRect(content_rect, contents_scale, analysis, NULL); |
+} |
+ |
+void PicturePileImpl::AnalyzeInRect( |
+ gfx::Rect content_rect, |
+ float contents_scale, |
+ PicturePileImpl::Analysis* analysis, |
+ RenderingStatsInstrumentation* stats_instrumentation) { |
+ DCHECK(analysis); |
+ TRACE_EVENT0("cc", "PicturePileImpl::AnalyzeInRect"); |
+ |
+ gfx::Rect layer_rect = gfx::ScaleToEnclosingRect( |
+ content_rect, 1.0f / contents_scale); |
+ |
+ layer_rect.Intersect(gfx::Rect(tiling_.total_size())); |
+ |
+ SkBitmap empty_bitmap; |
+ empty_bitmap.setConfig(SkBitmap::kNo_Config, |
+ layer_rect.width(), |
+ layer_rect.height()); |
+ skia::AnalysisDevice device(empty_bitmap); |
+ skia::AnalysisCanvas canvas(&device); |
+ |
+ RasterForAnalysis(&canvas, layer_rect, 1.0f, stats_instrumentation); |
+ |
+ analysis->is_solid_color = canvas.GetColorIfSolid(&analysis->solid_color); |
+ analysis->has_text = canvas.HasText(); |
+} |
+ |
PicturePileImpl::Analysis::Analysis() |
: is_solid_color(false), |
has_text(false) { |
@@ -342,19 +395,6 @@ |
if (pixel_ref_iterator_) |
break; |
} |
-} |
- |
-gfx::Rect PicturePileImpl::AnalysisRectForRaster(gfx::Rect content_rect, |
- float contents_scale) const { |
- // Bound the analysis rect to just the pile content. |
- gfx::Rect content_bounds( |
- gfx::ScaleToEnclosingRect(gfx::Rect(size()), contents_scale)); |
- gfx::Rect analysis_rect(content_rect); |
- analysis_rect.Intersect(content_bounds); |
- // Move to canvas space. |
- analysis_rect.set_origin(gfx::Point()); |
- |
- return analysis_rect; |
} |
void PicturePileImpl::DidBeginTracing() { |