[clutter] Remove last dependency on the GdkPixbuf API
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] Remove last dependency on the GdkPixbuf API
- Date: Fri, 6 May 2011 14:49:59 +0000 (UTC)
commit 589c80e41e4febc981cb2218c8f6eaf1b8c33157
Author: Robert Bragg <robert linux intel com>
Date: Fri May 6 14:55:05 2011 +0100
Remove last dependency on the GdkPixbuf API
In test-pixmap.c instead of using the GdkPixbuf API to load the
redhand.png image we now use the cairo API to load the png into a xlib
surface which wraps our Pixmap.
This test was the last thing that depended on the gdk API and since
it's more concise to use Cairo here which is a hard dependency for
Clutter this change means we avoid depending on GdkPixbuf directly.
README.in | 4 -
clutter/clutter-script.c | 4 -
configure.ac | 2 -
tests/interactive/test-pixmap.c | 119 +++++++++++----------------------------
4 files changed, 33 insertions(+), 96 deletions(-)
---
diff --git a/README.in b/README.in
index 9b8b33c..9b44278 100644
--- a/README.in
+++ b/README.in
@@ -16,10 +16,6 @@ Clutter currently requires:
â?¢ Cairo â?¥ @CAIRO_REQ_VERSION@
â?¢ PangoCairo â?¥ @PANGO_REQ_VERSION@
-Clutter also has optional dependencies:
-
- â?¢ GDK-Pixbuf â?¥ @GDK_PIXBUF_REQ_VERSION@
-
On X11, Clutter depends on the following extensions
â?¢ XComposite â?¥ @XCOMPOSITE_REQ_VERSION@
diff --git a/clutter/clutter-script.c b/clutter/clutter-script.c
index bda40c6..20b13d3 100644
--- a/clutter/clutter-script.c
+++ b/clutter/clutter-script.c
@@ -191,10 +191,6 @@
#include <glib-object.h>
#include <gmodule.h>
-#ifdef USE_GDKPIXBUF
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#endif
-
#include "clutter-actor.h"
#include "clutter-alpha.h"
#include "clutter-behaviour.h"
diff --git a/configure.ac b/configure.ac
index 3753971..99f69cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,7 +122,6 @@ m4_define([atk_req_version], [1.17])
m4_define([cairo_req_version], [1.10])
m4_define([pango_req_version], [1.20])
m4_define([gi_req_version], [0.9.5])
-m4_define([gdk_pixbuf_req_version], [2.0])
m4_define([uprof_req_version], [0.3])
m4_define([gtk_doc_req_version], [1.13])
m4_define([xfixes_req_version], [3])
@@ -135,7 +134,6 @@ AC_SUBST([ATK_REQ_VERSION], [atk_req_version])
AC_SUBST([CAIRO_REQ_VERSION], [cairo_req_version])
AC_SUBST([PANGO_REQ_VERSION], [pango_req_version])
AC_SUBST([GI_REQ_VERSION], [gi_req_version])
-AC_SUBST([GDK_PIXBUF_REQ_VERSION], [gdk_pixbuf_req_version])
AC_SUBST([UPROF_REQ_VERSION], [uprof_req_version])
AC_SUBST([GTK_DOC_REQ_VERSION], [gtk_doc_req_version])
AC_SUBST([XFIXES_REQ_VERSION], [xfixes_req_version])
diff --git a/tests/interactive/test-pixmap.c b/tests/interactive/test-pixmap.c
index a67df4b..9bdf950 100644
--- a/tests/interactive/test-pixmap.c
+++ b/tests/interactive/test-pixmap.c
@@ -17,10 +17,10 @@
# include <X11/Xlib.h>
# include <X11/extensions/Xcomposite.h>
-#define IMAGE TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png"
+# include <cairo.h>
+# include <cairo-xlib.h>
-# ifdef USE_GDKPIXBUF
-# include <gdk-pixbuf/gdk-pixbuf.h>
+#define IMAGE TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png"
static gboolean disable_x11 = FALSE;
static gboolean disable_animation = FALSE;
@@ -133,94 +133,44 @@ stage_button_press_cb (ClutterActor *actor,
Pixmap
create_pixmap (guint *width, guint *height, guint *depth)
{
- Display *dpy = clutter_x11_get_default_display ();
- Pixmap pixmap;
- GdkPixbuf *pixbuf;
- GError *error = NULL;
- XImage *image;
- char *data, *d;
- guchar *p, *line, *endofline, *end;
- guint w, h, rowstride;
- GC gc;
- XGCValues gc_values = {0};
-
- pixbuf = gdk_pixbuf_new_from_file (IMAGE, &error);
- if (error)
- g_error ("%s", error->message);
-
- /* We assume that the image had an alpha channel */
- g_assert (gdk_pixbuf_get_has_alpha (pixbuf));
-
- w = gdk_pixbuf_get_width (pixbuf);
- h = gdk_pixbuf_get_height (pixbuf);
- rowstride = gdk_pixbuf_get_rowstride (pixbuf);
-
- data = g_malloc (w * h * 4);
- image = XCreateImage (dpy,
- NULL,
- 32,
- ZPixmap,
- 0,
- data,
- w, h,
- 8,
- w * 4);
-
- p = gdk_pixbuf_get_pixels (pixbuf);
- d = data;
- end = p + rowstride*h;
-
- /* Convert from RGBA as contained in the pixmap to ARGB as used in X */
- for (line = p; line < end ; line += rowstride)
- {
- p = line;
- endofline = p + 4 * w;
-
- for (p = line; p < endofline; p += 4, d+=4)
- {
-
-# define r ((guint32)(*(p)))
-# define g ((guint32)(*(p+1)))
-# define b ((guint32)(*(p+2)))
-# define a ((guint32)(*(p+3)))
- guint32 pixel =
- ((a << 24) & 0xFF000000 ) |
- ((r << 16) & 0x00FF0000 ) |
- ((g << 8) & 0x0000FF00) |
- ((b) & 0x000000FF );
-
- *((guint32 *)d) = pixel;
-
- }
-# undef r
-# undef g
-# undef b
-# undef a
-
- }
-
- g_object_unref (pixbuf);
+ Display *dpy = clutter_x11_get_default_display ();
+ cairo_surface_t *image;
+ Pixmap pixmap;
+ XVisualInfo xvisinfo;
+ XVisualInfo *xvisinfos;
+ int n;
+ cairo_surface_t *xlib_surface;
+ cairo_t *cr;
+ guint w, h;
+
+ image = cairo_image_surface_create_from_png (IMAGE);
+ if (cairo_surface_status (image) != CAIRO_STATUS_SUCCESS)
+ g_error ("Failed to load %s", IMAGE);
+
+ w = cairo_image_surface_get_width (image);
+ h = cairo_image_surface_get_height (image);
pixmap = XCreatePixmap (dpy,
DefaultRootWindow (dpy),
w, h,
32);
- gc = XCreateGC (dpy,
- pixmap,
- 0,
- &gc_values);
+ xvisinfo.depth = 32;
+ xvisinfos = XGetVisualInfo (dpy, VisualDepthMask, &xvisinfo, &n);
+ if (!xvisinfos)
+ g_error ("Failed to find a 32bit X Visual");
- XPutImage (dpy,
- pixmap,
- gc,
- image,
- 0, 0,
- 0, 0,
- w, h);
+ xlib_surface =
+ cairo_xlib_surface_create (dpy,
+ pixmap,
+ xvisinfos->visual,
+ w, h);
+ XFree (xvisinfos);
- XFreeGC (dpy, gc);
- XDestroyImage (image);
+ cr = cairo_create (xlib_surface);
+ cairo_set_source_surface (cr, image, 0, 0);
+ cairo_paint (cr);
+ cairo_surface_destroy (image);
if (width) *width = w;
if (height) *height = h;
@@ -228,7 +178,6 @@ create_pixmap (guint *width, guint *height, guint *depth)
return pixmap;
}
-# endif /* USE_GDKPIXBUF */
/* each time the timeline animating the label completes, swap the direction */
static void
@@ -243,7 +192,6 @@ timeline_completed (ClutterTimeline *timeline,
G_MODULE_EXPORT int
test_pixmap_main (int argc, char **argv)
{
-#ifdef USE_GDKPIXBUF
GOptionContext *context;
Display *xdpy;
int screen;
@@ -357,7 +305,6 @@ test_pixmap_main (int argc, char **argv)
g_timeout_add_seconds (1, (GSourceFunc)draw_arc, GUINT_TO_POINTER (pixmap));
clutter_main ();
-# endif /* USE_GDKPIXBUF */
return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]