Chromium Code Reviews| 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, ¤t_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; |
| } |