mirror of
https://github.com/brl/mutter.git
synced 2025-01-05 09:12:14 +00:00
2007-03-19 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-texture.c: Clean up code; add checks in public API.
This commit is contained in:
parent
02d1f56310
commit
71815c61d9
@ -1,3 +1,8 @@
|
|||||||
|
2007-03-19 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
|
* clutter/clutter-texture.c: Clean up code; add checks
|
||||||
|
in public API.
|
||||||
|
|
||||||
2007-02-18 Matthew Allum <mallum@openedhand.com>
|
2007-02-18 Matthew Allum <mallum@openedhand.com>
|
||||||
|
|
||||||
* clutter/clutter-actor.c: (clutter_actor_reparent):
|
* clutter/clutter-actor.c: (clutter_actor_reparent):
|
||||||
|
@ -57,30 +57,35 @@ G_DEFINE_TYPE (ClutterTexture, clutter_texture, CLUTTER_TYPE_ACTOR);
|
|||||||
#define PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
|
#define PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct ClutterTextureTileDimension
|
typedef struct {
|
||||||
{
|
gint pos;
|
||||||
gint pos, size, waste;
|
gint size;
|
||||||
}
|
gint waste;
|
||||||
ClutterTextureTileDimension;
|
} ClutterTextureTileDimension;
|
||||||
|
|
||||||
struct _ClutterTexturePrivate
|
struct _ClutterTexturePrivate
|
||||||
{
|
{
|
||||||
gint width, height;
|
gint width;
|
||||||
|
gint height;
|
||||||
|
|
||||||
GLenum pixel_format;
|
GLenum pixel_format;
|
||||||
GLenum pixel_type;
|
GLenum pixel_type;
|
||||||
GLenum target_type;
|
GLenum target_type;
|
||||||
|
|
||||||
GdkPixbuf *local_pixbuf; /* non video memory copy */
|
GdkPixbuf *local_pixbuf; /* non video memory copy */
|
||||||
|
|
||||||
gboolean sync_actor_size;
|
guint sync_actor_size : 1;
|
||||||
gint max_tile_waste;
|
gint max_tile_waste;
|
||||||
guint filter_quality;
|
guint filter_quality;
|
||||||
gboolean repeat_x, repeat_y; /* non working */
|
guint repeat_x : 1; /* non working */
|
||||||
|
guint repeat_y : 1; /* non working */
|
||||||
|
|
||||||
|
|
||||||
gboolean tiled;
|
guint is_tiled : 1;
|
||||||
ClutterTextureTileDimension *x_tiles, *y_tiles;
|
ClutterTextureTileDimension *x_tiles;
|
||||||
gint n_x_tiles, n_y_tiles;
|
ClutterTextureTileDimension *y_tiles;
|
||||||
|
gint n_x_tiles;
|
||||||
|
gint n_y_tiles;
|
||||||
GLuint *tiles;
|
GLuint *tiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -266,7 +271,7 @@ texture_render_to_gl_quad (ClutterTexture *texture,
|
|||||||
* supported.
|
* supported.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!priv->tiled)
|
if (!priv->is_tiled)
|
||||||
{
|
{
|
||||||
glBindTexture(priv->target_type, priv->tiles[0]);
|
glBindTexture(priv->target_type, priv->tiles[0]);
|
||||||
|
|
||||||
@ -347,7 +352,7 @@ texture_free_gl_resources (ClutterTexture *texture)
|
|||||||
|
|
||||||
if (priv->tiles)
|
if (priv->tiles)
|
||||||
{
|
{
|
||||||
if (!priv->tiled)
|
if (!priv->is_tiled)
|
||||||
glDeleteTextures(1, priv->tiles);
|
glDeleteTextures(1, priv->tiles);
|
||||||
else
|
else
|
||||||
glDeleteTextures(priv->n_x_tiles * priv->n_y_tiles, priv->tiles);
|
glDeleteTextures(priv->n_x_tiles * priv->n_y_tiles, priv->tiles);
|
||||||
@ -388,7 +393,7 @@ texture_upload_data (ClutterTexture *texture,
|
|||||||
|
|
||||||
CLUTTER_MARK();
|
CLUTTER_MARK();
|
||||||
|
|
||||||
if (!priv->tiled)
|
if (!priv->is_tiled)
|
||||||
{
|
{
|
||||||
/* Single Texture */
|
/* Single Texture */
|
||||||
if (!priv->tiles)
|
if (!priv->tiles)
|
||||||
@ -481,7 +486,8 @@ texture_upload_data (ClutterTexture *texture,
|
|||||||
|
|
||||||
/* fixme - gslice ? */
|
/* fixme - gslice ? */
|
||||||
tmp = g_malloc (sizeof (guchar) * priv->x_tiles[x].size
|
tmp = g_malloc (sizeof (guchar) * priv->x_tiles[x].size
|
||||||
* priv->y_tiles[y].size * bpp);
|
* priv->y_tiles[y].size
|
||||||
|
* bpp);
|
||||||
|
|
||||||
/* clip */
|
/* clip */
|
||||||
if (priv->x_tiles[x].pos + src_w > priv->width)
|
if (priv->x_tiles[x].pos + src_w > priv->width)
|
||||||
@ -546,8 +552,7 @@ texture_upload_data (ClutterTexture *texture,
|
|||||||
{
|
{
|
||||||
glTexImage2D(priv->target_type,
|
glTexImage2D(priv->target_type,
|
||||||
0,
|
0,
|
||||||
(bpp == 4) ?
|
(bpp == 4) ? GL_RGBA : GL_RGB,
|
||||||
GL_RGBA : GL_RGB,
|
|
||||||
priv->x_tiles[x].size,
|
priv->x_tiles[x].size,
|
||||||
priv->y_tiles[y].size,
|
priv->y_tiles[y].size,
|
||||||
0,
|
0,
|
||||||
@ -748,14 +753,14 @@ clutter_texture_set_property (GObject *object,
|
|||||||
(GdkPixbuf*)g_value_get_pointer(value));
|
(GdkPixbuf*)g_value_get_pointer(value));
|
||||||
break;
|
break;
|
||||||
case PROP_USE_TILES:
|
case PROP_USE_TILES:
|
||||||
priv->tiled = g_value_get_boolean (value);
|
priv->is_tiled = g_value_get_boolean (value);
|
||||||
|
|
||||||
if (priv->target_type == GL_TEXTURE_RECTANGLE_ARB
|
if (priv->target_type == GL_TEXTURE_RECTANGLE_ARB &&
|
||||||
&& priv->tiled == TRUE)
|
priv->is_tiled)
|
||||||
priv->target_type = GL_TEXTURE_2D;
|
priv->target_type = GL_TEXTURE_2D;
|
||||||
|
|
||||||
CLUTTER_NOTE (TEXTURE, "Texture is tiled ? %s",
|
CLUTTER_NOTE (TEXTURE, "Texture is tiled ? %s",
|
||||||
priv->tiled ? "yes" : "no");
|
priv->is_tiled ? "yes" : "no");
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_TILE_WASTE:
|
case PROP_MAX_TILE_WASTE:
|
||||||
priv->max_tile_waste = g_value_get_int (value);
|
priv->max_tile_waste = g_value_get_int (value);
|
||||||
@ -806,7 +811,7 @@ clutter_texture_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_USE_TILES:
|
case PROP_USE_TILES:
|
||||||
g_value_set_boolean (value, priv->tiled);
|
g_value_set_boolean (value, priv->is_tiled);
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_TILE_WASTE:
|
case PROP_MAX_TILE_WASTE:
|
||||||
g_value_set_int (value, priv->max_tile_waste);
|
g_value_set_int (value, priv->max_tile_waste);
|
||||||
@ -998,7 +1003,7 @@ clutter_texture_init (ClutterTexture *self)
|
|||||||
|
|
||||||
priv->max_tile_waste = 64;
|
priv->max_tile_waste = 64;
|
||||||
priv->filter_quality = 0;
|
priv->filter_quality = 0;
|
||||||
priv->tiled = TRUE;
|
priv->is_tiled = TRUE;
|
||||||
priv->pixel_type = PIXEL_TYPE;
|
priv->pixel_type = PIXEL_TYPE;
|
||||||
priv->pixel_format = GL_RGBA;
|
priv->pixel_format = GL_RGBA;
|
||||||
priv->repeat_x = FALSE;
|
priv->repeat_x = FALSE;
|
||||||
@ -1007,7 +1012,7 @@ clutter_texture_init (ClutterTexture *self)
|
|||||||
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
||||||
{
|
{
|
||||||
priv->target_type = GL_TEXTURE_RECTANGLE_ARB;
|
priv->target_type = GL_TEXTURE_RECTANGLE_ARB;
|
||||||
priv->tiled = FALSE;
|
priv->is_tiled = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
priv->target_type = GL_TEXTURE_2D;
|
priv->target_type = GL_TEXTURE_2D;
|
||||||
@ -1042,7 +1047,7 @@ clutter_texture_get_pixbuf (ClutterTexture* texture)
|
|||||||
if (priv->tiles == NULL)
|
if (priv->tiles == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!priv->tiled)
|
if (!priv->is_tiled)
|
||||||
{
|
{
|
||||||
pixels = g_malloc (priv->width * priv->height * 4);
|
pixels = g_malloc (priv->width * priv->height * 4);
|
||||||
|
|
||||||
@ -1181,7 +1186,7 @@ clutter_texture_set_from_data (ClutterTexture *texture,
|
|||||||
{
|
{
|
||||||
texture_free_gl_resources (texture);
|
texture_free_gl_resources (texture);
|
||||||
|
|
||||||
if (priv->tiled == FALSE)
|
if (priv->is_tiled == FALSE)
|
||||||
{
|
{
|
||||||
if (priv->target_type == GL_TEXTURE_RECTANGLE_ARB
|
if (priv->target_type == GL_TEXTURE_RECTANGLE_ARB
|
||||||
&& !can_create_rect_arb (priv->width,
|
&& !can_create_rect_arb (priv->width,
|
||||||
@ -1190,7 +1195,7 @@ clutter_texture_set_from_data (ClutterTexture *texture,
|
|||||||
priv->pixel_type))
|
priv->pixel_type))
|
||||||
{
|
{
|
||||||
/* If we cant create NPOT tex of this size fall back to tiles */
|
/* If we cant create NPOT tex of this size fall back to tiles */
|
||||||
priv->tiled = TRUE;
|
priv->is_tiled = TRUE;
|
||||||
priv->target_type = GL_TEXTURE_2D;
|
priv->target_type = GL_TEXTURE_2D;
|
||||||
}
|
}
|
||||||
else if (priv->target_type == GL_TEXTURE_2D
|
else if (priv->target_type == GL_TEXTURE_2D
|
||||||
@ -1199,12 +1204,12 @@ clutter_texture_set_from_data (ClutterTexture *texture,
|
|||||||
priv->pixel_format,
|
priv->pixel_format,
|
||||||
priv->pixel_type))
|
priv->pixel_type))
|
||||||
{
|
{
|
||||||
priv->tiled = TRUE;
|
priv->is_tiled = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Figure our tiling etc */
|
/* Figure our tiling etc */
|
||||||
if (priv->tiled)
|
if (priv->is_tiled)
|
||||||
texture_init_tiles (texture);
|
texture_init_tiles (texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1246,7 +1251,8 @@ clutter_texture_set_from_data (ClutterTexture *texture,
|
|||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
clutter_texture_set_pixbuf (ClutterTexture *texture, GdkPixbuf *pixbuf)
|
clutter_texture_set_pixbuf (ClutterTexture *texture,
|
||||||
|
GdkPixbuf *pixbuf)
|
||||||
{
|
{
|
||||||
ClutterTexturePrivate *priv;
|
ClutterTexturePrivate *priv;
|
||||||
|
|
||||||
@ -1291,11 +1297,7 @@ clutter_texture_new_from_pixbuf (GdkPixbuf *pixbuf)
|
|||||||
ClutterActor *
|
ClutterActor *
|
||||||
clutter_texture_new (void)
|
clutter_texture_new (void)
|
||||||
{
|
{
|
||||||
ClutterTexture *texture;
|
return g_object_new (CLUTTER_TYPE_TEXTURE, NULL);
|
||||||
|
|
||||||
texture = g_object_new (CLUTTER_TYPE_TEXTURE, NULL);
|
|
||||||
|
|
||||||
return CLUTTER_ACTOR(texture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1422,16 +1424,22 @@ clutter_texture_get_y_tile_detail (ClutterTexture *texture,
|
|||||||
gint *size,
|
gint *size,
|
||||||
gint *waste)
|
gint *waste)
|
||||||
{
|
{
|
||||||
g_return_if_fail(y_index < texture->priv->n_y_tiles);
|
ClutterTexturePrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
|
||||||
|
|
||||||
|
priv = texture->priv;
|
||||||
|
|
||||||
|
g_return_if_fail (y_index < priv->n_y_tiles);
|
||||||
|
|
||||||
if (pos)
|
if (pos)
|
||||||
*pos = texture->priv->y_tiles[y_index].pos;
|
*pos = priv->y_tiles[y_index].pos;
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
*size = texture->priv->y_tiles[y_index].size;
|
*size = priv->y_tiles[y_index].size;
|
||||||
|
|
||||||
if (waste)
|
if (waste)
|
||||||
*waste = texture->priv->y_tiles[y_index].waste;
|
*waste = priv->y_tiles[y_index].waste;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1448,6 +1456,8 @@ clutter_texture_get_y_tile_detail (ClutterTexture *texture,
|
|||||||
gboolean
|
gboolean
|
||||||
clutter_texture_has_generated_tiles (ClutterTexture *texture)
|
clutter_texture_has_generated_tiles (ClutterTexture *texture)
|
||||||
{
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
|
||||||
|
|
||||||
return (texture->priv->tiles != NULL);
|
return (texture->priv->tiles != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1465,5 +1475,7 @@ clutter_texture_has_generated_tiles (ClutterTexture *texture)
|
|||||||
gboolean
|
gboolean
|
||||||
clutter_texture_is_tiled (ClutterTexture *texture)
|
clutter_texture_is_tiled (ClutterTexture *texture)
|
||||||
{
|
{
|
||||||
return texture->priv->tiled;
|
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
|
||||||
|
|
||||||
|
return texture->priv->is_tiled;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user