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

Unified Diff: ui/gfx/compositor/compositor_cc.cc

Issue 8561016: Adds a bounds parameter to ui::Compositor::ReadPixels (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nicer revision Created 9 years, 1 month 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: ui/gfx/compositor/compositor_cc.cc
diff --git a/ui/gfx/compositor/compositor_cc.cc b/ui/gfx/compositor/compositor_cc.cc
index ce757130e50bb064a4c1e8fff71912b5c94d9442..ebbf271835d2f30cba2f8c7be079389ac443dcef 100644
--- a/ui/gfx/compositor/compositor_cc.cc
+++ b/ui/gfx/compositor/compositor_cc.cc
@@ -182,14 +182,21 @@ void CompositorCC::DrawTree() {
host_.composite();
}
-bool CompositorCC::ReadPixels(SkBitmap* bitmap) {
+bool CompositorCC::ReadPixels(SkBitmap* bitmap, const gfx::Rect& bounds) {
+ if (bounds.right() > size().width() || bounds.bottom() > size().height())
+ return false;
+ // Convert to Skia coordinates.
+ gfx::Point new_origin(bounds.x(),
+ size().height() - bounds.height() - bounds.y());
+
bitmap->setConfig(SkBitmap::kARGB_8888_Config,
- size().width(), size().height());
+ bounds.width(), bounds.height());
bitmap->allocPixels();
SkAutoLockPixels lock_image(*bitmap);
unsigned char* pixels = static_cast<unsigned char*>(bitmap->getPixels());
- if (host_.compositeAndReadback(pixels, gfx::Rect(size()))) {
- SwizzleRGBAToBGRAAndFlip(pixels, size());
+ if (host_.compositeAndReadback(pixels,
+ gfx::Rect(new_origin, bounds.size()))) {
+ SwizzleRGBAToBGRAAndFlip(pixels, bounds.size());
return true;
}
return false;

Powered by Google App Engine
This is Rietveld 408576698