450
448
recorder->stage_height,
451
449
recorder->stage_width * 4);
453
/* When not using GL_MESA_pack_invert the data we get from glReadPixels is "upside down",
454
* so transform our cairo drawing to match */
455
451
cr = cairo_create (surface);
456
if (!recorder->have_pack_invert)
458
cairo_translate(cr, 0, recorder->stage_height);
459
cairo_scale(cr, 1, -1);
462
452
cairo_set_source_surface (cr,
463
453
recorder->cursor_image,
464
454
recorder->pointer_x - recorder->cursor_hot_x,
535
525
GST_BUFFER_TIMESTAMP(buffer) = get_wall_time() - recorder->start_time;
537
/* We could use cogl_read_pixels, but it only currently supports
538
* COGL_PIXEL_FORMAT_RGBA_8888, while we prefer the native framebuffer
539
* format. (COGL_PIXEL_FORMAT_ARGB_8888_PRE,
540
* COGL_PIXEL_FORMAT_BGRA_PRE, depending on endianess)
542
* http://bugzilla.openedhand.com/show_bug.cgi?id=1959
545
/* Flush any primitives that Cogl has batched up */
548
/* Set the parameters for how data is stored; these are the initial
549
* values but Cogl will have modified them for its own purposes */
550
glPixelStorei (GL_PACK_ALIGNMENT, 4);
551
glPixelStorei (GL_PACK_ROW_LENGTH, 0);
552
glPixelStorei (GL_PACK_SKIP_PIXELS, 0);
553
glPixelStorei (GL_PACK_SKIP_ROWS, 0);
555
if (recorder->have_pack_invert)
556
glPixelStorei (GL_PACK_INVERT_MESA, TRUE);
558
glReadBuffer (GL_BACK_LEFT);
560
recorder->stage_width, recorder->stage_height,
562
GL_UNSIGNED_INT_8_8_8_8_REV,
565
if (recorder->have_pack_invert)
566
glPixelStorei (GL_PACK_INVERT_MESA, FALSE);
527
cogl_read_pixels (0, 0,
528
recorder->stage_width, recorder->stage_height,
529
COGL_READ_PIXELS_COLOR_BUFFER,
530
COGL_PIXEL_FORMAT_BGRA_8888_PRE,
568
533
recorder_draw_cursor (recorder, buffer);
891
855
XFixesDisplayCursorNotifyMask);
893
857
clutter_stage_ensure_current (stage);
894
gl_extensions = (const char *)glGetString (GL_EXTENSIONS);
895
recorder->have_pack_invert = strstr (gl_extensions, "GL_MESA_pack_invert") != NULL;
897
859
recorder_get_initial_cursor_position (recorder);
1125
1085
gst_bin_add (GST_BIN (pipeline->pipeline), ffmpegcolorspace);
1127
/* glReadPixels gives us an upside-down buffer, so we have to flip it back
1130
* When available MESA_pack_invert extension is used to avoid the
1131
* flip entirely, since the data is actually stored in the frame buffer
1132
* in the order that we expect.
1134
* We use gst_parse_launch to avoid having to know the enum value for flip-vertical
1137
if (!pipeline->recorder->have_pack_invert)
1139
videoflip = gst_parse_launch_full ("videoflip method=vertical-flip", NULL,
1140
GST_PARSE_FLAG_FATAL_ERRORS,
1142
if (videoflip == NULL)
1144
g_warning("Can't create videoflip element: %s", error->message);
1145
g_error_free (error);
1149
gst_bin_add (GST_BIN (pipeline->pipeline), videoflip);
1150
gst_element_link_many (pipeline->src, ffmpegcolorspace, videoflip, NULL);
1152
src_pad = gst_element_get_static_pad (videoflip, "src");
1156
gst_element_link_many (pipeline->src, ffmpegcolorspace, NULL);
1157
src_pad = gst_element_get_static_pad (ffmpegcolorspace, "src");
1087
gst_element_link_many (pipeline->src, ffmpegcolorspace, NULL);
1088
src_pad = gst_element_get_static_pad (ffmpegcolorspace, "src");