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

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

Issue 8463024: Implement CompositorCC::ReadPixels (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compositor::ReadPixels now returns bool 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
diff --git a/ui/gfx/compositor/compositor.cc b/ui/gfx/compositor/compositor.cc
index 388d7d9196ba5b9df39f125fb85bcb6329757adf..6e9e1d5e216b3d92af98142906cbcfe7fe3af7a6 100644
--- a/ui/gfx/compositor/compositor.cc
+++ b/ui/gfx/compositor/compositor.cc
@@ -68,6 +68,29 @@ void Compositor::DrawTree() {
root_layer_->DrawTree();
}
+void Compositor::SwizzleRGBAToBGRAAndFlip(unsigned char* pixels,
+ const gfx::Size& image_size) {
+ // Swizzle from RGBA to BGRA
+ size_t bitmap_size = 4 * image_size.width() * image_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 * image_size.width();
+ scoped_array<unsigned char> tmp_row(new unsigned char[row_size]);
+ for(int row = 0; row < image_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);
+ }
+}
+
void Compositor::NotifyStart(bool clear) {
OnNotifyStart(clear);
}

Powered by Google App Engine
This is Rietveld 408576698