[gnome-shell/wip/wayland: 1/4] Remove shell-screen-grabber



commit 5248c8bcbcc114f65a9bbb1f0db6240b27c74c76
Author: Neil Roberts <neil linux intel com>
Date:   Tue Mar 13 15:07:43 2012 +0000

    Remove shell-screen-grabber
    
    The screen grabber was a workaround for an extremely slow path in Mesa
    when reading back pixel data from the frame buffer. It was using pixel
    buffer objects by directly calling into GL to hit a fast blit path in
    Intel's driver. This should no longer be necessary with the latest
    Mesa because the normal read pixels path now has a fast path to just
    memcpy the data. Using PBOs in that case just adds an extra
    indirection because the data is read into an intermediate buffer and
    then copied back out again.
    
    We want to be able to remove the dependency on linking against libGL
    directly from Gnome Shell because that will not work if Cogl is
    actually using GLES. Also libGL includes GLX which means gnome-shell
    ends up with a hard dependency on Xlib which hinders the goal of
    getting Gnome Shell to be a Wayland compositor.
    
    https://bugs.freedesktop.org/show_bug.cgi?id=46631

 src/Makefile.am            |    4 -
 src/shell-recorder.c       |   16 ++--
 src/shell-screen-grabber.c |  210 --------------------------------------------
 src/shell-screen-grabber.h |   44 ---------
 src/shell-screenshot.c     |   37 ++++++--
 5 files changed, 34 insertions(+), 277 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 8023794..a3adc00 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -121,7 +121,6 @@ shell_public_headers_h =		\
 	shell-network-agent.h		\
 	shell-perf-log.h		\
 	shell-screenshot.h		\
-	shell-screen-grabber.h		\
 	shell-slicer.h			\
 	shell-stack.h			\
 	shell-tp-client.h		\
@@ -173,7 +172,6 @@ libgnome_shell_la_SOURCES =		\
 	shell-polkit-authentication-agent.h	\
 	shell-polkit-authentication-agent.c	\
 	shell-screenshot.c		\
-	shell-screen-grabber.c		\
 	shell-secure-text-buffer.c	\
 	shell-secure-text-buffer.h	\
 	shell-slicer.c			\
@@ -241,8 +239,6 @@ test_recorder_LDADD = $(TEST_SHELL_RECORDER_LIBS)
 
 test_recorder_SOURCES =     \
 	$(shell_recorder_sources) $(shell_recorder_private_sources) \
-	shell-screen-grabber.c	\
-	shell-screen-grabber.h	\
 	test-recorder.c
 endif BUILD_RECORDER
 
diff --git a/src/shell-recorder.c b/src/shell-recorder.c
index 120ca0f..cf5c816 100644
--- a/src/shell-recorder.c
+++ b/src/shell-recorder.c
@@ -12,7 +12,6 @@
 
 #include "shell-recorder-src.h"
 #include "shell-recorder.h"
-#include "shell-screen-grabber.h"
 
 #include <clutter/x11/clutter-x11.h>
 #include <X11/extensions/Xfixes.h>
@@ -48,8 +47,6 @@ struct _ShellRecorder {
   int stage_width;
   int stage_height;
 
-  ShellScreenGrabber *grabber;
-
   gboolean have_pointer;
   int pointer_x;
   int pointer_y;
@@ -267,8 +264,6 @@ shell_recorder_init (ShellRecorder *recorder)
   recorder->recording_icon = create_recording_icon ();
   recorder->memory_target = get_memory_target();
 
-  recorder->grabber = shell_screen_grabber_new ();
-
   recorder->state = RECORDER_STATE_CLOSED;
   recorder->framerate = DEFAULT_FRAMES_PER_SECOND;
 }
@@ -300,8 +295,6 @@ shell_recorder_finalize (GObject  *object)
   recorder_set_pipeline (recorder, NULL);
   recorder_set_filename (recorder, NULL);
 
-  g_object_unref (recorder->grabber);
-
   cogl_handle_unref (recorder->recording_icon);
 
   G_OBJECT_CLASS (shell_recorder_parent_class)->finalize (object);
@@ -545,8 +538,13 @@ recorder_record_frame (ShellRecorder *recorder)
 
   size = recorder->stage_width * recorder->stage_height * 4;
 
-  data = shell_screen_grabber_grab (recorder->grabber,
-                                    0, 0, recorder->stage_width, recorder->stage_height);
+  data = g_malloc (recorder->stage_width * 4 * recorder->stage_height);
+  cogl_read_pixels (0, 0, /* x/y */
+                    recorder->stage_width,
+                    recorder->stage_height,
+                    COGL_READ_PIXELS_COLOR_BUFFER,
+                    CLUTTER_CAIRO_FORMAT_ARGB32,
+                    data);
 
   buffer = gst_buffer_new();
   GST_BUFFER_SIZE(buffer) = size;
diff --git a/src/shell-screenshot.c b/src/shell-screenshot.c
index 2f58340..8494072 100644
--- a/src/shell-screenshot.c
+++ b/src/shell-screenshot.c
@@ -1,5 +1,8 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 
+#define COGL_ENABLE_EXPERIMENTAL_API
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+
 #include <X11/extensions/Xfixes.h>
 #include <clutter/x11/clutter-x11.h>
 #include <clutter/clutter.h>
@@ -10,7 +13,6 @@
 #include <meta/meta-shaped-texture.h>
 
 #include "shell-global.h"
-#include "shell-screen-grabber.h"
 #include "shell-screenshot.h"
 
 struct _ShellScreenshotClass
@@ -90,18 +92,33 @@ do_grab_screenshot (_screenshot_data *screenshot_data,
                     int               width,
                     int               height)
 {
-  ShellScreenGrabber *grabber;
-  static const cairo_user_data_key_t key;
+  CoglBitmap *bitmap;
+  ClutterBackend *backend;
+  CoglContext *context;
+  int stride;
   guchar *data;
 
-  grabber = shell_screen_grabber_new ();
-  data = shell_screen_grabber_grab (grabber, x, y, width, height);
-  g_object_unref (grabber);
+  backend = clutter_get_default_backend ();
+  context = clutter_backend_get_cogl_context (backend);
+
+  screenshot_data->image = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
+                                                       width, height);
+
+
+  data = cairo_image_surface_get_data (screenshot_data->image);
+  stride = cairo_image_surface_get_stride (screenshot_data->image);
 
-  screenshot_data->image = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_RGB24,
-                                                               width, height, width * 4);
-  cairo_surface_set_user_data (screenshot_data->image, &key,
-                               data, (cairo_destroy_func_t)g_free);
+  bitmap = cogl_bitmap_new_for_data (context,
+                                     width,
+                                     height,
+                                     CLUTTER_CAIRO_FORMAT_ARGB32,
+                                     stride,
+                                     data);
+  cogl_framebuffer_read_pixels_into_bitmap (cogl_get_draw_framebuffer (),
+                                            x, y,
+                                            COGL_READ_PIXELS_COLOR_BUFFER,
+                                            bitmap);
+  cogl_object_unref (bitmap);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]