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

Unified Diff: cc/picture.cc

Issue 12184010: skia::AnalysisCanvas: implementation for IsCheapInRect(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Wrote device boilerplate 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') | skia/ext/analysis_canvas.h » ('J')
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 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;
}
« no previous file with comments | « no previous file | skia/ext/analysis_canvas.h » ('j') | skia/ext/analysis_canvas.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698