| Index: cc/picture.cc
|
| diff --git a/cc/picture.cc b/cc/picture.cc
|
| index c8fcd4504283733ba585bece04cb52d6e73a9c25..55dbd8afb890dbc707bc345d54f84e379e99a131 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"
|
| @@ -100,8 +101,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(),
|
| + 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();
|
| @@ -113,7 +127,18 @@ void Picture::Raster(
|
| }
|
|
|
| bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) {
|
| - return false;
|
| +TRACE_EVENT0("cc", "Picture::IsCheapInRect");
|
| + SkBitmap emptyBitmap;
|
| + emptyBitmap.setConfig(SkBitmap::kNo_Config, picture_->width(),
|
| + picture_->height());
|
| + skia::AnalysisDevice device(emptyBitmap);
|
| + skia::AnalysisCanvas canvas(&device, gfx::RectToSkRect(layer_rect));
|
| + // If a picture has low estimated cost, go ahead and
|
| + // wait until we have more pictures to draw (to amortize startup costs).
|
| + // If estimated cost is high, start it now so that compositing isn't
|
| + // blocked waiting for it.
|
| + canvas.drawPicture(*picture_);
|
| + return canvas.isCheap();
|
| }
|
|
|
| void Picture::GatherPixelRefs(const gfx::Rect& layer_rect,
|
|
|