ShellRecorder: Fix interaction of glReadPixels with Cogl

The screen recording wasn't working because of two bad interactions
with Cogl:

 - Buffered primitives weren't being flushed out
 - Cogl changes the pixel store values away from their default values

Thanks for Jon Nettleton for tracking down the source of the
problems with the recorder.

https://bugzilla.gnome.org/show_bug.cgi?id=598390
This commit is contained in:
Owen W. Taylor 2010-01-27 08:24:36 -05:00
parent 2494cc1637
commit 8db212db99

View File

@ -504,6 +504,24 @@ recorder_record_frame (ShellRecorder *recorder)
GST_BUFFER_TIMESTAMP(buffer) = get_wall_time() - recorder->start_time;
/* We could use cogl_read_pixels, but it only currently supports
* COGL_PIXEL_FORMAT_RGBA_8888, while we prefer the native framebuffer
* format. (COGL_PIXEL_FORMAT_ARGB_8888_PRE,
* COGL_PIXEL_FORMAT_BGRA_PRE, depending on endianess)
*
* http://bugzilla.openedhand.com/show_bug.cgi?id=1959
*/
/* Flush any primitives that Cogl has batched up */
cogl_flush ();
/* Set the parameters for how data is stored; these are the initial
* values but Cogl will have modified them for its own purposes */
glPixelStorei (GL_PACK_ALIGNMENT, 4);
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
glPixelStorei (GL_PACK_SKIP_PIXELS, 0);
glPixelStorei (GL_PACK_SKIP_ROWS, 0);
glReadBuffer (GL_BACK_LEFT);
glReadPixels (0, 0,
recorder->stage_width, recorder->stage_height,
@ -1038,6 +1056,10 @@ recorder_pipeline_add_source (RecorderPipeline *pipeline)
* that we might have a smaller buffer to flip; on the other hand flipping
* YUV 422 is more complicated than flipping RGB. Probably a toss-up.
*
* When available MESA_pack_invert extension could be used to avoid the
* flip entirely, since the data is actually stored in the frame buffer
* in the order that we expect.
*
* We use gst_parse_launch to avoid having to know the enum value for flip-vertical
*/
videoflip = gst_parse_launch_full ("videoflip method=vertical-flip", NULL,