From aa9e91e261789e3b3fb1551981f83d7d61dffd4c Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Tue, 12 Feb 2008 17:17:52 +0000 Subject: [PATCH] * clutter/clutter-texture.c: (texture_get_tile_pixbuf), (clutter_texture_get_pixbuf): Fix copying textures to pixbufs for tiled textures and correct #ifndef typo * clutter/clutter-util.c: Amend documentation --- ChangeLog | 10 ++++++++++ clutter/clutter-texture.c | 31 ++++++++++++++++++++++--------- clutter/clutter-util.c | 4 ++-- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index fb9fc0bde..c2716f925 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-02-12 Chris Lord + + * clutter/clutter-texture.c: (texture_get_tile_pixbuf), + (clutter_texture_get_pixbuf): + Fix copying textures to pixbufs for tiled textures and correct #ifndef + typo + + * clutter/clutter-util.c: + Amend documentation + 2008-02-12 Matthew Allum * clutter/clutter-texture.c: (texture_get_tile_pixbuf): diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 1c94e43c7..c3bf81d21 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -1192,9 +1192,11 @@ pixbuf_destroy_notify (guchar *pixels, gpointer data) static GdkPixbuf * texture_get_tile_pixbuf (ClutterTexture *texture, COGLuint texture_id, - gint bpp) + gint bpp, + gint ix, + gint iy) { -#ifndef HAVE_COGL_GL +#ifdef HAVE_COGL_GL ClutterTexturePrivate *priv; guchar *pixels = NULL; guint tex_width, tex_height; @@ -1202,13 +1204,24 @@ texture_get_tile_pixbuf (ClutterTexture *texture, priv = texture->priv; cogl_texture_bind (priv->target_type, texture_id); - tex_width = priv->width; - tex_height = priv->height; - + if (!priv->is_tiled) + { + tex_width = priv->width; + tex_height = priv->height; + } + else + { + tex_width = priv->x_tiles[ix].size; + tex_height = priv->y_tiles[iy].size; + } + + /* Make sure if we aren't using rectangular textures that we increase the + * texture size accordingly. + */ if (priv->target_type == CGL_TEXTURE_2D) /* POT */ { - tex_width = clutter_util_next_p2 (priv->width); - tex_height = clutter_util_next_p2 (priv->height); + tex_width = clutter_util_next_p2 (tex_width); + tex_height = clutter_util_next_p2 (tex_height); } cogl_texture_set_alignment (priv->target_type, 4, tex_width); @@ -1283,7 +1296,7 @@ clutter_texture_get_pixbuf (ClutterTexture *texture) if (!priv->is_tiled) { - pixtmp = texture_get_tile_pixbuf (texture, priv->tiles[0], bpp); + pixtmp = texture_get_tile_pixbuf (texture, priv->tiles[0], bpp, 0, 0); if (pixtmp == NULL) { @@ -1319,7 +1332,7 @@ clutter_texture_get_pixbuf (ClutterTexture *texture) { gint src_w, src_h; - pixtmp = texture_get_tile_pixbuf (texture, priv->tiles[i], bpp); + pixtmp = texture_get_tile_pixbuf (texture, priv->tiles[i], bpp, x, y); if (pixtmp == NULL) { diff --git a/clutter/clutter-util.c b/clutter/clutter-util.c index 67f37b742..85fcf5f57 100644 --- a/clutter/clutter-util.c +++ b/clutter/clutter-util.c @@ -38,9 +38,9 @@ * clutter_util_next_p2: * @a: Value to get the next power * - * Calculates the next power greater than @a. + * Calculates the nearest power of two, greater than or equal to @a. * - * Return value: The next power after @a. + * Return value: The nearest power of two, greater or equal to @a. */ int clutter_util_next_p2 (int a)