~ubuntu-branches/debian/jessie/gnome-shell/jessie

« back to all changes in this revision

Viewing changes to src/shell-recorder.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Michael Biebl, Rico Tzschichholz
  • Date: 2011-10-14 17:22:55 UTC
  • Revision ID: package-import@ubuntu.com-20111014172255-z2imjapg2uy8m4vd
Tags: 3.0.2-5
[ Michael Biebl ]
* debian/rules:
  - Make network-manager and gnome-bluetooth (build) dependencies linux-any.

[ Rico Tzschichholz ]
* Add 00git-ShellRecorder-Use-cogl_read_pixels.patch to fix FTBFS on arm

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
 
63
63
  gboolean only_paint; /* Used to temporarily suppress recording */
64
64
 
65
 
  gboolean have_pack_invert; /* True when GL_MESA_pack_invert is available */
66
 
 
67
65
  int framerate;
68
66
  char *pipeline_description;
69
67
  char *filename;
450
448
                                                 recorder->stage_height,
451
449
                                                 recorder->stage_width * 4);
452
450
 
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)
457
 
    {
458
 
      cairo_translate(cr, 0, recorder->stage_height);
459
 
      cairo_scale(cr, 1, -1);
460
 
    }
461
 
 
462
452
  cairo_set_source_surface (cr,
463
453
                            recorder->cursor_image,
464
454
                            recorder->pointer_x - recorder->cursor_hot_x,
534
524
 
535
525
  GST_BUFFER_TIMESTAMP(buffer) = get_wall_time() - recorder->start_time;
536
526
 
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)
541
 
   *
542
 
   * http://bugzilla.openedhand.com/show_bug.cgi?id=1959
543
 
   */
544
 
 
545
 
  /* Flush any primitives that Cogl has batched up */
546
 
  cogl_flush ();
547
 
 
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);
554
 
 
555
 
  if (recorder->have_pack_invert)
556
 
    glPixelStorei (GL_PACK_INVERT_MESA, TRUE);
557
 
 
558
 
  glReadBuffer (GL_BACK_LEFT);
559
 
  glReadPixels (0, 0,
560
 
                recorder->stage_width, recorder->stage_height,
561
 
                GL_BGRA,
562
 
                GL_UNSIGNED_INT_8_8_8_8_REV,
563
 
                data);
564
 
 
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,
 
531
                    data);
567
532
 
568
533
  recorder_draw_cursor (recorder, buffer);
569
534
 
866
831
  if (recorder->stage)
867
832
    {
868
833
      int error_base;
869
 
      const char *gl_extensions;
870
834
 
871
835
      recorder->stage = stage;
872
836
      g_signal_connect (recorder->stage, "destroy",
891
855
                                 XFixesDisplayCursorNotifyMask);
892
856
 
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;
896
858
 
897
859
      recorder_get_initial_cursor_position (recorder);
898
860
    }
1093
1055
  GstPad *sink_pad = NULL, *src_pad = NULL;
1094
1056
  gboolean result = FALSE;
1095
1057
  GstElement *ffmpegcolorspace;
1096
 
  GstElement *videoflip;
1097
 
  GError *error = NULL;
1098
1058
 
1099
1059
  sink_pad = gst_bin_find_unlinked_pad (GST_BIN (pipeline->pipeline), GST_PAD_SINK);
1100
1060
  if (sink_pad == NULL)
1124
1084
    }
1125
1085
  gst_bin_add (GST_BIN (pipeline->pipeline), ffmpegcolorspace);
1126
1086
 
1127
 
  /* glReadPixels gives us an upside-down buffer, so we have to flip it back
1128
 
   * right-side up.
1129
 
   *
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.
1133
 
   *
1134
 
   * We use gst_parse_launch to avoid having to know the enum value for flip-vertical
1135
 
   */
1136
 
 
1137
 
  if (!pipeline->recorder->have_pack_invert)
1138
 
    {
1139
 
      videoflip = gst_parse_launch_full ("videoflip method=vertical-flip", NULL,
1140
 
                                         GST_PARSE_FLAG_FATAL_ERRORS,
1141
 
                                         &error);
1142
 
      if (videoflip == NULL)
1143
 
        {
1144
 
          g_warning("Can't create videoflip element: %s", error->message);
1145
 
          g_error_free (error);
1146
 
          goto out;
1147
 
        }
1148
 
 
1149
 
      gst_bin_add (GST_BIN (pipeline->pipeline), videoflip);
1150
 
      gst_element_link_many (pipeline->src, ffmpegcolorspace, videoflip, NULL);
1151
 
 
1152
 
      src_pad = gst_element_get_static_pad (videoflip, "src");
1153
 
    }
1154
 
  else
1155
 
    {
1156
 
      gst_element_link_many (pipeline->src, ffmpegcolorspace, NULL);
1157
 
      src_pad = gst_element_get_static_pad (ffmpegcolorspace, "src");
1158
 
    }
 
1087
  gst_element_link_many (pipeline->src, ffmpegcolorspace, NULL);
 
1088
  src_pad = gst_element_get_static_pad (ffmpegcolorspace, "src");
1159
1089
 
1160
1090
  if (!src_pad)
1161
1091
    {