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

Unified Diff: remoting/host/capturer_mac.cc

Issue 6610007: Fix up mac capturer to flip image. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/remoting/client/appengine/static_files
Patch Set: Created 9 years, 10 months 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 | « remoting/host/capturer_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/capturer_mac.cc
diff --git a/remoting/host/capturer_mac.cc b/remoting/host/capturer_mac.cc
index e5b4c8a829bb4349747c718c40658d3dc2de0434..9b06ac6707aa68c777183c84c4047decffb95c6b 100644
--- a/remoting/host/capturer_mac.cc
+++ b/remoting/host/capturer_mac.cc
@@ -55,6 +55,7 @@ void CapturerMac::ScreenConfigurationChanged() {
for (int i = 0; i < kNumBuffers; ++i) {
buffers_[i].reset(new uint8[buffer_size]);
}
+ flip_buffer_.reset(new uint8[buffer_size]);
CGLPixelFormatAttribute attributes[] = {
kCGLPFAFullScreen,
kCGLPFADisplayMask,
@@ -92,18 +93,33 @@ void CapturerMac::CaptureRects(const InvalidRects& rects,
glPixelStorei(GL_PACK_SKIP_PIXELS, 0);
// Read a block of pixels from the frame buffer.
- glReadPixels(0, 0, width(), height(), GL_BGRA, GL_UNSIGNED_BYTE,
- buffers_[current_buffer_].get());
+ int h = height();
+ int w = width();
+ uint8* flip_buffer = flip_buffer_.get();
+ uint8* current_buffer = buffers_[current_buffer_].get();
+
+ glReadPixels(0, 0, w, h, GL_BGRA, GL_UNSIGNED_BYTE, flip_buffer);
glPopClientAttrib();
+ // OpenGL reads with a vertical flip, and sadly there is no optimized
+ // way to get it flipped automatically.
+ DCHECK_EQ(bytes_per_row_ % sizeof(uint32_t), 0U);
+ for (int y = 0; y < h; ++y) {
+ uint32_t* flip_row = reinterpret_cast<uint32_t*>(
+ &(flip_buffer[y * bytes_per_row_]));
+ uint32_t* current_row = reinterpret_cast<uint32_t*>(
+ &(current_buffer[(h - (y + 1)) * bytes_per_row_]));
+ for (int x = 0; x < w; ++x) {
Alpha Left Google 2011/03/03 01:43:33 Do a memcpy instead of doing yourself, memcpy is p
+ current_row[x] = flip_row[x];
+ }
+ }
+
DataPlanes planes;
planes.data[0] = buffers_[current_buffer_].get();
planes.strides[0] = bytes_per_row_;
- scoped_refptr<CaptureData> data(new CaptureData(planes,
- width(),
- height(),
- pixel_format()));
+ scoped_refptr<CaptureData> data(
+ new CaptureData(planes, w, h, pixel_format()));
data->mutable_dirty_rects() = rects;
FinishCapture(data, callback);
}
« no previous file with comments | « remoting/host/capturer_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698