Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1450)

Unified Diff: cc/picture.cc

Issue 12184010: skia::AnalysisCanvas: implementation for IsCheapInRect(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to reviewer comments Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | skia/ext/analysis_canvas.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « no previous file | skia/ext/analysis_canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698