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

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

Issue 8463024: Implement CompositorCC::ReadPixels (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor host API change. 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/compositor_win.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 078556bd5126ce03016f3a4df0d15d69d753803c..54e43e4e15000fc9f536190002213f0ac83aab91 100644
--- a/ui/gfx/compositor/compositor_gl.cc
+++ b/ui/gfx/compositor/compositor_gl.cc
@@ -561,7 +561,7 @@ CompositorGL::~CompositorGL() {
gl_context_ = NULL;
}
-void CompositorGL::ReadPixels(SkBitmap* bitmap) {
+bool CompositorGL::ReadPixels(SkBitmap* bitmap) {
MakeCurrent();
bitmap->setConfig(SkBitmap::kARGB_8888_Config,
@@ -587,25 +587,8 @@ void CompositorGL::ReadPixels(SkBitmap* bitmap) {
pixels);
glPixelStorei(GL_PACK_ALIGNMENT, current_alignment);
- // Swizzle from RGBA to BGRA
- size_t bitmap_size = 4 * size().width() * size().height();
- for(size_t i = 0; i < bitmap_size; i += 4)
- std::swap(pixels[i], pixels[i + 2]);
-
- // Vertical flip to transform from GL co-ords
- size_t row_size = 4 * size().width();
- scoped_array<unsigned char> tmp_row(new unsigned char[row_size]);
- for(int row = 0; row < size().height() / 2; row++) {
- memcpy(tmp_row.get(),
- &pixels[row * row_size],
- row_size);
- memcpy(&pixels[row * row_size],
- &pixels[bitmap_size - (row + 1) * row_size],
- row_size);
- memcpy(&pixels[bitmap_size - (row + 1) * row_size],
- tmp_row.get(),
- row_size);
- }
+ SwizzleRGBAToBGRAAndFlip(pixels, size());
+ return true;
}
void CompositorGL::MakeCurrent() {
« no previous file with comments | « ui/gfx/compositor/compositor_gl.h ('k') | ui/gfx/compositor/compositor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698