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

Unified Diff: ui/gfx/compositor/compositor_gl.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
« no previous file with comments | « ui/gfx/compositor/compositor_gl.h ('k') | ui/gfx/compositor/layer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/compositor/compositor_gl.cc
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc
index e71a0e06a116e610dee3082fb96c3c93a0efa824..14d5c56bcb3ee7eb30143e13812d8741bbf24268 100644
--- a/ui/gfx/compositor/compositor_gl.cc
+++ b/ui/gfx/compositor/compositor_gl.cc
@@ -558,12 +558,15 @@ CompositorGL::~CompositorGL() {
gl_context_ = NULL;
}
-bool CompositorGL::ReadPixels(SkBitmap* bitmap) {
+bool CompositorGL::ReadPixels(SkBitmap* bitmap, const gfx::Rect& bounds) {
MakeCurrent();
+ if (bounds.right() > size().width() || bounds.bottom() > size().height())
+ return false;
+
bitmap->setConfig(SkBitmap::kARGB_8888_Config,
- size().width(),
- size().height());
+ bounds.width(),
+ bounds.height());
bitmap->allocPixels();
SkAutoLockPixels lock(*bitmap);
unsigned char* pixels = static_cast<unsigned char*>(bitmap->getPixels());
@@ -575,16 +578,16 @@ bool CompositorGL::ReadPixels(SkBitmap* bitmap) {
GLint current_alignment = 0;
glGetIntegerv(GL_PACK_ALIGNMENT, &current_alignment);
glPixelStorei(GL_PACK_ALIGNMENT, 4);
- glReadPixels(0,
- 0,
- size().width(),
- size().height(),
+ glReadPixels(bounds.x(),
+ size().height() - bounds.y() - bounds.height(),
Ian Vollick 2011/11/18 18:13:45 I think it would be helpful to have a comment like
+ bounds.width(),
+ bounds.height(),
GL_RGBA,
GL_UNSIGNED_BYTE,
pixels);
glPixelStorei(GL_PACK_ALIGNMENT, current_alignment);
- SwizzleRGBAToBGRAAndFlip(pixels, size());
+ SwizzleRGBAToBGRAAndFlip(pixels, bounds.size());
return true;
}
« no previous file with comments | « ui/gfx/compositor/compositor_gl.h ('k') | ui/gfx/compositor/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698