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

Unified Diff: cc/picture.cc

Issue 12316084: cc: Consolidate the analysis_canvas operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reveman's review 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
Index: cc/picture.cc
diff --git a/cc/picture.cc b/cc/picture.cc
index c8fd76ffde70a01830f300dda033c40b37ee4ec9..501621b0668249d3745dc7378e91d98a984a8930 100644
--- a/cc/picture.cc
+++ b/cc/picture.cc
@@ -114,17 +114,23 @@ void Picture::Raster(
canvas->restore();
}
-bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) const {
- TRACE_EVENT0("cc", "Picture::IsCheapInRect");
+void Picture::AnalyzeInRect(skia::AnalysisCanvas* canvas,
+ const gfx::Rect& content_rect,
+ float contents_scale,
+ Analysis* analysis) {
+ // Verify the output is valid.
+ DCHECK(analysis);
- SkBitmap emptyBitmap;
- emptyBitmap.setConfig(SkBitmap::kNo_Config, layer_rect.width(),
- layer_rect.height());
- skia::AnalysisDevice device(emptyBitmap);
- skia::AnalysisCanvas canvas(&device);
+ canvas->save();
+ canvas->clipRect(gfx::RectToSkRect(content_rect));
+ canvas->scale(contents_scale, contents_scale);
+ canvas->translate(layer_rect_.x(), layer_rect_.y());
+ canvas->drawPicture(*picture_);
+ canvas->restore();
- canvas.drawPicture(*picture_);
- return canvas.isCheap();
+ analysis->is_solid_color = canvas->getColorIfSolid(&analysis->solid_color);
+ analysis->is_transparent = canvas->isTransparent();
+ analysis->is_cheap_to_raster = canvas->isCheap();
}
void Picture::GatherPixelRefs(const gfx::Rect& layer_rect,
@@ -155,4 +161,10 @@ void Picture::GatherPixelRefs(const gfx::Rect& layer_rect,
pixel_refs->unref();
}
+Picture::Analysis::Analysis() :
+ is_solid_color(false),
+ is_transparent(false),
+ is_cheap_to_raster(false) {
+}
+
} // namespace cc
« no previous file with comments | « cc/picture.h ('k') | cc/picture_layer_impl.cc » ('j') | cc/picture_pile_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698