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); |
} |