Chromium Code Reviews| Index: cc/picture.cc |
| diff --git a/cc/picture.cc b/cc/picture.cc |
| index 1407f55dc4a1eb5ee470f302f155666abbec5b37..7ad3b4ff2a3497a1f6fe479dd3735cdde3b38d16 100644 |
| --- a/cc/picture.cc |
| +++ b/cc/picture.cc |
| @@ -6,6 +6,7 @@ |
| #include "cc/content_layer_client.h" |
| #include "cc/picture.h" |
| #include "cc/rendering_stats.h" |
| +#include "skia/ext/analysis_canvas.h" |
| #include "third_party/skia/include/core/SkCanvas.h" |
| #include "third_party/skia/include/core/SkData.h" |
| #include "third_party/skia/include/core/SkTileGridPicture.h" |
| @@ -96,8 +97,21 @@ void Picture::Raster( |
| SkCanvas* canvas, |
| gfx::Rect content_rect, |
| float contents_scale) { |
| - TRACE_EVENT2("cc", "Picture::Raster", |
| - "width", layer_rect_.width(), "height", layer_rect_.height()); |
| +char strbuf[256]; |
| +if (IsCheapInRect(content_rect)) { |
| +sprintf(strbuf, "CHEAP Picture::Raster"); |
| +} else { |
| +sprintf(strbuf, "EXPENSIVE Picture::Raster"); |
| +} |
| +SkBitmap emptyBitmap; |
| +emptyBitmap.setConfig(SkBitmap::kARGB_8888_Config, picture_->width(), |
|
Justin Novosad
2013/02/04 20:23:55
Config should be SkBitmap::kNo_Config
Tom Hudson
2013/02/05 10:23:24
Done.
I'd cribbed this from GatherPixelRefDevice,
|
| + picture_->height()); |
| +skia::AnalysisDevice device(emptyBitmap); |
| +skia::AnalysisCanvas aCanvas(&device, gfx::RectToSkRect(content_rect)); |
| +aCanvas.drawPicture(*picture_); |
| +TRACE_EVENT1("cc", strdup(strbuf), "cost", aCanvas.getEstimatedCost()); |
| + //TRACE_EVENT2("cc", strdup(strbuf), |
| + //"width", layer_rect_.width(), "height", layer_rect_.height()); |
| DCHECK(picture_); |
| canvas->save(); |
| @@ -109,6 +123,24 @@ void Picture::Raster( |
| } |
| bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) { |
| +TRACE_EVENT0("cc", "Picture::IsCheapInRect"); |
| + SkBitmap emptyBitmap; |
| + emptyBitmap.setConfig(SkBitmap::kARGB_8888_Config, picture_->width(), |
| + picture_->height()); |
| + skia::AnalysisDevice device(emptyBitmap); |
| + skia::AnalysisCanvas canvas(&device, gfx::RectToSkRect(layer_rect)); |
| + // If a picture has estimatd cost below this threshold, go ahead and |
| + // wait until we have more pictures to draw (to amortize startup costs). |
| + // If cost exceeds this threshold, start it now so we aren't blocked |
| + // waiting for it. |
| + // FIXME: Arbitrary number. Requires tuning & experimentation. |
| + // Probably requires per-platform tuning; N10 average draw call takes |
| + // 25x as long as Z620. |
| + int pictureCostThreshold = 100; |
| + canvas.drawPicture(*picture_); |
| + if (canvas.getEstimatedCost() <= pictureCostThreshold) { |
| + return true; |
| + } |
| return false; |
| } |