2006-05-29 04:59:36 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2006-06-21 18:34:25 -04:00
|
|
|
/**
|
|
|
|
* SECTION:clutter-clone-texture
|
|
|
|
* @short_description: Actor for cloning existing textures in an
|
|
|
|
* efficient way.
|
|
|
|
*
|
|
|
|
* #ClutterCloneTexture allows the cloning of existing #ClutterTexture based
|
|
|
|
* actors whilst saving underlying graphics resources.
|
|
|
|
*/
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
#include "clutter-clone-texture.h"
|
|
|
|
#include "clutter-main.h"
|
2006-07-24 17:15:19 -04:00
|
|
|
#include "clutter-feature.h"
|
2006-12-12 15:20:04 -05:00
|
|
|
#include "clutter-actor.h"
|
2006-05-29 04:59:36 -04:00
|
|
|
#include "clutter-util.h"
|
|
|
|
#include "clutter-enum-types.h"
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 16:27:53 -05:00
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-debug.h"
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_PARENT_TEXTURE
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (ClutterCloneTexture,
|
|
|
|
clutter_clone_texture,
|
2006-06-13 09:17:45 -04:00
|
|
|
CLUTTER_TYPE_ACTOR);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
#define CLUTTER_CLONE_TEXTURE_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_CLONE_TEXTURE, ClutterCloneTexturePrivate))
|
|
|
|
|
|
|
|
struct _ClutterCloneTexturePrivate
|
|
|
|
{
|
|
|
|
ClutterTexture *parent_texture;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
clone_texture_render_to_gl_quad (ClutterCloneTexture *ctexture,
|
|
|
|
int x1,
|
|
|
|
int y1,
|
|
|
|
int x2,
|
|
|
|
int y2)
|
|
|
|
{
|
|
|
|
gint qx1 = 0, qx2 = 0, qy1 = 0, qy2 = 0;
|
|
|
|
gint qwidth = 0, qheight = 0;
|
|
|
|
gint x, y, i =0, lastx = 0, lasty = 0;
|
|
|
|
gint n_x_tiles, n_y_tiles;
|
|
|
|
gint pwidth, pheight;
|
|
|
|
float tx, ty;
|
|
|
|
|
|
|
|
ClutterCloneTexturePrivate *priv = ctexture->priv;
|
2006-06-13 09:17:45 -04:00
|
|
|
ClutterActor *parent_actor = CLUTTER_ACTOR (priv->parent_texture);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
priv = ctexture->priv;
|
|
|
|
|
|
|
|
qwidth = x2 - x1;
|
|
|
|
qheight = y2 - y1;
|
|
|
|
|
2006-06-13 09:17:45 -04:00
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (parent_actor))
|
|
|
|
clutter_actor_realize (parent_actor);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
/* Only paint if parent is in a state to do so */
|
|
|
|
if (!clutter_texture_has_generated_tiles (priv->parent_texture))
|
|
|
|
return;
|
|
|
|
|
|
|
|
clutter_texture_get_base_size (priv->parent_texture, &pwidth, &pheight);
|
|
|
|
|
|
|
|
if (!clutter_texture_is_tiled (priv->parent_texture))
|
|
|
|
{
|
|
|
|
clutter_texture_bind_tile (priv->parent_texture, 0);
|
|
|
|
|
2006-07-24 17:15:19 -04:00
|
|
|
/* NPOTS textures *always* used if extension available
|
|
|
|
*/
|
|
|
|
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE))
|
|
|
|
{
|
|
|
|
tx = (float) pwidth;
|
|
|
|
ty = (float) pheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tx = (float) pwidth / clutter_util_next_p2 (pwidth);
|
|
|
|
ty = (float) pheight / clutter_util_next_p2 (pheight);
|
|
|
|
}
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
qx1 = x1; qx2 = x2;
|
|
|
|
qy1 = y1; qy2 = y2;
|
|
|
|
|
|
|
|
glBegin (GL_QUADS);
|
|
|
|
glTexCoord2f (tx, ty); glVertex2i (qx2, qy2);
|
|
|
|
glTexCoord2f (0, ty); glVertex2i (qx1, qy2);
|
|
|
|
glTexCoord2f (0, 0); glVertex2i (qx1, qy1);
|
|
|
|
glTexCoord2f (tx, 0); glVertex2i (qx2, qy1);
|
|
|
|
glEnd ();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clutter_texture_get_n_tiles (priv->parent_texture, &n_x_tiles, &n_y_tiles);
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
for (x = 0; x < n_x_tiles; x++)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
|
|
|
lasty = 0;
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
for (y = 0; y < n_y_tiles; y++)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
|
|
|
gint actual_w, actual_h;
|
|
|
|
gint xpos, ypos, xsize, ysize, ywaste, xwaste;
|
|
|
|
|
|
|
|
clutter_texture_bind_tile (priv->parent_texture, i);
|
|
|
|
|
|
|
|
clutter_texture_get_x_tile_detail (priv->parent_texture,
|
|
|
|
x, &xpos, &xsize, &xwaste);
|
|
|
|
|
|
|
|
clutter_texture_get_y_tile_detail (priv->parent_texture,
|
|
|
|
y, &ypos, &ysize, &ywaste);
|
|
|
|
|
|
|
|
actual_w = xsize - xwaste;
|
|
|
|
actual_h = ysize - ywaste;
|
|
|
|
|
|
|
|
tx = (float) actual_w / xsize;
|
|
|
|
ty = (float) actual_h / ysize;
|
|
|
|
|
|
|
|
qx1 = x1 + lastx;
|
|
|
|
qx2 = qx1 + ((qwidth * actual_w ) / pwidth );
|
|
|
|
|
|
|
|
qy1 = y1 + lasty;
|
|
|
|
qy2 = qy1 + ((qheight * actual_h) / pheight );
|
|
|
|
|
2006-11-21 Emmanuele Bassi <ebassi@openedhand.com>
* configure.ac: Enable debug messages also when
--enable-debug is set to "minimum".
* clutter/Makefile.am:
* clutter/clutter-debug.h: Move all debugging macros inside
this private header; make all debug macros depend on the
CLUTTER_ENABLE_DEBUG compile time define, controlled by
the --enable-debug configure switch; add G_LOG_DOMAIN define.
* clutter/clutter-main.c: Clean up the debug stuff; add
command line argument parsing using GOption; the debug
messages now are triggered like this:
CLUTTER_DEBUG=section:section:... clutter-app
or like this:
clutter-app --clutter-debug=section:section:...
where "section" is one of the sections listed in clutter-main.c,
or "all", for all sections; each section is bound to a flag,
which can be used to define a domain when adding a debug note
using the CLUTTER_NOTE() macro; the old CLUTTER_DBG() macro is
just a wrapper around that, under the CLUTTER_DEBUG_MISC domain;
CLUTTER_NOTE() is used like this:
CLUTTER_NOTE (DOMAIN, log-function);
where log function is g_printerr(), g_message(), g_warning(),
g_critical() or directly g_log() - for instance:
CLUTTER_NOTE (PANGO, g_warning ("Cache miss: %d", glyph));
will print the warning only if the "pango" flag has been
set to the CLUTTER_DEBUG envvar or passed to the --clutter-debug
command line argument.
similar to CLUTTER_SHOW_FPS, there's also the --clutter-show-fps
command line switch; also, the --display and --screen command
line switches have been added: the first overrides the DISPLAY
envvar and the second controls the X screen used by Clutter to
get the root window on the display.
* clutter/clutter-main.h:
* clutter/clutter-main.c: Add extended support for GOption
in Clutter; use clutter_init_with_args() to let Clutter
parse your own command line arguments; use instead
clutter_get_option_group() to get the GOptionGroup used by
Clutter if you want to do the parsing yourself with
g_option_context_parse(). The init sequence has been verified,
updated and moved into common functions where possible.
* clutter/pango/pangoclutter-render.c:
* clutter/*.c: Include "clutter-debug.h" where needed; use
CLUTTER_NOTE() instead of CLUTTER_DBG().
* examples/super-oh.c: Use the new clutter_init_with_args()
function, and add a --num-hands command line switch to
the SuperOH example code controlling the number of hands at
runtime.
2006-11-21 16:27:53 -05:00
|
|
|
CLUTTER_NOTE (TEXTURE,
|
2006-11-22 15:52:27 -05:00
|
|
|
"rendering text tile x: %i, y: %i - %ix%i",
|
|
|
|
x, y,
|
|
|
|
actual_w, actual_h);
|
2006-06-06 16:40:40 -04:00
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
glBegin (GL_QUADS);
|
|
|
|
glTexCoord2f (tx, ty); glVertex2i (qx2, qy2);
|
|
|
|
glTexCoord2f (0, ty); glVertex2i (qx1, qy2);
|
|
|
|
glTexCoord2f (0, 0); glVertex2i (qx1, qy1);
|
|
|
|
glTexCoord2f (tx, 0); glVertex2i (qx2, qy1);
|
|
|
|
glEnd ();
|
|
|
|
|
|
|
|
lasty += qy2 - qy1;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
lastx += qx2 - qx1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-06-13 09:17:45 -04:00
|
|
|
clutter_clone_texture_paint (ClutterActor *self)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
|
|
|
ClutterCloneTexturePrivate *priv;
|
2006-07-24 17:15:19 -04:00
|
|
|
ClutterActor *parent_texture;
|
2006-05-29 04:59:36 -04:00
|
|
|
gint x1, y1, x2, y2;
|
2006-07-24 17:15:19 -04:00
|
|
|
GLenum target_type;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
priv = CLUTTER_CLONE_TEXTURE (self)->priv;
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
/* no need to paint stuff if we don't have a texture to clone */
|
|
|
|
if (!priv->parent_texture)
|
|
|
|
return;
|
2006-07-24 17:15:19 -04:00
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
/* parent texture may have been hidden, there for need to make sure its
|
|
|
|
* realised with resources available.
|
|
|
|
*/
|
2006-06-13 09:17:45 -04:00
|
|
|
parent_texture = CLUTTER_ACTOR (priv->parent_texture);
|
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (parent_texture))
|
|
|
|
clutter_actor_realize (parent_texture);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-07-24 17:15:19 -04:00
|
|
|
/* FIXME: figure out nicer way of getting at this info...
|
|
|
|
*/
|
2006-12-12 15:20:04 -05:00
|
|
|
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_RECTANGLE) &&
|
|
|
|
clutter_texture_is_tiled (CLUTTER_TEXTURE (parent_texture)) == FALSE)
|
2006-07-24 17:15:19 -04:00
|
|
|
target_type = GL_TEXTURE_RECTANGLE_ARB;
|
|
|
|
else
|
|
|
|
target_type = GL_TEXTURE_2D;
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
glEnable (GL_BLEND);
|
|
|
|
glEnable (target_type);
|
|
|
|
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
glColor4ub (255, 255, 255, clutter_actor_get_opacity (self));
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-06-13 09:17:45 -04:00
|
|
|
clutter_actor_get_coords (self, &x1, &y1, &x2, &y2);
|
2006-06-06 16:40:40 -04:00
|
|
|
|
2006-11-22 15:52:27 -05:00
|
|
|
CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i "
|
|
|
|
"opacity: %i",
|
|
|
|
x1, y1, x2, y2,
|
|
|
|
clutter_actor_get_opacity (self));
|
2006-06-06 16:40:40 -04:00
|
|
|
|
2006-09-20 14:38:08 -04:00
|
|
|
/* Parent paint translated us into position */
|
2006-12-12 15:20:04 -05:00
|
|
|
clone_texture_render_to_gl_quad (CLUTTER_CLONE_TEXTURE (self),
|
2006-09-20 14:38:08 -04:00
|
|
|
0, 0, x2 - x1, y2 - y1);
|
2006-12-12 15:20:04 -05:00
|
|
|
glDisable (target_type);
|
|
|
|
glDisable (GL_BLEND);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_parent_texture (ClutterCloneTexture *ctexture,
|
|
|
|
ClutterTexture *texture)
|
|
|
|
{
|
|
|
|
ClutterCloneTexturePrivate *priv = ctexture->priv;
|
2006-12-12 15:20:04 -05:00
|
|
|
ClutterActor *actor = CLUTTER_ACTOR (ctexture);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
if (priv->parent_texture)
|
|
|
|
{
|
|
|
|
g_object_unref (priv->parent_texture);
|
|
|
|
priv->parent_texture = NULL;
|
|
|
|
}
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
clutter_actor_hide (actor);
|
|
|
|
|
2006-06-06 16:40:40 -04:00
|
|
|
if (texture)
|
|
|
|
{
|
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
priv->parent_texture = g_object_ref (texture);
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
/* Sync up the size to parent texture base pixbuf size. */
|
2006-06-06 16:40:40 -04:00
|
|
|
clutter_texture_get_base_size (texture, &width, &height);
|
2006-12-12 15:20:04 -05:00
|
|
|
clutter_actor_set_size (actor, width, height);
|
|
|
|
|
|
|
|
/* queue a redraw if the cloned texture is already visible */
|
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (priv->parent_texture)) &&
|
|
|
|
CLUTTER_ACTOR_IS_VISIBLE (actor))
|
|
|
|
clutter_actor_queue_redraw (actor);
|
2006-06-06 16:40:40 -04:00
|
|
|
}
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_clone_texture_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
ClutterCloneTexture *self = CLUTTER_CLONE_TEXTURE(object);
|
|
|
|
ClutterCloneTexturePrivate *priv = self->priv;
|
|
|
|
|
|
|
|
if (priv->parent_texture)
|
|
|
|
g_object_unref (priv->parent_texture);
|
|
|
|
|
|
|
|
priv->parent_texture = NULL;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_clone_texture_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_clone_texture_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
G_OBJECT_CLASS (clutter_clone_texture_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_clone_texture_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PARENT_TEXTURE:
|
|
|
|
set_parent_texture (ctexture, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_clone_texture_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterCloneTexture *ctexture = CLUTTER_CLONE_TEXTURE (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_PARENT_TEXTURE:
|
|
|
|
g_value_set_object (value, ctexture->priv->parent_texture);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_clone_texture_class_init (ClutterCloneTextureClass *klass)
|
|
|
|
{
|
2006-12-12 15:20:04 -05:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2006-06-13 09:17:45 -04:00
|
|
|
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
actor_class->paint = clutter_clone_texture_paint;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
gobject_class->finalize = clutter_clone_texture_finalize;
|
|
|
|
gobject_class->dispose = clutter_clone_texture_dispose;
|
|
|
|
gobject_class->set_property = clutter_clone_texture_set_property;
|
|
|
|
gobject_class->get_property = clutter_clone_texture_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_PARENT_TEXTURE,
|
|
|
|
g_param_spec_object ("parent-texture",
|
|
|
|
"Parent Texture",
|
|
|
|
"The parent texture to clone",
|
|
|
|
CLUTTER_TYPE_TEXTURE,
|
2006-12-12 15:20:04 -05:00
|
|
|
(G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE)));
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
g_type_class_add_private (gobject_class, sizeof (ClutterCloneTexturePrivate));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_clone_texture_init (ClutterCloneTexture *self)
|
|
|
|
{
|
|
|
|
ClutterCloneTexturePrivate *priv;
|
|
|
|
|
|
|
|
self->priv = priv = CLUTTER_CLONE_TEXTURE_GET_PRIVATE (self);
|
|
|
|
priv->parent_texture = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_clone_texture_new:
|
2006-12-12 15:20:04 -05:00
|
|
|
* @texture: a #ClutterTexture or %NULL
|
2006-05-29 04:59:36 -04:00
|
|
|
*
|
2006-06-06 16:40:40 -04:00
|
|
|
* Creates an efficient 'clone' of a pre-existing texture if which it
|
2006-12-12 15:20:04 -05:00
|
|
|
* shares the underlying pixbuf data.
|
|
|
|
*
|
|
|
|
* You can use clutter_clone_texture_set_parent_texture() to change the
|
|
|
|
* parent texture to be cloned.
|
2006-05-29 04:59:36 -04:00
|
|
|
*
|
|
|
|
* Return value: the newly created #ClutterCloneTexture
|
|
|
|
*/
|
2006-06-13 09:17:45 -04:00
|
|
|
ClutterActor *
|
2006-05-29 04:59:36 -04:00
|
|
|
clutter_clone_texture_new (ClutterTexture *texture)
|
|
|
|
{
|
2006-12-12 15:20:04 -05:00
|
|
|
g_return_val_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture), NULL);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
|
|
|
return g_object_new (CLUTTER_TYPE_CLONE_TEXTURE,
|
|
|
|
"parent-texture", texture,
|
|
|
|
NULL);
|
|
|
|
}
|
2006-12-12 15:20:04 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_clone_texture_get_parent_texture:
|
|
|
|
* @clone: a #ClutterCloneTexture
|
|
|
|
*
|
|
|
|
* Retrieves the parent #ClutterTexture used by @clone.
|
|
|
|
*
|
|
|
|
* Return value: a #ClutterTexture actor, or %NULL
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
ClutterTexture *
|
|
|
|
clutter_clone_texture_get_parent_texture (ClutterCloneTexture *clone)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_CLONE_TEXTURE (clone), NULL);
|
|
|
|
|
|
|
|
return clone->priv->parent_texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_clone_texture_set_parent_texture:
|
|
|
|
* @clone: a #ClutterCloneTexture
|
|
|
|
* @texture a #ClutterTexture or %NULL
|
|
|
|
*
|
|
|
|
* Sets the parent texture cloned by the #ClutterCloneTexture.
|
|
|
|
*
|
|
|
|
* Since: 0.2
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_clone_texture_set_parent_texture (ClutterCloneTexture *clone,
|
|
|
|
ClutterTexture *texture)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_CLONE_TEXTURE (clone));
|
|
|
|
g_return_if_fail (texture == NULL || CLUTTER_IS_TEXTURE (texture));
|
|
|
|
|
|
|
|
g_object_ref (clone);
|
|
|
|
|
|
|
|
set_parent_texture (clone, texture);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (clone), "parent-texture");
|
|
|
|
g_object_unref (clone);
|
|
|
|
}
|