2006-05-29 08:59:36 +00: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 22:34:25 +00:00
|
|
|
/**
|
|
|
|
* SECTION:clutter-texture
|
|
|
|
* @short_description: An actor for displaying and manipulating images.
|
|
|
|
*
|
|
|
|
* #ClutterTexture is a base class for displaying and manipulating pixel
|
|
|
|
* buffer type data.
|
2006-09-19 19:27:16 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* The clutter_texture_set_from_rgb_data() and
|
|
|
|
* clutter_texture_set_from_file() functions are used to copy image
|
|
|
|
* data into texture memory and subsequently realize the texture.
|
2007-05-25 10:56:09 +00:00
|
|
|
*
|
2007-07-24 17:38:35 +00:00
|
|
|
* If texture reads are supported by underlying GL implementation,
|
2008-06-13 15:37:58 +00:00
|
|
|
* unrealizing frees image data from texture memory moving to main
|
2007-10-12 08:17:00 +00:00
|
|
|
* system memory. Re-realizing then performs the opposite operation.
|
2008-06-13 15:37:58 +00:00
|
|
|
* This process allows basic management of commonly limited available
|
|
|
|
* texture memory.
|
2007-12-17 15:51:30 +00:00
|
|
|
*
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
* Note: a ClutterTexture will scale its contents to fit the bounding
|
|
|
|
* box requested using clutter_actor_set_size(). To display an area of
|
|
|
|
* a texture without scaling, you should set the clip area using
|
|
|
|
* clutter_actor_set_clip().
|
2006-06-21 22:34:25 +00:00
|
|
|
*/
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-04-27 21:13:06 +00:00
|
|
|
#include "config.h"
|
2007-10-12 08:17:00 +00:00
|
|
|
#endif
|
2007-04-27 21:13:06 +00:00
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
#include "clutter-texture.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-marshal.h"
|
2006-07-24 21:15:19 +00:00
|
|
|
#include "clutter-feature.h"
|
2006-06-06 20:40:40 +00:00
|
|
|
#include "clutter-util.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 21:27:53 +00:00
|
|
|
#include "clutter-private.h"
|
2008-04-25 13:37:36 +00:00
|
|
|
#include "clutter-scriptable.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 21:27:53 +00:00
|
|
|
#include "clutter-debug.h"
|
2007-04-27 21:13:06 +00:00
|
|
|
#include "clutter-fixed.h"
|
2008-06-07 15:08:05 +00:00
|
|
|
#include "clutter-enum-types.h"
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
#include "cogl/cogl.h"
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
static void clutter_scriptable_iface_init (ClutterScriptableIface *iface);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (ClutterTexture,
|
|
|
|
clutter_texture,
|
|
|
|
CLUTTER_TYPE_ACTOR,
|
|
|
|
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_SCRIPTABLE,
|
|
|
|
clutter_scriptable_iface_init));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2007-07-24 17:38:35 +00:00
|
|
|
#define CLUTTER_TEXTURE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_TEXTURE, ClutterTexturePrivate))
|
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
typedef struct _ClutterTextureAsyncData ClutterTextureAsyncData;
|
|
|
|
|
2006-12-03 18:34:41 +00:00
|
|
|
struct _ClutterTexturePrivate
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2007-04-27 21:13:06 +00:00
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint max_tile_waste;
|
2008-06-07 15:08:05 +00:00
|
|
|
ClutterTextureQuality filter_quality;
|
2008-12-23 16:39:11 +00:00
|
|
|
CoglHandle material;
|
2008-04-25 13:37:36 +00:00
|
|
|
gboolean no_slice;
|
2008-02-01 15:29:00 +00:00
|
|
|
|
|
|
|
ClutterActor *fbo_source;
|
2008-04-25 13:37:36 +00:00
|
|
|
CoglHandle fbo_handle;
|
|
|
|
|
|
|
|
/* Non video memory copy of image data */
|
|
|
|
guint local_data_width, local_data_height;
|
|
|
|
guint local_data_rowstride;
|
|
|
|
guint local_data_has_alpha;
|
|
|
|
guchar *local_data;
|
2008-06-13 14:58:18 +00:00
|
|
|
|
2008-11-07 17:00:54 +00:00
|
|
|
guint sync_actor_size : 1;
|
|
|
|
guint repeat_x : 1;
|
|
|
|
guint repeat_y : 1;
|
2008-06-13 14:58:18 +00:00
|
|
|
guint in_dispose : 1;
|
2008-06-23 15:31:12 +00:00
|
|
|
guint keep_aspect_ratio : 1;
|
2009-03-11 18:26:30 +00:00
|
|
|
guint load_size_async : 1;
|
|
|
|
guint load_data_async : 1;
|
2009-03-12 10:14:40 +00:00
|
|
|
guint load_async_set : 1; /* used to make load_async
|
|
|
|
possible */
|
2009-02-25 17:10:54 +00:00
|
|
|
|
|
|
|
ClutterTextureAsyncData *async_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _ClutterTextureAsyncData
|
|
|
|
{
|
|
|
|
/* Mutex used to synchronize setting the abort flag */
|
|
|
|
GMutex *mutex;
|
|
|
|
|
|
|
|
/* If set to true, the loaded data will be discarded */
|
|
|
|
gboolean abort;
|
|
|
|
|
|
|
|
/* The texture for which the data is being loaded */
|
|
|
|
ClutterTexture *texture;
|
|
|
|
|
|
|
|
/* Source ID of the idle handler for loading. If this is zero then
|
|
|
|
the data is being loaded in a thread from the thread pool. Once
|
|
|
|
the thread is finished it will be converted to idle load handler
|
|
|
|
and load_idle will be nonzero. If load_idle is nonzero then the
|
|
|
|
rest of the load can safely be aborted by just removing the
|
|
|
|
source, otherwise the abort flag needs to be set and the data
|
|
|
|
should be disowned */
|
|
|
|
guint load_idle;
|
|
|
|
|
|
|
|
gchar *load_filename;
|
2009-04-30 17:00:22 +00:00
|
|
|
CoglHandle load_bitmap;
|
2009-02-25 17:10:54 +00:00
|
|
|
GError *load_error;
|
2006-05-29 08:59:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2008-04-25 13:37:36 +00:00
|
|
|
PROP_NO_SLICE,
|
2006-05-29 08:59:36 +00:00
|
|
|
PROP_MAX_TILE_WASTE,
|
|
|
|
PROP_PIXEL_FORMAT, /* Texture format */
|
|
|
|
PROP_SYNC_SIZE,
|
|
|
|
PROP_REPEAT_Y,
|
2006-06-06 20:40:40 +00:00
|
|
|
PROP_REPEAT_X,
|
2008-04-25 13:37:36 +00:00
|
|
|
PROP_FILTER_QUALITY,
|
|
|
|
PROP_COGL_TEXTURE,
|
2008-12-23 16:39:11 +00:00
|
|
|
PROP_COGL_MATERIAL,
|
2008-06-23 15:31:12 +00:00
|
|
|
PROP_FILENAME,
|
2009-01-07 17:02:43 +00:00
|
|
|
PROP_KEEP_ASPECT_RATIO,
|
2009-03-11 18:26:30 +00:00
|
|
|
PROP_LOAD_ASYNC,
|
|
|
|
PROP_LOAD_DATA_ASYNC,
|
2006-05-29 08:59:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2006-12-13 18:12:09 +00:00
|
|
|
SIZE_CHANGE,
|
|
|
|
PIXBUF_CHANGE,
|
2009-01-07 17:02:43 +00:00
|
|
|
LOAD_SUCCESS,
|
|
|
|
LOAD_FINISHED,
|
2006-05-29 08:59:36 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static int texture_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
static GThreadPool *async_thread_pool = NULL;
|
|
|
|
|
2008-02-03 23:25:12 +00:00
|
|
|
static void
|
|
|
|
texture_fbo_free_resources (ClutterTexture *texture);
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
static void
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_save_to_local_data (ClutterTexture *texture);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
static void
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_load_from_local_data (ClutterTexture *texture);
|
2007-10-12 08:17:00 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
GQuark
|
|
|
|
clutter_texture_error_quark (void)
|
|
|
|
{
|
|
|
|
return g_quark_from_static_string ("clutter-texture-error-quark");
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2009-02-06 13:50:16 +00:00
|
|
|
static inline void
|
|
|
|
clutter_texture_quality_to_filters (ClutterTextureQuality quality,
|
|
|
|
gint *min_filter_p,
|
|
|
|
gint *mag_filter_p)
|
2008-06-07 15:08:05 +00:00
|
|
|
{
|
2009-02-06 13:50:16 +00:00
|
|
|
gint min_filter, mag_filter;
|
2008-06-07 15:08:05 +00:00
|
|
|
|
2009-02-06 13:50:16 +00:00
|
|
|
switch (quality)
|
2008-06-07 15:08:05 +00:00
|
|
|
{
|
2009-02-06 13:50:16 +00:00
|
|
|
case CLUTTER_TEXTURE_QUALITY_LOW:
|
2009-05-12 13:15:18 +00:00
|
|
|
min_filter = COGL_TEXTURE_FILTER_NEAREST;
|
|
|
|
mag_filter = COGL_TEXTURE_FILTER_NEAREST;
|
2009-02-06 13:50:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_TEXTURE_QUALITY_MEDIUM:
|
2009-05-12 13:15:18 +00:00
|
|
|
min_filter = COGL_TEXTURE_FILTER_LINEAR;
|
|
|
|
mag_filter = COGL_TEXTURE_FILTER_LINEAR;
|
2009-02-06 13:50:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_TEXTURE_QUALITY_HIGH:
|
2009-05-12 13:15:18 +00:00
|
|
|
min_filter = COGL_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR;
|
|
|
|
mag_filter = COGL_TEXTURE_FILTER_LINEAR;
|
2009-02-06 13:50:16 +00:00
|
|
|
break;
|
2008-06-07 15:08:05 +00:00
|
|
|
}
|
2009-02-06 13:50:16 +00:00
|
|
|
|
|
|
|
if (min_filter_p)
|
|
|
|
*min_filter_p = min_filter;
|
|
|
|
|
|
|
|
if (mag_filter_p)
|
|
|
|
*mag_filter_p = mag_filter;
|
2008-06-07 15:08:05 +00:00
|
|
|
}
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
static void
|
2006-09-19 19:27:16 +00:00
|
|
|
texture_free_gl_resources (ClutterTexture *texture)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2009-02-06 13:50:16 +00:00
|
|
|
ClutterTexturePrivate *priv = texture->priv;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
CLUTTER_MARK();
|
|
|
|
|
2009-02-11 17:52:50 +00:00
|
|
|
if (priv->material != COGL_INVALID_HANDLE)
|
|
|
|
cogl_material_remove_layer (priv->material, 0);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 19:27:16 +00:00
|
|
|
static void
|
|
|
|
clutter_texture_unrealize (ClutterActor *actor)
|
|
|
|
{
|
|
|
|
ClutterTexture *texture;
|
|
|
|
ClutterTexturePrivate *priv;
|
|
|
|
|
|
|
|
texture = CLUTTER_TEXTURE(actor);
|
|
|
|
priv = texture->priv;
|
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
if (priv->material == COGL_INVALID_HANDLE)
|
2006-09-19 19:27:16 +00:00
|
|
|
return;
|
|
|
|
|
2007-12-28 15:34:24 +00:00
|
|
|
/* there's no need to read the pixels back when unrealizing inside
|
|
|
|
* a dispose run, and the dispose() call will release the GL
|
|
|
|
* texture data as well, so we can safely bail out now
|
|
|
|
*/
|
2008-06-13 14:58:18 +00:00
|
|
|
if ((CLUTTER_PRIVATE_FLAGS (actor) & CLUTTER_ACTOR_IN_DESTRUCTION) ||
|
|
|
|
priv->in_dispose)
|
2007-12-28 15:34:24 +00:00
|
|
|
return;
|
|
|
|
|
2006-09-19 19:27:16 +00:00
|
|
|
CLUTTER_MARK();
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->fbo_source != COGL_INVALID_HANDLE)
|
2008-02-08 10:37:38 +00:00
|
|
|
{
|
|
|
|
/* Free up our fbo handle and texture resources, realize will recreate */
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_unref (priv->fbo_handle);
|
2008-04-25 13:37:36 +00:00
|
|
|
priv->fbo_handle = COGL_INVALID_HANDLE;
|
2008-02-08 10:37:38 +00:00
|
|
|
texture_free_gl_resources (texture);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-05-28 20:09:19 +00:00
|
|
|
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_READ_PIXELS))
|
|
|
|
{
|
2007-10-12 08:17:00 +00:00
|
|
|
/* Move image data from video to main memory.
|
|
|
|
* GL/ES cant do this - it probably makes sense
|
2007-05-28 20:09:19 +00:00
|
|
|
* to move this kind of thing into a ClutterProxyTexture
|
|
|
|
* where this behaviour can be better controlled.
|
2007-06-22 15:16:40 +00:00
|
|
|
*
|
|
|
|
* Or make it controllable via a property.
|
2007-05-28 20:09:19 +00:00
|
|
|
*/
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->local_data == NULL)
|
2007-06-07 23:51:53 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_save_to_local_data (texture);
|
|
|
|
CLUTTER_NOTE (TEXTURE, "moved pixels into system mem");
|
2007-06-07 23:51:53 +00:00
|
|
|
}
|
|
|
|
|
2007-05-28 20:09:19 +00:00
|
|
|
texture_free_gl_resources (texture);
|
|
|
|
}
|
2006-09-19 19:27:16 +00:00
|
|
|
|
2006-11-22 20:52:27 +00:00
|
|
|
CLUTTER_NOTE (TEXTURE, "Texture unrealized");
|
2006-09-19 19:27:16 +00:00
|
|
|
}
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
static void
|
2006-06-13 13:17:45 +00:00
|
|
|
clutter_texture_realize (ClutterActor *actor)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2006-09-19 19:27:16 +00:00
|
|
|
ClutterTexture *texture;
|
|
|
|
ClutterTexturePrivate *priv;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2006-06-13 13:17:45 +00:00
|
|
|
texture = CLUTTER_TEXTURE(actor);
|
2006-09-19 19:27:16 +00:00
|
|
|
priv = texture->priv;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
CLUTTER_MARK();
|
|
|
|
|
2008-02-08 10:37:38 +00:00
|
|
|
if (priv->fbo_source)
|
|
|
|
{
|
2009-01-18 14:51:19 +00:00
|
|
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
2009-02-06 13:50:16 +00:00
|
|
|
gint min_filter, mag_filter;
|
2009-01-18 14:51:19 +00:00
|
|
|
gint max_waste = -1;
|
2009-04-30 13:32:19 +00:00
|
|
|
CoglHandle tex;
|
2009-01-18 14:51:19 +00:00
|
|
|
|
2008-02-08 10:37:38 +00:00
|
|
|
/* Handle FBO's */
|
|
|
|
|
2009-01-18 14:51:19 +00:00
|
|
|
if (!priv->no_slice)
|
|
|
|
max_waste = priv->max_tile_waste;
|
|
|
|
|
|
|
|
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
|
|
|
|
flags |= COGL_TEXTURE_AUTO_MIPMAP;
|
|
|
|
|
2009-04-30 13:32:19 +00:00
|
|
|
tex = cogl_texture_new_with_size (priv->width,
|
|
|
|
priv->height,
|
|
|
|
max_waste, flags,
|
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888);
|
|
|
|
|
|
|
|
cogl_material_set_layer (priv->material, 0, tex);
|
2008-02-08 10:37:38 +00:00
|
|
|
|
2009-02-06 13:50:16 +00:00
|
|
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
|
|
|
&min_filter,
|
|
|
|
&mag_filter);
|
|
|
|
|
2009-04-30 13:32:19 +00:00
|
|
|
cogl_texture_set_filters (tex, min_filter, mag_filter);
|
|
|
|
|
|
|
|
priv->fbo_handle = cogl_offscreen_new_to_texture (tex);
|
2008-02-08 10:37:38 +00:00
|
|
|
|
2009-04-30 13:32:19 +00:00
|
|
|
/* The material now has a reference to the texture so it will
|
|
|
|
stick around */
|
|
|
|
cogl_handle_unref (tex);
|
2008-02-08 10:37:38 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->fbo_handle == COGL_INVALID_HANDLE)
|
2008-02-08 10:37:38 +00:00
|
|
|
{
|
|
|
|
g_warning ("%s: Offscreen texture creation failed", G_STRLOC);
|
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
clutter_actor_set_size (actor, priv->width, priv->height);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->local_data != NULL)
|
2006-09-19 19:27:16 +00:00
|
|
|
{
|
2007-10-12 08:17:00 +00:00
|
|
|
/* Move any local image data we have from unrealization
|
|
|
|
* back into video memory.
|
2006-09-19 19:27:16 +00:00
|
|
|
*/
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_load_from_local_data (texture);
|
2006-09-19 19:27:16 +00:00
|
|
|
}
|
|
|
|
else
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2007-06-07 23:51:53 +00:00
|
|
|
if (clutter_feature_available (CLUTTER_FEATURE_TEXTURE_READ_PIXELS))
|
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Dont allow realization with no data - note set_data
|
2007-10-12 08:17:00 +00:00
|
|
|
* will set realize flags.
|
2008-04-25 13:37:36 +00:00
|
|
|
*/
|
2007-06-07 23:51:53 +00:00
|
|
|
CLUTTER_NOTE (TEXTURE,
|
|
|
|
"Texture has no image data cannot realize");
|
2007-10-12 08:17:00 +00:00
|
|
|
|
2007-06-07 23:51:53 +00:00
|
|
|
CLUTTER_NOTE (TEXTURE, "flags %i", actor->flags);
|
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (actor, CLUTTER_ACTOR_REALIZED);
|
|
|
|
CLUTTER_NOTE (TEXTURE, "flags %i", actor->flags);
|
|
|
|
return;
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-11-22 20:52:27 +00:00
|
|
|
CLUTTER_NOTE (TEXTURE, "Texture realized");
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
static void
|
|
|
|
clutter_texture_get_preferred_width (ClutterActor *self,
|
|
|
|
ClutterUnit for_height,
|
|
|
|
ClutterUnit *min_width_p,
|
|
|
|
ClutterUnit *natural_width_p)
|
|
|
|
{
|
|
|
|
ClutterTexture *texture = CLUTTER_TEXTURE (self);
|
|
|
|
ClutterTexturePrivate *priv = texture->priv;
|
|
|
|
|
|
|
|
/* Min request is always 0 since we can scale down or clip */
|
|
|
|
if (min_width_p)
|
|
|
|
*min_width_p = 0;
|
|
|
|
|
|
|
|
if (priv->sync_actor_size)
|
|
|
|
{
|
|
|
|
if (natural_width_p)
|
2008-06-17 14:45:33 +00:00
|
|
|
{
|
2008-06-23 15:31:12 +00:00
|
|
|
if (!priv->keep_aspect_ratio ||
|
|
|
|
for_height < 0 ||
|
|
|
|
priv->height <= 0)
|
|
|
|
{
|
|
|
|
*natural_width_p = CLUTTER_UNITS_FROM_DEVICE (priv->width);
|
|
|
|
}
|
2008-06-17 14:45:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Set the natural width so as to preserve the aspect ratio */
|
2009-03-09 17:31:44 +00:00
|
|
|
gfloat ratio, height;
|
2008-06-23 15:31:12 +00:00
|
|
|
|
2009-03-09 17:31:44 +00:00
|
|
|
ratio = (float)(priv->width) / (float)(priv->height);
|
2008-06-23 15:31:12 +00:00
|
|
|
|
2009-03-09 17:31:44 +00:00
|
|
|
height = CLUTTER_UNITS_TO_FLOAT (for_height);
|
2008-06-23 15:31:12 +00:00
|
|
|
|
|
|
|
*natural_width_p =
|
2009-03-09 17:31:44 +00:00
|
|
|
CLUTTER_UNITS_FROM_FLOAT (ratio * height);
|
2008-06-17 14:45:33 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (natural_width_p)
|
|
|
|
*natural_width_p = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_texture_get_preferred_height (ClutterActor *self,
|
|
|
|
ClutterUnit for_width,
|
|
|
|
ClutterUnit *min_height_p,
|
|
|
|
ClutterUnit *natural_height_p)
|
|
|
|
{
|
|
|
|
ClutterTexture *texture = CLUTTER_TEXTURE (self);
|
|
|
|
ClutterTexturePrivate *priv = texture->priv;
|
|
|
|
|
|
|
|
/* Min request is always 0 since we can scale down or clip */
|
|
|
|
if (min_height_p)
|
|
|
|
*min_height_p = 0;
|
|
|
|
|
|
|
|
if (priv->sync_actor_size)
|
|
|
|
{
|
|
|
|
if (natural_height_p)
|
2008-06-17 14:45:33 +00:00
|
|
|
{
|
2008-06-23 15:31:12 +00:00
|
|
|
if (!priv->keep_aspect_ratio ||
|
|
|
|
for_width < 0 ||
|
|
|
|
priv->width <= 0)
|
|
|
|
{
|
|
|
|
*natural_height_p = CLUTTER_UNITS_FROM_DEVICE (priv->height);
|
|
|
|
}
|
2008-06-17 14:45:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Set the natural height so as to preserve the aspect ratio */
|
2009-03-09 17:31:44 +00:00
|
|
|
gfloat ratio, width;
|
2008-12-23 16:29:29 +00:00
|
|
|
|
2009-03-09 17:31:44 +00:00
|
|
|
ratio = (float)(priv->height) / (float)(priv->width);
|
2008-06-23 15:31:12 +00:00
|
|
|
|
2009-03-09 17:31:44 +00:00
|
|
|
width = CLUTTER_UNITS_TO_FLOAT (for_width);
|
2008-12-23 16:29:29 +00:00
|
|
|
|
2008-06-23 15:31:12 +00:00
|
|
|
*natural_height_p =
|
2009-03-09 17:31:44 +00:00
|
|
|
CLUTTER_UNITS_FROM_FLOAT (ratio * width);
|
2008-06-17 14:45:33 +00:00
|
|
|
}
|
|
|
|
}
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (natural_height_p)
|
|
|
|
*natural_height_p = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-04 10:44:18 +00:00
|
|
|
static void
|
|
|
|
clutter_texture_allocate (ClutterActor *self,
|
|
|
|
const ClutterActorBox *box,
|
|
|
|
gboolean origin_changed)
|
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv = CLUTTER_TEXTURE (self)->priv;
|
|
|
|
|
|
|
|
/* chain up to set actor->allocation */
|
|
|
|
CLUTTER_ACTOR_CLASS (clutter_texture_parent_class)->allocate (self, box,
|
|
|
|
origin_changed);
|
|
|
|
|
|
|
|
/* If we adopted the source fbo then allocate that at its preferred
|
|
|
|
size */
|
|
|
|
if (priv->fbo_source && clutter_actor_get_parent (priv->fbo_source) == self)
|
|
|
|
clutter_actor_allocate_preferred_size (priv->fbo_source, origin_changed);
|
|
|
|
}
|
|
|
|
|
2008-08-01 12:23:57 +00:00
|
|
|
static void
|
|
|
|
clutter_texture_set_fbo_projection (ClutterActor *self)
|
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv = CLUTTER_TEXTURE (self)->priv;
|
|
|
|
ClutterVertex verts[4];
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
gfloat viewport[4];
|
2008-12-19 13:42:17 +00:00
|
|
|
ClutterUnit x_min, x_max, y_min, y_max;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
gfloat tx_min, tx_max, ty_min, ty_max;
|
|
|
|
gfloat tan_angle, near_size;
|
2008-08-01 12:23:57 +00:00
|
|
|
ClutterPerspective perspective;
|
|
|
|
ClutterStage *stage;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Get the bounding rectangle of the source as drawn in screen
|
|
|
|
coordinates */
|
|
|
|
clutter_actor_get_abs_allocation_vertices (priv->fbo_source, verts);
|
|
|
|
|
|
|
|
x_min = x_max = verts[0].x;
|
|
|
|
y_min = y_max = verts[0].y;
|
|
|
|
|
|
|
|
for (i = 1; i < G_N_ELEMENTS (verts); ++i)
|
|
|
|
{
|
|
|
|
if (verts[i].x < x_min)
|
|
|
|
x_min = verts[i].x;
|
|
|
|
|
|
|
|
if (verts[i].x > x_max)
|
|
|
|
x_max = verts[i].x;
|
|
|
|
|
|
|
|
if (verts[i].y < y_min)
|
|
|
|
y_min = verts[i].y;
|
|
|
|
|
|
|
|
if (verts[i].y > y_max)
|
|
|
|
y_max = verts[i].y;
|
|
|
|
}
|
|
|
|
|
|
|
|
stage = CLUTTER_STAGE (clutter_actor_get_stage (self));
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
clutter_stage_get_perspective (stage, &perspective);
|
2008-08-01 12:23:57 +00:00
|
|
|
|
|
|
|
/* Convert the coordinates back to [-1,1] range */
|
|
|
|
cogl_get_viewport (viewport);
|
2008-12-19 13:42:17 +00:00
|
|
|
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
tx_min = (CLUTTER_UNITS_TO_FLOAT (x_min) / viewport[2])
|
2009-01-20 16:20:54 +00:00
|
|
|
* 2 - 1.0;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
tx_max = (CLUTTER_UNITS_TO_FLOAT (x_max) / viewport[2])
|
2009-01-20 16:20:54 +00:00
|
|
|
* 2 - 1.0;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
ty_min = (CLUTTER_UNITS_TO_FLOAT (y_min) / viewport[3])
|
2009-01-20 16:20:54 +00:00
|
|
|
* 2 - 1.0;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
ty_max = (CLUTTER_UNITS_TO_FLOAT (y_max) / viewport[3])
|
2009-01-20 16:20:54 +00:00
|
|
|
* 2 - 1.0;
|
2008-08-01 12:23:57 +00:00
|
|
|
|
|
|
|
/* Set up a projection matrix so that the actor will be projected as
|
|
|
|
if it was drawn at its original location */
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
tan_angle = tanf ((perspective.fovy / 2) * (G_PI / 180.0));
|
|
|
|
near_size = perspective.z_near * tan_angle;
|
|
|
|
|
|
|
|
cogl_frustum ((tx_min * near_size),
|
|
|
|
(tx_max * near_size),
|
|
|
|
(-ty_min * near_size),
|
|
|
|
(-ty_max * near_size),
|
|
|
|
perspective.z_near,
|
|
|
|
perspective.z_far);
|
2008-08-01 12:23:57 +00:00
|
|
|
}
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
static void
|
2006-06-13 13:17:45 +00:00
|
|
|
clutter_texture_paint (ClutterActor *self)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2007-03-19 10:00:38 +00:00
|
|
|
ClutterTexture *texture = CLUTTER_TEXTURE (self);
|
2007-07-26 11:04:04 +00:00
|
|
|
ClutterTexturePrivate *priv = texture->priv;
|
|
|
|
gint x_1, y_1, x_2, y_2;
|
2008-10-30 16:50:07 +00:00
|
|
|
CoglColor transparent_col;
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
gfloat t_w, t_h;
|
2009-02-19 15:44:16 +00:00
|
|
|
guint8 paint_opacity = clutter_actor_get_paint_opacity (self);
|
|
|
|
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
if (paint_opacity == 0)
|
2009-02-19 15:44:16 +00:00
|
|
|
{
|
|
|
|
/* Bail early if painting the actor would be a no-op, custom actors that
|
|
|
|
* might cause a lot of work/state changes should all do this.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2007-07-23 17:02:52 +00:00
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (CLUTTER_ACTOR(texture)))
|
|
|
|
clutter_actor_realize (CLUTTER_ACTOR(texture));
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->fbo_handle != COGL_INVALID_HANDLE)
|
2008-02-01 15:29:00 +00:00
|
|
|
{
|
2008-02-04 11:45:12 +00:00
|
|
|
ClutterMainContext *context;
|
2008-02-08 10:37:38 +00:00
|
|
|
ClutterShader *shader = NULL;
|
2008-08-01 12:23:57 +00:00
|
|
|
ClutterActor *stage = NULL;
|
|
|
|
ClutterPerspective perspective;
|
2008-02-04 11:45:12 +00:00
|
|
|
|
|
|
|
context = clutter_context_get_default ();
|
|
|
|
|
2008-02-08 10:37:38 +00:00
|
|
|
if (context->shaders)
|
|
|
|
shader = clutter_actor_get_shader (context->shaders->data);
|
|
|
|
|
2008-02-04 11:45:12 +00:00
|
|
|
/* Temporarily turn of the shader on the top of the context's
|
|
|
|
* shader stack, to restore the GL pipeline to it's natural state.
|
|
|
|
*/
|
2008-02-08 10:37:38 +00:00
|
|
|
if (shader)
|
|
|
|
clutter_shader_set_is_enabled (shader, FALSE);
|
2008-02-04 11:45:12 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Redirect drawing to the fbo */
|
2009-04-30 21:19:43 +00:00
|
|
|
cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->fbo_handle);
|
2008-04-25 13:37:36 +00:00
|
|
|
|
2008-08-01 12:23:57 +00:00
|
|
|
if ((stage = clutter_actor_get_stage (self)))
|
|
|
|
{
|
|
|
|
guint stage_width, stage_height;
|
|
|
|
ClutterActor *source_parent;
|
|
|
|
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
clutter_stage_get_perspective (CLUTTER_STAGE (stage), &perspective);
|
2008-08-01 12:23:57 +00:00
|
|
|
clutter_actor_get_size (stage, &stage_width, &stage_height);
|
|
|
|
|
|
|
|
/* Use below to set the modelview matrix as if the viewport
|
|
|
|
was still the same size as the stage */
|
|
|
|
cogl_setup_viewport (stage_width, stage_height,
|
|
|
|
perspective.fovy,
|
|
|
|
perspective.aspect,
|
|
|
|
perspective.z_near,
|
|
|
|
perspective.z_far);
|
|
|
|
/* Use a projection matrix that makes the actor appear as it
|
|
|
|
would if it was rendered at its normal screen location */
|
|
|
|
clutter_texture_set_fbo_projection (self);
|
|
|
|
/* Reset the viewport to the size of the FBO */
|
|
|
|
cogl_viewport (priv->width, priv->height);
|
|
|
|
/* Reapply the source's parent transformations */
|
|
|
|
if ((source_parent = clutter_actor_get_parent (priv->fbo_source)))
|
|
|
|
_clutter_actor_apply_modelview_transform_recursive (source_parent,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2009-02-12 13:23:20 +00:00
|
|
|
/* cogl_clear is called to clear the buffers */
|
2008-10-30 16:50:07 +00:00
|
|
|
cogl_color_set_from_4ub (&transparent_col, 0, 0, 0, 0);
|
2009-04-24 17:09:52 +00:00
|
|
|
cogl_clear (&transparent_col,
|
|
|
|
COGL_BUFFER_BIT_COLOR |
|
2009-05-12 14:36:16 +00:00
|
|
|
COGL_BUFFER_BIT_DEPTH);
|
2009-02-12 13:23:20 +00:00
|
|
|
cogl_disable_fog ();
|
2008-02-08 10:37:38 +00:00
|
|
|
|
2008-08-01 12:23:57 +00:00
|
|
|
/* Clear the clipping stack so that if the FBO actor is being
|
|
|
|
clipped then it won't affect drawing the source */
|
|
|
|
cogl_clip_stack_save ();
|
|
|
|
|
2008-02-08 10:37:38 +00:00
|
|
|
/* Render out actor scene to fbo */
|
2008-02-01 15:29:00 +00:00
|
|
|
clutter_actor_paint (priv->fbo_source);
|
2008-02-08 10:37:38 +00:00
|
|
|
|
2008-08-01 12:23:57 +00:00
|
|
|
cogl_clip_stack_restore ();
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Restore drawing to the frame buffer */
|
2009-04-30 21:19:43 +00:00
|
|
|
cogl_set_draw_buffer (COGL_WINDOW_BUFFER, COGL_INVALID_HANDLE);
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-08-01 12:23:57 +00:00
|
|
|
/* Restore the perspective matrix using cogl_perspective so that
|
|
|
|
the inverse matrix will be right */
|
2008-12-19 13:42:17 +00:00
|
|
|
cogl_perspective (perspective.fovy,
|
|
|
|
perspective.aspect,
|
|
|
|
perspective.z_near,
|
|
|
|
perspective.z_far);
|
2008-08-01 12:23:57 +00:00
|
|
|
|
2008-02-04 11:45:12 +00:00
|
|
|
/* If there is a shader on top of the shader stack, turn it back on. */
|
2008-02-08 10:37:38 +00:00
|
|
|
if (shader)
|
|
|
|
clutter_shader_set_is_enabled (shader, TRUE);
|
|
|
|
}
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-11-07 16:31:56 +00:00
|
|
|
/* A clone may need to fire above if were a TFP/FBO but not visible.
|
|
|
|
* Ultimatly needs some reworking with maybe an extra prepare_paint
|
|
|
|
* method or some such.
|
|
|
|
*/
|
|
|
|
if (CLUTTER_PRIVATE_FLAGS(self) & CLUTTER_TEXTURE_IN_CLONE_PAINT)
|
|
|
|
return;
|
|
|
|
|
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 21:27:53 +00:00
|
|
|
CLUTTER_NOTE (PAINT,
|
2007-04-27 21:13:06 +00:00
|
|
|
"painting texture '%s'",
|
2006-11-22 20:52:27 +00:00
|
|
|
clutter_actor_get_name (self) ? clutter_actor_get_name (self)
|
2007-03-19 10:00:38 +00:00
|
|
|
: "unknown");
|
2008-10-30 16:50:07 +00:00
|
|
|
|
2009-02-19 15:44:16 +00:00
|
|
|
cogl_material_set_color4ub (priv->material, 0xff, 0xff, 0xff, paint_opacity);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
clutter_actor_get_allocation_coords (self, &x_1, &y_1, &x_2, &y_2);
|
2007-04-27 21:13:06 +00:00
|
|
|
|
|
|
|
CLUTTER_NOTE (PAINT, "paint to x1: %i, y1: %i x2: %i, y2: %i "
|
2007-07-26 11:04:04 +00:00
|
|
|
"opacity: %i",
|
|
|
|
x_1, y_1, x_2, y_2,
|
2007-04-27 21:13:06 +00:00
|
|
|
clutter_actor_get_opacity (self));
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->repeat_x && priv->width > 0)
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
t_w = (float) (x_2 - x_1) / (float) (priv->width);
|
2008-04-25 13:37:36 +00:00
|
|
|
else
|
2009-01-20 16:20:54 +00:00
|
|
|
t_w = 1.0;
|
2008-10-30 16:37:55 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->repeat_y && priv->height > 0)
|
[stage] Coalesce fog and perspective API
The fog and perspective API is currently split in two parts:
- the floating point version, using values
- the fixed point version, using structures
The relative properties are using the structure types, since they
are meant to set multiple values at the same time. Instead of
using bare values, the whole API should be coalesced into two
simple calls using structures to match the GObject properties.
Thus:
clutter_stage_set_fog (ClutterStage*, const ClutterFog*)
clutter_stage_get_fog (ClutterStage*, ClutterFog*)
clutter_stage_set_perspective (ClutterStage*, const ClutterPerspective*)
clutter_stage_get_perspective (ClutterStage*, ClutterPerspective*)
Which supercedes the fixed point and floating point variants.
More importantly, both ClutterFog and ClutterPerspective should
using floating point values, since that's what get passed to
COGL anyway.
ClutterFog should also drop the "density" member, since ClutterStage
only allows linear fog; non-linear fog distribution can be achieved
using a signal handler and calling cogl_set_fog() directly; this keeps
the API compact yet extensible.
Finally, there is no ClutterStage:fog so it should be added.
2009-03-09 17:24:44 +00:00
|
|
|
t_h = (float) (y_2 - y_1) / (float) (priv->height);
|
2008-04-25 13:37:36 +00:00
|
|
|
else
|
2009-01-20 16:20:54 +00:00
|
|
|
t_h = 1.0;
|
2008-04-25 13:37:36 +00:00
|
|
|
|
|
|
|
/* Paint will have translated us */
|
2008-12-23 16:39:11 +00:00
|
|
|
cogl_set_source (priv->material);
|
Fully integrates CoglMaterial throughout the rest of Cogl
This glues CoglMaterial in as the fundamental way that Cogl describes how to
fill in geometry.
It adds cogl_set_source (), which is used to set the material which will be
used by all subsequent drawing functions
It adds cogl_set_source_texture as a convenience for setting up a default
material with a single texture layer, and cogl_set_source_color is now also
a convenience for setting up a material with a solid fill.
"drawing functions" include, cogl_rectangle, cogl_texture_rectangle,
cogl_texture_multiple_rectangles, cogl_texture_polygon (though the
cogl_texture_* funcs have been renamed; see below for details),
cogl_path_fill/stroke and cogl_vertex_buffer_draw*.
cogl_texture_rectangle, cogl_texture_multiple_rectangles and
cogl_texture_polygon no longer take a texture handle; instead the current
source material is referenced. The functions have also been renamed to:
cogl_rectangle_with_texture_coords, cogl_rectangles_with_texture_coords
and cogl_polygon respectivly.
Most code that previously did:
cogl_texture_rectangle (tex_handle, x, y,...);
needs to be changed to now do:
cogl_set_source_texture (tex_handle);
cogl_rectangle_with_texture_coords (x, y,....);
In the less likely case where you were blending your source texture with a color
like:
cogl_set_source_color4ub (r,g,b,a); /* where r,g,b,a isn't just white */
cogl_texture_rectangle (tex_handle, x, y,...);
you will need your own material to do that:
mat = cogl_material_new ();
cogl_material_set_color4ub (r,g,b,a);
cogl_material_set_layer (mat, 0, tex_handle));
cogl_set_source_material (mat);
Code that uses the texture coordinates, 0, 0, 1, 1 don't need to use
cog_rectangle_with_texure_coords since these are the coordinates that
cogl_rectangle will use.
For cogl_texture_polygon; as well as dropping the texture handle, the
n_vertices and vertices arguments were transposed for consistency. So
code previously written as:
cogl_texture_polygon (tex_handle, 3, verts, TRUE);
need to be written as:
cogl_set_source_texture (tex_handle);
cogl_polygon (verts, 3, TRUE);
All of the unit tests have been updated to now use the material API and
test-cogl-material has been renamed to test-cogl-multitexture since any
textured quad is now technically a test of CoglMaterial but this test
specifically creates a material with multiple texture layers.
Note: The GLES backend has not been updated yet; that will be done in a
following commit.
2009-01-23 16:15:40 +00:00
|
|
|
cogl_rectangle_with_texture_coords (0, 0,
|
|
|
|
(float) (x_2 - x_1),
|
|
|
|
(float) (y_2 - y_1),
|
|
|
|
0, 0, t_w, t_h);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
static void
|
|
|
|
clutter_texture_async_data_free (ClutterTextureAsyncData *data)
|
|
|
|
{
|
|
|
|
/* This function should only be called either from the main thread
|
|
|
|
once it is known that the load thread has completed or from the
|
|
|
|
load thread itself if the abort flag is true (in which case the
|
|
|
|
main thread has disowned the data) */
|
|
|
|
|
|
|
|
if (data->load_filename)
|
|
|
|
g_free (data->load_filename);
|
|
|
|
|
|
|
|
if (data->load_bitmap)
|
2009-04-30 17:00:22 +00:00
|
|
|
cogl_handle_unref (data->load_bitmap);
|
2009-02-25 17:10:54 +00:00
|
|
|
|
|
|
|
if (data->load_error)
|
|
|
|
g_error_free (data->load_error);
|
|
|
|
|
|
|
|
if (data->mutex)
|
|
|
|
g_mutex_free (data->mutex);
|
|
|
|
|
|
|
|
g_slice_free (ClutterTextureAsyncData, data);
|
|
|
|
}
|
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
/*
|
|
|
|
* clutter_texture_async_load_cancel:
|
|
|
|
* @texture: a #ClutterTexture
|
|
|
|
*
|
|
|
|
* Cancels an asynchronous loading operation, whether done
|
|
|
|
* with threads enabled or just using the main loop
|
|
|
|
*/
|
2009-01-07 17:02:43 +00:00
|
|
|
static void
|
2009-01-12 16:54:30 +00:00
|
|
|
clutter_texture_async_load_cancel (ClutterTexture *texture)
|
2009-01-07 17:02:43 +00:00
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv = texture->priv;
|
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
if (priv->async_data)
|
2009-01-07 17:02:43 +00:00
|
|
|
{
|
2009-02-25 17:10:54 +00:00
|
|
|
GMutex *mutex = priv->async_data->mutex;
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
/* The mutex will only be NULL if the no thread was used for
|
|
|
|
this load, in which case there's no need for any
|
|
|
|
synchronization */
|
|
|
|
if (mutex)
|
|
|
|
g_mutex_lock (mutex);
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
/* If there is no thread behind this load then we can just abort
|
|
|
|
the idle handler and destroy the load data immediately */
|
|
|
|
if (priv->async_data->load_idle)
|
|
|
|
{
|
|
|
|
g_source_remove (priv->async_data->load_idle);
|
|
|
|
priv->async_data->load_idle = 0;
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
if (mutex)
|
|
|
|
g_mutex_unlock (mutex);
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_async_data_free (priv->async_data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Otherwise we need to tell the thread to abort and disown
|
|
|
|
the data */
|
|
|
|
priv->async_data->abort = TRUE;
|
|
|
|
|
|
|
|
if (mutex)
|
|
|
|
g_mutex_unlock (mutex);
|
|
|
|
}
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
priv->async_data = NULL;
|
|
|
|
}
|
2009-01-07 17:02:43 +00:00
|
|
|
}
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
static void
|
2006-05-29 08:59:36 +00:00
|
|
|
clutter_texture_dispose (GObject *object)
|
|
|
|
{
|
2007-07-26 11:04:04 +00:00
|
|
|
ClutterTexture *texture = CLUTTER_TEXTURE (object);
|
2006-05-29 08:59:36 +00:00
|
|
|
ClutterTexturePrivate *priv;
|
|
|
|
|
2006-09-19 19:27:16 +00:00
|
|
|
priv = texture->priv;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-06-13 14:58:18 +00:00
|
|
|
/* mark that we are in dispose, so when the parent class'
|
|
|
|
* dispose implementation will call unrealize on us we'll
|
|
|
|
* not try to copy back the resources from video memory
|
|
|
|
* to system memory
|
|
|
|
*/
|
|
|
|
if (!priv->in_dispose)
|
|
|
|
priv->in_dispose = TRUE;
|
|
|
|
|
2007-07-24 17:38:35 +00:00
|
|
|
texture_free_gl_resources (texture);
|
2008-02-03 23:25:12 +00:00
|
|
|
texture_fbo_free_resources (texture);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->local_data != NULL)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
g_free (priv->local_data);
|
|
|
|
priv->local_data = NULL;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
2009-02-05 20:24:18 +00:00
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
clutter_texture_async_load_cancel (texture);
|
2009-02-05 18:27:04 +00:00
|
|
|
|
2009-02-05 20:24:18 +00:00
|
|
|
G_OBJECT_CLASS (clutter_texture_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_texture_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
ClutterTexture *texture = CLUTTER_TEXTURE (object);
|
2009-02-05 23:01:59 +00:00
|
|
|
ClutterTexturePrivate *priv = texture->priv;
|
2009-02-05 20:24:18 +00:00
|
|
|
|
2009-02-05 18:27:04 +00:00
|
|
|
if (priv->material != COGL_INVALID_HANDLE)
|
|
|
|
{
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_unref (priv->material);
|
2009-02-05 18:27:04 +00:00
|
|
|
priv->material = COGL_INVALID_HANDLE;
|
|
|
|
}
|
2009-02-05 20:24:18 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (clutter_texture_parent_class)->finalize (object);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-10-12 08:17:00 +00:00
|
|
|
clutter_texture_set_property (GObject *object,
|
2006-05-29 08:59:36 +00:00
|
|
|
guint prop_id,
|
2007-10-12 08:17:00 +00:00
|
|
|
const GValue *value,
|
2006-05-29 08:59:36 +00:00
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterTexture *texture;
|
|
|
|
ClutterTexturePrivate *priv;
|
|
|
|
|
|
|
|
texture = CLUTTER_TEXTURE(object);
|
|
|
|
priv = texture->priv;
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
switch (prop_id)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
|
|
|
case PROP_MAX_TILE_WASTE:
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_set_max_tile_waste (texture,
|
|
|
|
g_value_get_int (value));
|
2006-05-29 08:59:36 +00:00
|
|
|
break;
|
|
|
|
case PROP_SYNC_SIZE:
|
2006-06-13 13:17:45 +00:00
|
|
|
priv->sync_actor_size = g_value_get_boolean (value);
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
clutter_actor_queue_relayout (CLUTTER_ACTOR (texture));
|
2006-05-29 08:59:36 +00:00
|
|
|
break;
|
|
|
|
case PROP_REPEAT_X:
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->repeat_x != g_value_get_boolean (value))
|
|
|
|
{
|
|
|
|
priv->repeat_x = !priv->repeat_x;
|
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
break;
|
|
|
|
case PROP_REPEAT_Y:
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->repeat_y != g_value_get_boolean (value))
|
|
|
|
{
|
|
|
|
priv->repeat_y = !priv->repeat_y;
|
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
break;
|
2006-06-06 20:40:40 +00:00
|
|
|
case PROP_FILTER_QUALITY:
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_set_filter_quality (texture,
|
2008-06-07 15:08:05 +00:00
|
|
|
g_value_get_enum (value));
|
2008-04-25 13:37:36 +00:00
|
|
|
break;
|
|
|
|
case PROP_COGL_TEXTURE:
|
|
|
|
clutter_texture_set_cogl_texture
|
|
|
|
(texture, (CoglHandle) g_value_get_boxed (value));
|
|
|
|
break;
|
2009-01-26 15:25:55 +00:00
|
|
|
#if EXPOSE_COGL_MATERIAL_PROP
|
Fully integrates CoglMaterial throughout the rest of Cogl
This glues CoglMaterial in as the fundamental way that Cogl describes how to
fill in geometry.
It adds cogl_set_source (), which is used to set the material which will be
used by all subsequent drawing functions
It adds cogl_set_source_texture as a convenience for setting up a default
material with a single texture layer, and cogl_set_source_color is now also
a convenience for setting up a material with a solid fill.
"drawing functions" include, cogl_rectangle, cogl_texture_rectangle,
cogl_texture_multiple_rectangles, cogl_texture_polygon (though the
cogl_texture_* funcs have been renamed; see below for details),
cogl_path_fill/stroke and cogl_vertex_buffer_draw*.
cogl_texture_rectangle, cogl_texture_multiple_rectangles and
cogl_texture_polygon no longer take a texture handle; instead the current
source material is referenced. The functions have also been renamed to:
cogl_rectangle_with_texture_coords, cogl_rectangles_with_texture_coords
and cogl_polygon respectivly.
Most code that previously did:
cogl_texture_rectangle (tex_handle, x, y,...);
needs to be changed to now do:
cogl_set_source_texture (tex_handle);
cogl_rectangle_with_texture_coords (x, y,....);
In the less likely case where you were blending your source texture with a color
like:
cogl_set_source_color4ub (r,g,b,a); /* where r,g,b,a isn't just white */
cogl_texture_rectangle (tex_handle, x, y,...);
you will need your own material to do that:
mat = cogl_material_new ();
cogl_material_set_color4ub (r,g,b,a);
cogl_material_set_layer (mat, 0, tex_handle));
cogl_set_source_material (mat);
Code that uses the texture coordinates, 0, 0, 1, 1 don't need to use
cog_rectangle_with_texure_coords since these are the coordinates that
cogl_rectangle will use.
For cogl_texture_polygon; as well as dropping the texture handle, the
n_vertices and vertices arguments were transposed for consistency. So
code previously written as:
cogl_texture_polygon (tex_handle, 3, verts, TRUE);
need to be written as:
cogl_set_source_texture (tex_handle);
cogl_polygon (verts, 3, TRUE);
All of the unit tests have been updated to now use the material API and
test-cogl-material has been renamed to test-cogl-multitexture since any
textured quad is now technically a test of CoglMaterial but this test
specifically creates a material with multiple texture layers.
Note: The GLES backend has not been updated yet; that will be done in a
following commit.
2009-01-23 16:15:40 +00:00
|
|
|
case PROP_COGL_MATERIAL:
|
2008-12-23 16:39:11 +00:00
|
|
|
clutter_texture_set_cogl_material
|
|
|
|
(texture, (CoglHandle) g_value_get_boxed (value));
|
|
|
|
break;
|
|
|
|
#endif
|
2008-04-25 13:37:36 +00:00
|
|
|
case PROP_FILENAME:
|
|
|
|
clutter_texture_set_from_file (texture,
|
|
|
|
g_value_get_string (value),
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
case PROP_NO_SLICE:
|
|
|
|
priv->no_slice = g_value_get_boolean (value);
|
2006-06-06 20:40:40 +00:00
|
|
|
break;
|
2008-06-23 15:31:12 +00:00
|
|
|
case PROP_KEEP_ASPECT_RATIO:
|
|
|
|
priv->keep_aspect_ratio = g_value_get_boolean (value);
|
2009-03-30 16:32:54 +00:00
|
|
|
clutter_actor_queue_relayout (CLUTTER_ACTOR (object));
|
2008-06-23 15:31:12 +00:00
|
|
|
break;
|
2009-03-11 18:26:30 +00:00
|
|
|
case PROP_LOAD_DATA_ASYNC:
|
2009-03-12 10:14:40 +00:00
|
|
|
if (g_value_get_boolean (value))
|
|
|
|
{
|
|
|
|
priv->load_async_set = TRUE;
|
|
|
|
priv->load_data_async = TRUE;
|
|
|
|
}
|
2009-03-11 18:26:30 +00:00
|
|
|
break;
|
2009-01-07 17:02:43 +00:00
|
|
|
case PROP_LOAD_ASYNC:
|
2009-03-12 10:14:40 +00:00
|
|
|
if (g_value_get_boolean (value))
|
|
|
|
{
|
2009-03-12 10:38:39 +00:00
|
|
|
priv->load_data_async = TRUE;
|
2009-03-12 10:14:40 +00:00
|
|
|
priv->load_async_set = TRUE;
|
|
|
|
priv->load_size_async = TRUE;
|
|
|
|
}
|
2009-01-07 17:02:43 +00:00
|
|
|
break;
|
2006-05-29 08:59:36 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-10-12 08:17:00 +00:00
|
|
|
clutter_texture_get_property (GObject *object,
|
2006-05-29 08:59:36 +00:00
|
|
|
guint prop_id,
|
2007-10-12 08:17:00 +00:00
|
|
|
GValue *value,
|
2006-05-29 08:59:36 +00:00
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterTexture *texture;
|
|
|
|
ClutterTexturePrivate *priv;
|
2008-12-23 16:39:11 +00:00
|
|
|
CoglHandle cogl_texture;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
texture = CLUTTER_TEXTURE(object);
|
|
|
|
priv = texture->priv;
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
switch (prop_id)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
|
|
|
case PROP_MAX_TILE_WASTE:
|
2008-04-25 13:37:36 +00:00
|
|
|
g_value_set_int (value, clutter_texture_get_max_tile_waste (texture));
|
2006-05-29 08:59:36 +00:00
|
|
|
break;
|
|
|
|
case PROP_PIXEL_FORMAT:
|
2008-12-23 16:39:11 +00:00
|
|
|
cogl_texture = clutter_texture_get_cogl_texture (texture);
|
|
|
|
if (cogl_texture == COGL_INVALID_HANDLE)
|
2008-04-25 13:37:36 +00:00
|
|
|
g_value_set_int (value, COGL_PIXEL_FORMAT_ANY);
|
|
|
|
else
|
2008-12-23 16:39:11 +00:00
|
|
|
g_value_set_int (value, cogl_texture_get_format (cogl_texture));
|
2006-05-29 08:59:36 +00:00
|
|
|
break;
|
|
|
|
case PROP_SYNC_SIZE:
|
2006-06-13 13:17:45 +00:00
|
|
|
g_value_set_boolean (value, priv->sync_actor_size);
|
2006-05-29 08:59:36 +00:00
|
|
|
break;
|
|
|
|
case PROP_REPEAT_X:
|
|
|
|
g_value_set_boolean (value, priv->repeat_x);
|
|
|
|
break;
|
|
|
|
case PROP_REPEAT_Y:
|
|
|
|
g_value_set_boolean (value, priv->repeat_y);
|
|
|
|
break;
|
2006-06-06 20:40:40 +00:00
|
|
|
case PROP_FILTER_QUALITY:
|
2008-06-07 15:08:05 +00:00
|
|
|
g_value_set_enum (value, clutter_texture_get_filter_quality (texture));
|
2008-04-25 13:37:36 +00:00
|
|
|
break;
|
|
|
|
case PROP_COGL_TEXTURE:
|
|
|
|
g_value_set_boxed (value, clutter_texture_get_cogl_texture (texture));
|
|
|
|
break;
|
2008-12-23 16:39:11 +00:00
|
|
|
case PROP_COGL_MATERIAL:
|
|
|
|
g_value_set_boxed (value, clutter_texture_get_cogl_material (texture));
|
|
|
|
break;
|
2008-04-25 13:37:36 +00:00
|
|
|
case PROP_NO_SLICE:
|
|
|
|
g_value_set_boolean (value, priv->no_slice);
|
2006-06-06 20:40:40 +00:00
|
|
|
break;
|
2008-06-23 15:31:12 +00:00
|
|
|
case PROP_KEEP_ASPECT_RATIO:
|
|
|
|
g_value_set_boolean (value, priv->keep_aspect_ratio);
|
|
|
|
break;
|
2006-05-29 08:59:36 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
2007-10-12 08:17:00 +00:00
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_texture_class_init (ClutterTextureClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
2006-06-13 13:17:45 +00:00
|
|
|
ClutterActorClass *actor_class;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2007-07-24 17:38:35 +00:00
|
|
|
gobject_class = (GObjectClass*) klass;
|
|
|
|
actor_class = (ClutterActorClass*) klass;
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (ClutterTexturePrivate));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2007-11-15 17:38:40 +00:00
|
|
|
actor_class->paint = clutter_texture_paint;
|
|
|
|
actor_class->realize = clutter_texture_realize;
|
|
|
|
actor_class->unrealize = clutter_texture_unrealize;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
|
2008-07-04 10:44:18 +00:00
|
|
|
actor_class->get_preferred_width = clutter_texture_get_preferred_width;
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
actor_class->get_preferred_height = clutter_texture_get_preferred_height;
|
2008-07-04 10:44:18 +00:00
|
|
|
actor_class->allocate = clutter_texture_allocate;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
gobject_class->dispose = clutter_texture_dispose;
|
2009-02-05 20:24:18 +00:00
|
|
|
gobject_class->finalize = clutter_texture_finalize;
|
2006-05-29 08:59:36 +00:00
|
|
|
gobject_class->set_property = clutter_texture_set_property;
|
|
|
|
gobject_class->get_property = clutter_texture_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_SYNC_SIZE,
|
|
|
|
g_param_spec_boolean ("sync-size",
|
2006-06-13 13:17:45 +00:00
|
|
|
"Sync size of actor",
|
2008-02-15 15:49:44 +00:00
|
|
|
"Auto sync size of actor to underlying pixbuf "
|
|
|
|
"dimensions",
|
2006-05-29 08:59:36 +00:00
|
|
|
TRUE,
|
2007-11-15 17:38:40 +00:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_NO_SLICE,
|
|
|
|
g_param_spec_boolean ("disable-slicing",
|
|
|
|
"Disable Slicing",
|
|
|
|
"Force the underlying texture to be singlular"
|
|
|
|
"and not made of of smaller space saving "
|
|
|
|
"inidivual textures.",
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_CONSTRUCT_ONLY | CLUTTER_PARAM_READWRITE));
|
|
|
|
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_REPEAT_X,
|
|
|
|
g_param_spec_boolean ("repeat-x",
|
|
|
|
"Tile underlying pixbuf in x direction",
|
2008-04-25 13:37:36 +00:00
|
|
|
"Repeat underlying pixbuf rather than scale "
|
|
|
|
"in x direction.",
|
2006-05-29 08:59:36 +00:00
|
|
|
FALSE,
|
2007-11-15 17:38:40 +00:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_REPEAT_Y,
|
|
|
|
g_param_spec_boolean ("repeat-y",
|
|
|
|
"Tile underlying pixbuf in y direction",
|
2008-04-25 13:37:36 +00:00
|
|
|
"Repeat underlying pixbuf rather than scale "
|
|
|
|
"in y direction.",
|
2006-05-29 08:59:36 +00:00
|
|
|
FALSE,
|
2007-11-15 17:38:40 +00:00
|
|
|
CLUTTER_PARAM_READWRITE));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2006-06-06 20:40:40 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_FILTER_QUALITY,
|
2008-06-07 15:08:05 +00:00
|
|
|
g_param_spec_enum ("filter-quality",
|
|
|
|
"Filter Quality",
|
|
|
|
"Rendering quality used when drawing the texture.",
|
|
|
|
CLUTTER_TYPE_TEXTURE_QUALITY,
|
|
|
|
CLUTTER_TEXTURE_QUALITY_MEDIUM,
|
|
|
|
G_PARAM_CONSTRUCT | CLUTTER_PARAM_READWRITE));
|
2006-06-06 20:40:40 +00:00
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_MAX_TILE_WASTE,
|
|
|
|
g_param_spec_int ("tile-waste",
|
2008-02-15 15:49:44 +00:00
|
|
|
"Tile dimension to waste",
|
|
|
|
"Max wastage dimension of a texture when using "
|
2008-04-25 13:37:36 +00:00
|
|
|
"sliced textures or -1 to disable slicing. "
|
|
|
|
"Bigger values use less textures, "
|
2008-02-15 15:49:44 +00:00
|
|
|
"smaller values less texture memory.",
|
2008-04-25 13:37:36 +00:00
|
|
|
-1,
|
2006-05-29 08:59:36 +00:00
|
|
|
G_MAXINT,
|
2009-01-11 00:25:27 +00:00
|
|
|
63,
|
2006-12-04 16:26:35 +00:00
|
|
|
G_PARAM_CONSTRUCT_ONLY | CLUTTER_PARAM_READWRITE));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_PIXEL_FORMAT,
|
|
|
|
g_param_spec_int ("pixel-format",
|
|
|
|
"Texture pixel format",
|
2008-04-25 13:37:36 +00:00
|
|
|
"CoglPixelFormat to use.",
|
2006-05-29 08:59:36 +00:00
|
|
|
0,
|
|
|
|
G_MAXINT,
|
2008-04-25 13:37:36 +00:00
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888,
|
2007-05-25 10:56:09 +00:00
|
|
|
G_PARAM_READABLE));
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_COGL_TEXTURE,
|
|
|
|
g_param_spec_boxed ("cogl-texture",
|
|
|
|
"COGL Texture",
|
|
|
|
"The underlying COGL texture handle used to draw "
|
|
|
|
"this actor",
|
2009-02-19 12:05:20 +00:00
|
|
|
COGL_TYPE_HANDLE,
|
2008-04-25 13:37:36 +00:00
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_COGL_MATERIAL,
|
|
|
|
g_param_spec_boxed ("cogl-material",
|
|
|
|
"COGL Material",
|
|
|
|
"The underlying COGL material handle used to draw "
|
|
|
|
"this actor",
|
2009-02-19 12:05:20 +00:00
|
|
|
COGL_TYPE_HANDLE,
|
2008-12-23 16:39:11 +00:00
|
|
|
G_PARAM_READWRITE));
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_FILENAME,
|
|
|
|
g_param_spec_string ("filename",
|
|
|
|
"Filename",
|
|
|
|
"The full path of the file containing the texture",
|
|
|
|
NULL,
|
|
|
|
G_PARAM_WRITABLE));
|
|
|
|
|
2008-06-23 15:31:12 +00:00
|
|
|
g_object_class_install_property
|
|
|
|
(gobject_class, PROP_KEEP_ASPECT_RATIO,
|
|
|
|
g_param_spec_boolean ("keep-aspect-ratio",
|
|
|
|
"Keep Aspect Ratio",
|
|
|
|
"Keep the aspect ratio of the texture when "
|
|
|
|
"requesting the preferred width or height",
|
|
|
|
FALSE,
|
|
|
|
CLUTTER_PARAM_READWRITE));
|
|
|
|
|
2009-03-12 10:14:40 +00:00
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
/**
|
2009-03-12 11:48:44 +00:00
|
|
|
* ClutterTexture:load-async:
|
2009-01-12 16:54:30 +00:00
|
|
|
*
|
2009-03-12 11:48:44 +00:00
|
|
|
* Tries to load a texture from a filename by using a local thread to perform
|
|
|
|
* the read operations. The initially created texture has dimensions 0x0 when
|
2009-03-12 11:48:44 +00:00
|
|
|
* the true size becomes available the #ClutterTexture::size-change signal is
|
2009-03-12 11:48:44 +00:00
|
|
|
* emitted and when the image has completed loading the
|
2009-03-12 11:48:44 +00:00
|
|
|
* #ClutterTexture::load-finished signal is emitted.
|
2009-01-12 16:54:30 +00:00
|
|
|
*
|
2009-03-12 11:48:44 +00:00
|
|
|
* Threading is only enabled if g_thread_init() has been called prior to
|
|
|
|
* clutter_init(), otherwise #ClutterTexture will use the main loop to load
|
|
|
|
* the image.
|
|
|
|
*
|
|
|
|
* The upload of the texture data on the GL pipeline is not asynchronous, as
|
|
|
|
* it must be performed from within the same thread that called
|
|
|
|
* clutter_main().
|
2009-01-12 16:54:30 +00:00
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
2009-03-11 18:26:30 +00:00
|
|
|
g_object_class_install_property
|
2009-03-12 11:48:44 +00:00
|
|
|
(gobject_class, PROP_LOAD_ASYNC,
|
|
|
|
g_param_spec_boolean ("load-async",
|
|
|
|
"Load asynchronously",
|
2009-03-11 18:26:30 +00:00
|
|
|
"Load files inside a thread to avoid blocking when "
|
|
|
|
"loading images.",
|
|
|
|
FALSE,
|
2009-03-12 10:38:39 +00:00
|
|
|
CLUTTER_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
|
2009-03-11 18:26:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-03-12 11:48:44 +00:00
|
|
|
* ClutterTexture:load-data-async:
|
2009-03-11 18:26:30 +00:00
|
|
|
*
|
2009-03-12 11:48:44 +00:00
|
|
|
* Like #ClutterTexture:load-async but loads the width and height
|
2009-03-12 11:48:44 +00:00
|
|
|
* synchronously causing some blocking.
|
2009-03-11 18:26:30 +00:00
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
2009-01-07 17:02:43 +00:00
|
|
|
g_object_class_install_property
|
2009-03-12 11:48:44 +00:00
|
|
|
(gobject_class, PROP_LOAD_DATA_ASYNC,
|
|
|
|
g_param_spec_boolean ("load-data-async",
|
|
|
|
"Load data asynchronously",
|
|
|
|
"Decode image data files inside a thread to reduce "
|
|
|
|
"blocking when loading images.",
|
2009-01-07 17:02:43 +00:00
|
|
|
FALSE,
|
2009-03-12 10:14:40 +00:00
|
|
|
CLUTTER_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
|
2009-01-07 17:02:43 +00:00
|
|
|
|
2009-03-12 11:48:44 +00:00
|
|
|
|
2009-03-12 11:48:44 +00:00
|
|
|
|
2006-12-13 18:12:09 +00:00
|
|
|
/**
|
|
|
|
* ClutterTexture::size-change:
|
|
|
|
* @texture: the texture which received the signal
|
|
|
|
* @width: the width of the new texture
|
|
|
|
* @height: the height of the new texture
|
|
|
|
*
|
|
|
|
* The ::size-change signal is emitted each time the size of the
|
|
|
|
* pixbuf used by @texture changes. The new size is given as
|
|
|
|
* argument to the callback.
|
|
|
|
*/
|
|
|
|
texture_signals[SIZE_CHANGE] =
|
2006-05-29 08:59:36 +00:00
|
|
|
g_signal_new ("size-change",
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (ClutterTextureClass, size_change),
|
|
|
|
NULL, NULL,
|
|
|
|
clutter_marshal_VOID__INT_INT,
|
2007-10-12 08:17:00 +00:00
|
|
|
G_TYPE_NONE,
|
2006-05-29 08:59:36 +00:00
|
|
|
2, G_TYPE_INT, G_TYPE_INT);
|
2006-12-13 18:12:09 +00:00
|
|
|
/**
|
|
|
|
* ClutterTexture::pixbuf-change:
|
|
|
|
* @texture: the texture which received the signal
|
2007-10-12 08:17:00 +00:00
|
|
|
*
|
2006-12-13 18:12:09 +00:00
|
|
|
* The ::pixbuf-change signal is emitted each time the pixbuf
|
|
|
|
* used by @texture changes.
|
|
|
|
*/
|
|
|
|
texture_signals[PIXBUF_CHANGE] =
|
2006-05-29 08:59:36 +00:00
|
|
|
g_signal_new ("pixbuf-change",
|
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (ClutterTextureClass, pixbuf_change),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID,
|
2007-10-12 08:17:00 +00:00
|
|
|
G_TYPE_NONE,
|
|
|
|
0);
|
2009-01-07 17:02:43 +00:00
|
|
|
/**
|
|
|
|
* ClutterTexture::load-finished:
|
|
|
|
* @texture: the texture which received the signal
|
|
|
|
* @error: A set error, or %NULL
|
|
|
|
*
|
2009-01-12 16:54:30 +00:00
|
|
|
* The ::load-finished signal is emitted when a texture load has
|
|
|
|
* completed. If there was an error during loading, @error will
|
|
|
|
* be set, otherwise it will be %NULL
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
2009-01-07 17:02:43 +00:00
|
|
|
*/
|
|
|
|
texture_signals[LOAD_FINISHED] =
|
2009-01-12 16:54:30 +00:00
|
|
|
g_signal_new (I_("load-finished"),
|
2009-01-07 17:02:43 +00:00
|
|
|
G_TYPE_FROM_CLASS (gobject_class),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
G_STRUCT_OFFSET (ClutterTextureClass, load_finished),
|
|
|
|
NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__POINTER,
|
|
|
|
G_TYPE_NONE,
|
|
|
|
1,
|
|
|
|
G_TYPE_POINTER);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
static ClutterScriptableIface *parent_scriptable_iface = NULL;
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_texture_set_custom_property (ClutterScriptable *scriptable,
|
|
|
|
ClutterScript *script,
|
|
|
|
const gchar *name,
|
|
|
|
const GValue *value)
|
|
|
|
{
|
|
|
|
ClutterTexture *texture = CLUTTER_TEXTURE (scriptable);
|
|
|
|
|
|
|
|
if (strcmp ("filename", name) == 0)
|
|
|
|
{
|
|
|
|
const gchar *str = g_value_get_string (value);
|
|
|
|
gchar *path;
|
|
|
|
GError *error;
|
|
|
|
|
2008-06-24 16:47:43 +00:00
|
|
|
path = clutter_script_lookup_filename (script, str);
|
|
|
|
if (G_UNLIKELY (!path))
|
|
|
|
return;
|
2008-04-25 13:37:36 +00:00
|
|
|
|
|
|
|
error = NULL;
|
|
|
|
clutter_texture_set_from_file (texture, path, &error);
|
|
|
|
if (error)
|
|
|
|
{
|
2009-03-17 14:12:01 +00:00
|
|
|
g_warning ("Unable to open image path at '%s': %s",
|
2008-04-25 13:37:36 +00:00
|
|
|
path,
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* chain up */
|
|
|
|
if (parent_scriptable_iface->set_custom_property)
|
|
|
|
parent_scriptable_iface->set_custom_property (scriptable, script,
|
|
|
|
name,
|
|
|
|
value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_scriptable_iface_init (ClutterScriptableIface *iface)
|
|
|
|
{
|
|
|
|
parent_scriptable_iface = g_type_interface_peek_parent (iface);
|
|
|
|
|
|
|
|
if (!parent_scriptable_iface)
|
2008-12-23 16:29:29 +00:00
|
|
|
parent_scriptable_iface = g_type_default_interface_peek
|
2008-06-10 10:49:21 +00:00
|
|
|
(CLUTTER_TYPE_SCRIPTABLE);
|
2008-04-25 13:37:36 +00:00
|
|
|
|
|
|
|
iface->set_custom_property = clutter_texture_set_custom_property;
|
|
|
|
}
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
static void
|
|
|
|
clutter_texture_init (ClutterTexture *self)
|
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv;
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
self->priv = priv = CLUTTER_TEXTURE_GET_PRIVATE (self);
|
2006-06-08 21:28:05 +00:00
|
|
|
|
2009-01-11 00:25:27 +00:00
|
|
|
priv->max_tile_waste = 63;
|
2008-06-23 15:31:12 +00:00
|
|
|
priv->filter_quality = CLUTTER_TEXTURE_QUALITY_MEDIUM;
|
|
|
|
priv->repeat_x = FALSE;
|
|
|
|
priv->repeat_y = FALSE;
|
|
|
|
priv->sync_actor_size = TRUE;
|
2008-12-23 16:39:11 +00:00
|
|
|
priv->material = cogl_material_new ();
|
2008-06-23 15:31:12 +00:00
|
|
|
priv->fbo_handle = COGL_INVALID_HANDLE;
|
|
|
|
priv->local_data = NULL;
|
|
|
|
priv->keep_aspect_ratio = FALSE;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 19:27:16 +00:00
|
|
|
static void
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_save_to_local_data (ClutterTexture *texture)
|
2008-02-05 14:49:29 +00:00
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv;
|
2008-04-25 13:37:36 +00:00
|
|
|
int bpp;
|
|
|
|
CoglPixelFormat pixel_format;
|
2008-12-23 16:39:11 +00:00
|
|
|
CoglHandle cogl_texture;
|
2008-02-05 14:49:29 +00:00
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->local_data)
|
2008-02-12 17:17:52 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
g_free (priv->local_data);
|
|
|
|
priv->local_data = NULL;
|
2008-02-12 17:17:52 +00:00
|
|
|
}
|
2008-02-25 11:34:51 +00:00
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
if (priv->material == COGL_INVALID_HANDLE)
|
2008-04-25 13:37:36 +00:00
|
|
|
return;
|
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
cogl_texture = clutter_texture_get_cogl_texture (texture);
|
|
|
|
|
|
|
|
priv->local_data_width = cogl_texture_get_width (cogl_texture);
|
|
|
|
priv->local_data_height = cogl_texture_get_height (cogl_texture);
|
|
|
|
pixel_format = cogl_texture_get_format (cogl_texture);
|
2008-04-25 13:37:36 +00:00
|
|
|
priv->local_data_has_alpha = pixel_format & COGL_A_BIT;
|
|
|
|
bpp = priv->local_data_has_alpha ? 4 : 3;
|
2008-06-10 10:49:21 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Align to 4 bytes */
|
|
|
|
priv->local_data_rowstride = (priv->local_data_width * bpp + 3) & ~3;
|
|
|
|
|
|
|
|
/* Store the filter quality and max_tile_waste from the texture
|
|
|
|
properties so that they will be restored the data is loaded
|
|
|
|
again */
|
|
|
|
priv->max_tile_waste = clutter_texture_get_max_tile_waste (texture);
|
|
|
|
priv->filter_quality = clutter_texture_get_filter_quality (texture);
|
|
|
|
|
|
|
|
priv->local_data = g_malloc (priv->local_data_rowstride
|
|
|
|
* priv->local_data_height);
|
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
if (cogl_texture_get_data (cogl_texture,
|
2008-04-25 13:37:36 +00:00
|
|
|
priv->local_data_has_alpha
|
|
|
|
? COGL_PIXEL_FORMAT_RGBA_8888
|
|
|
|
: COGL_PIXEL_FORMAT_RGB_888,
|
|
|
|
priv->local_data_rowstride,
|
|
|
|
priv->local_data) == 0)
|
2008-02-05 14:49:29 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
g_free (priv->local_data);
|
|
|
|
priv->local_data = NULL;
|
2008-02-05 14:49:29 +00:00
|
|
|
}
|
2008-04-25 13:37:36 +00:00
|
|
|
}
|
2008-02-05 14:49:29 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
static void
|
|
|
|
clutter_texture_load_from_local_data (ClutterTexture *texture)
|
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv;
|
2008-02-05 16:40:46 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
priv = texture->priv;
|
2008-02-05 14:49:29 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->local_data == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
clutter_texture_set_from_rgb_data (texture,
|
|
|
|
priv->local_data,
|
|
|
|
priv->local_data_has_alpha,
|
|
|
|
priv->local_data_width,
|
|
|
|
priv->local_data_height,
|
|
|
|
priv->local_data_rowstride,
|
|
|
|
priv->local_data_has_alpha ? 4: 3,
|
|
|
|
0, NULL);
|
2008-12-23 16:29:29 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_free (priv->local_data);
|
|
|
|
priv->local_data = NULL;
|
2008-02-05 14:49:29 +00:00
|
|
|
}
|
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
/**
|
|
|
|
* clutter_texture_get_cogl_material:
|
|
|
|
* @texture: A #ClutterTexture
|
|
|
|
*
|
|
|
|
* Returns a handle to the underlying COGL material used for drawing
|
|
|
|
* the actor. No extra reference is taken so if you need to keep the
|
2009-04-01 16:16:44 +00:00
|
|
|
* handle then you should call cogl_handle_ref() on it.
|
2008-12-23 16:39:11 +00:00
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*
|
|
|
|
* Return value: COGL material handle
|
|
|
|
*/
|
|
|
|
CoglHandle
|
|
|
|
clutter_texture_get_cogl_material (ClutterTexture *texture)
|
|
|
|
{
|
2009-02-19 12:05:20 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), COGL_INVALID_HANDLE);
|
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
return texture->priv->material;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_texture_set_cogl_material:
|
|
|
|
* @texture: A #ClutterTexture
|
|
|
|
* @cogl_material: A CoglHandle for a material
|
|
|
|
*
|
|
|
|
* Replaces the underlying COGL texture drawn by this actor with
|
|
|
|
* @cogl_tex. A reference to the texture is taken so if the handle is
|
2009-04-01 16:16:44 +00:00
|
|
|
* no longer needed it should be deref'd with cogl_handle_unref.
|
2008-12-23 16:39:11 +00:00
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_texture_set_cogl_material (ClutterTexture *texture,
|
|
|
|
CoglHandle cogl_material)
|
|
|
|
{
|
|
|
|
CoglHandle cogl_texture;
|
|
|
|
|
2009-02-19 12:05:20 +00:00
|
|
|
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
|
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
/* This */
|
|
|
|
if (texture->priv->material)
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_unref (texture->priv->material);
|
2008-12-23 16:39:11 +00:00
|
|
|
|
|
|
|
texture->priv->material = cogl_material;
|
|
|
|
|
|
|
|
/* XXX: We are re-asserting the first layer of the new material to ensure the
|
|
|
|
* priv state is in sync with the contents of the material. */
|
|
|
|
cogl_texture = clutter_texture_get_cogl_texture (texture);
|
|
|
|
clutter_texture_set_cogl_texture (texture, cogl_texture);
|
|
|
|
/* XXX: If we add support for more material layers, this will need
|
|
|
|
* extending */
|
|
|
|
}
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
/**
|
2008-04-25 13:37:36 +00:00
|
|
|
* clutter_texture_get_cogl_texture
|
2006-06-22 09:14:35 +00:00
|
|
|
* @texture: A #ClutterTexture
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2009-02-19 13:44:29 +00:00
|
|
|
* Retrieves the handle to the underlying COGL texture used for drawing
|
2008-04-25 13:37:36 +00:00
|
|
|
* the actor. No extra reference is taken so if you need to keep the
|
2009-04-01 16:16:44 +00:00
|
|
|
* handle then you should call cogl_handle_ref() on it.
|
2009-02-19 13:44:29 +00:00
|
|
|
*
|
|
|
|
* The texture handle returned is the first layer of the material
|
|
|
|
* handle used by the #ClutterTexture. If you need to access the other
|
|
|
|
* layers you should use clutter_texture_get_cogl_material() instead
|
|
|
|
* and use the #CoglMaterial API.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Since: 0.8
|
2008-01-21 11:39:23 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Return value: COGL texture handle
|
2009-02-19 13:44:29 +00:00
|
|
|
*/
|
2008-04-25 13:37:36 +00:00
|
|
|
CoglHandle
|
|
|
|
clutter_texture_get_cogl_texture (ClutterTexture *texture)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2008-12-23 16:39:11 +00:00
|
|
|
const GList *layers;
|
|
|
|
int n_layers;
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), COGL_INVALID_HANDLE);
|
2008-02-05 14:49:29 +00:00
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
layers = cogl_material_get_layers (texture->priv->material);
|
|
|
|
n_layers = g_list_length ((GList *)layers);
|
|
|
|
if (n_layers == 0)
|
|
|
|
return COGL_INVALID_HANDLE;
|
2009-01-26 15:25:55 +00:00
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
return cogl_material_layer_get_texture (layers->data);
|
2008-04-25 13:37:36 +00:00
|
|
|
}
|
2006-09-19 19:27:16 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/**
|
|
|
|
* clutter_texture_set_cogl_texture
|
|
|
|
* @texture: A #ClutterTexture
|
|
|
|
* @cogl_tex: A CoglHandle for a texture
|
|
|
|
*
|
|
|
|
* Replaces the underlying COGL texture drawn by this actor with
|
|
|
|
* @cogl_tex. A reference to the texture is taken so if the handle is
|
2009-04-01 16:16:44 +00:00
|
|
|
* no longer needed it should be deref'd with cogl_handle_unref.
|
2008-04-25 13:37:36 +00:00
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_texture_set_cogl_texture (ClutterTexture *texture,
|
|
|
|
CoglHandle cogl_tex)
|
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv;
|
|
|
|
gboolean size_change;
|
|
|
|
guint width, height;
|
2006-09-19 19:27:16 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
|
|
|
|
g_return_if_fail (cogl_is_texture (cogl_tex));
|
2008-02-05 14:49:29 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
priv = texture->priv;
|
2008-02-05 14:49:29 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
width = cogl_texture_get_width (cogl_tex);
|
|
|
|
height = cogl_texture_get_height (cogl_tex);
|
2008-02-05 14:49:29 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Reference the new texture now in case it is the same one we are
|
|
|
|
already using */
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_ref (cogl_tex);
|
2007-07-29 22:55:04 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Remove FBO if exisiting */
|
|
|
|
if (priv->fbo_source)
|
|
|
|
texture_fbo_free_resources (texture);
|
2009-02-06 13:50:16 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Remove old texture */
|
|
|
|
texture_free_gl_resources (texture);
|
|
|
|
/* Use the new texture */
|
2008-12-23 16:39:11 +00:00
|
|
|
|
|
|
|
cogl_material_set_layer (priv->material, 0, cogl_tex);
|
2007-07-29 22:55:04 +00:00
|
|
|
|
2009-02-05 18:26:08 +00:00
|
|
|
/* The material now holds a reference to the texture so we can
|
|
|
|
safely release the reference we claimed above */
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_unref (cogl_tex);
|
2009-02-05 18:26:08 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
size_change = width != priv->width || height != priv->height;
|
|
|
|
priv->width = width;
|
|
|
|
priv->height = height;
|
2007-10-12 08:17:00 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
CLUTTER_NOTE (TEXTURE, "set size %ix%i\n",
|
|
|
|
priv->width,
|
|
|
|
priv->height);
|
2006-09-19 19:27:16 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
CLUTTER_ACTOR_SET_FLAGS (CLUTTER_ACTOR (texture), CLUTTER_ACTOR_REALIZED);
|
2006-09-19 19:27:16 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (size_change)
|
|
|
|
{
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
g_signal_emit (texture, texture_signals[SIZE_CHANGE], 0,
|
|
|
|
priv->width,
|
|
|
|
priv->height);
|
2007-06-22 15:16:40 +00:00
|
|
|
|
2009-01-26 16:24:17 +00:00
|
|
|
if (priv->sync_actor_size)
|
|
|
|
clutter_actor_queue_relayout (CLUTTER_ACTOR (texture));
|
2006-09-19 19:27:16 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* rename signal */
|
|
|
|
g_signal_emit (texture, texture_signals[PIXBUF_CHANGE], 0);
|
|
|
|
|
|
|
|
g_object_notify (G_OBJECT (texture), "cogl-texture");
|
2007-04-27 21:13:06 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* If resized actor may need resizing but paint() will do this */
|
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
static gboolean
|
|
|
|
clutter_texture_set_from_data (ClutterTexture *texture,
|
|
|
|
const guchar *data,
|
|
|
|
CoglPixelFormat source_format,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint rowstride,
|
|
|
|
gint bpp,
|
|
|
|
GError **error)
|
2007-12-20 14:26:07 +00:00
|
|
|
{
|
2009-01-18 14:51:19 +00:00
|
|
|
ClutterTexturePrivate *priv = texture->priv;
|
|
|
|
CoglHandle new_texture = COGL_INVALID_HANDLE;
|
|
|
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
2009-02-06 13:50:16 +00:00
|
|
|
gint min_filter, mag_filter;
|
2009-01-18 14:51:19 +00:00
|
|
|
gint max_waste = -1;
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2009-01-18 14:51:19 +00:00
|
|
|
if (!priv->no_slice)
|
|
|
|
max_waste = priv->max_tile_waste;
|
|
|
|
|
|
|
|
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
|
|
|
|
flags |= COGL_TEXTURE_AUTO_MIPMAP;
|
|
|
|
|
|
|
|
new_texture = cogl_texture_new_from_data (width, height,
|
|
|
|
max_waste, flags,
|
|
|
|
source_format,
|
|
|
|
COGL_PIXEL_FORMAT_ANY,
|
|
|
|
rowstride,
|
|
|
|
data);
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2009-01-18 14:51:19 +00:00
|
|
|
if (G_UNLIKELY (new_texture == COGL_INVALID_HANDLE))
|
2007-12-20 14:26:07 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Failed to create COGL texture");
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
return FALSE;
|
2007-12-20 14:26:07 +00:00
|
|
|
}
|
|
|
|
|
2009-02-06 13:50:16 +00:00
|
|
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
|
|
|
&min_filter,
|
|
|
|
&mag_filter);
|
|
|
|
|
|
|
|
cogl_texture_set_filters (new_texture, min_filter, mag_filter);
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_set_cogl_texture (texture, new_texture);
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_unref (new_texture);
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2009-01-14 15:30:10 +00:00
|
|
|
g_signal_emit (texture, texture_signals[LOAD_FINISHED], 0, error);
|
|
|
|
|
2007-12-20 14:26:07 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
/**
|
2007-05-25 10:56:09 +00:00
|
|
|
* clutter_texture_set_from_rgb_data:
|
2006-06-22 09:14:35 +00:00
|
|
|
* @texture: A #ClutterTexture
|
2008-02-15 17:11:50 +00:00
|
|
|
* @data: Image data in RGBA type colorspace.
|
2008-02-15 15:49:44 +00:00
|
|
|
* @has_alpha: Set to TRUE if image data has an alpha channel.
|
2006-09-19 19:27:16 +00:00
|
|
|
* @width: Width in pixels of image data.
|
|
|
|
* @height: Height in pixels of image data
|
|
|
|
* @rowstride: Distance in bytes between row starts.
|
2008-12-23 16:29:29 +00:00
|
|
|
* @bpp: bytes per pixel (Currently only 3 and 4 supported,
|
2008-07-01 10:11:39 +00:00
|
|
|
* depending on @has_alpha)
|
2007-05-25 10:56:09 +00:00
|
|
|
* @flags: #ClutterTextureFlags
|
2007-12-24 16:24:26 +00:00
|
|
|
* @error: return location for a #GError, or %NULL.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2006-09-19 19:27:16 +00:00
|
|
|
* Sets #ClutterTexture image data.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2007-12-24 16:24:26 +00:00
|
|
|
* Note: This function is likely to change in future versions.
|
2007-05-25 10:56:09 +00:00
|
|
|
*
|
2007-12-24 16:24:26 +00:00
|
|
|
* Return value: %TRUE on success, %FALSE on failure.
|
|
|
|
*
|
|
|
|
* Since: 0.4.
|
2006-05-29 08:59:36 +00:00
|
|
|
**/
|
2007-10-12 08:17:00 +00:00
|
|
|
gboolean
|
2007-05-25 10:56:09 +00:00
|
|
|
clutter_texture_set_from_rgb_data (ClutterTexture *texture,
|
|
|
|
const guchar *data,
|
|
|
|
gboolean has_alpha,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint rowstride,
|
|
|
|
gint bpp,
|
|
|
|
ClutterTextureFlags flags,
|
2007-06-06 14:27:52 +00:00
|
|
|
GError **error)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv;
|
2008-04-25 13:37:36 +00:00
|
|
|
CoglPixelFormat source_format;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
priv = texture->priv;
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Convert the flags to a CoglPixelFormat */
|
|
|
|
if (has_alpha)
|
2006-07-24 21:15:19 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
if (bpp != 4)
|
2006-07-24 21:15:19 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Unsupported BPP");
|
|
|
|
return FALSE;
|
2006-07-24 21:15:19 +00:00
|
|
|
}
|
2008-04-25 13:37:36 +00:00
|
|
|
source_format = COGL_PIXEL_FORMAT_RGBA_8888;
|
2006-09-19 19:27:16 +00:00
|
|
|
}
|
2008-04-25 13:37:36 +00:00
|
|
|
else
|
2006-09-19 19:27:16 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
if (bpp != 3)
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Unsupported BPP");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
source_format = COGL_PIXEL_FORMAT_RGB_888;
|
2006-09-19 19:27:16 +00:00
|
|
|
}
|
2008-04-25 13:37:36 +00:00
|
|
|
if ((flags & CLUTTER_TEXTURE_RGB_FLAG_BGR))
|
|
|
|
source_format |= COGL_BGR_BIT;
|
|
|
|
if ((flags & CLUTTER_TEXTURE_RGB_FLAG_PREMULT))
|
|
|
|
source_format |= COGL_PREMULT_BIT;
|
|
|
|
|
|
|
|
return clutter_texture_set_from_data (texture, data,
|
|
|
|
source_format,
|
|
|
|
width, height,
|
|
|
|
rowstride, bpp,
|
|
|
|
error);
|
2007-05-25 10:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_texture_set_from_yuv_data:
|
|
|
|
* @texture: A #ClutterTexture
|
2008-02-15 15:18:02 +00:00
|
|
|
* @data: Image data in YUV type colorspace.
|
2007-05-25 10:56:09 +00:00
|
|
|
* @width: Width in pixels of image data.
|
|
|
|
* @height: Height in pixels of image data
|
|
|
|
* @flags: #ClutterTextureFlags
|
2007-07-24 17:38:35 +00:00
|
|
|
* @error: Return location for a #GError, or %NULL.
|
2007-05-25 10:56:09 +00:00
|
|
|
*
|
2007-07-24 17:38:35 +00:00
|
|
|
* Sets a #ClutterTexture from YUV image data. If an error occurred,
|
|
|
|
* %FALSE is returned and @error is set.
|
2007-05-25 10:56:09 +00:00
|
|
|
*
|
2007-07-24 17:38:35 +00:00
|
|
|
* This function is likely to change in future versions.
|
2007-05-25 10:56:09 +00:00
|
|
|
*
|
2007-07-24 17:38:35 +00:00
|
|
|
* Return value: %TRUE if the texture was successfully updated
|
|
|
|
*
|
2008-12-05 14:08:06 +00:00
|
|
|
* Since: 0.4
|
2009-01-12 16:54:30 +00:00
|
|
|
*/
|
2007-10-12 08:17:00 +00:00
|
|
|
gboolean
|
2009-01-12 16:54:30 +00:00
|
|
|
clutter_texture_set_from_yuv_data (ClutterTexture *texture,
|
|
|
|
const guchar *data,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
ClutterTextureFlags flags,
|
|
|
|
GError **error)
|
2007-05-25 10:56:09 +00:00
|
|
|
{
|
2007-06-07 23:51:53 +00:00
|
|
|
ClutterTexturePrivate *priv;
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2007-07-24 17:38:35 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), FALSE);
|
|
|
|
|
|
|
|
if (!clutter_feature_available (CLUTTER_FEATURE_TEXTURE_YUV))
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_NO_YUV,
|
|
|
|
"YUV textures are not supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-05-25 10:56:09 +00:00
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Convert the flags to a CoglPixelFormat */
|
|
|
|
if ((flags & CLUTTER_TEXTURE_YUV_FLAG_YUV2))
|
2007-05-25 10:56:09 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"YUV2 not supported");
|
|
|
|
return FALSE;
|
2007-05-25 10:56:09 +00:00
|
|
|
}
|
2007-06-07 23:51:53 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
return clutter_texture_set_from_data (texture, data,
|
|
|
|
COGL_PIXEL_FORMAT_YUV,
|
|
|
|
width, height,
|
|
|
|
width * 3, 3,
|
|
|
|
error);
|
2006-09-19 19:27:16 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
/*
|
|
|
|
* clutter_texture_async_load_complete:
|
|
|
|
* @self: a #ClutterTexture
|
2009-04-30 17:00:22 +00:00
|
|
|
* @bitmap: a handle to a CoglBitmap
|
2009-01-12 16:54:30 +00:00
|
|
|
* @error: load error
|
|
|
|
*
|
2009-02-25 17:10:54 +00:00
|
|
|
* If @error is %NULL, loads @bitmap into a #CoglTexture.
|
2009-01-12 16:54:30 +00:00
|
|
|
*
|
|
|
|
* This function emits the ::load-finished signal on @self.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
clutter_texture_async_load_complete (ClutterTexture *self,
|
2009-04-30 17:00:22 +00:00
|
|
|
CoglHandle bitmap,
|
2009-01-12 16:54:30 +00:00
|
|
|
const GError *error)
|
2009-01-07 17:02:43 +00:00
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv = self->priv;
|
2009-01-12 16:54:30 +00:00
|
|
|
CoglHandle handle;
|
2009-01-18 14:51:19 +00:00
|
|
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
2009-01-12 16:54:30 +00:00
|
|
|
gint waste = -1;
|
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
priv->async_data = NULL;
|
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
if (error == NULL)
|
2009-01-07 17:02:43 +00:00
|
|
|
{
|
2009-02-05 20:00:05 +00:00
|
|
|
if (!priv->no_slice)
|
2009-01-12 16:54:30 +00:00
|
|
|
waste = priv->max_tile_waste;
|
|
|
|
|
|
|
|
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
|
2009-01-22 13:24:20 +00:00
|
|
|
flags |= COGL_TEXTURE_AUTO_MIPMAP;
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
handle = cogl_texture_new_from_bitmap (bitmap,
|
2009-01-18 14:51:19 +00:00
|
|
|
waste, flags,
|
|
|
|
COGL_PIXEL_FORMAT_ANY);
|
2009-01-07 17:02:43 +00:00
|
|
|
clutter_texture_set_cogl_texture (self, handle);
|
2009-03-12 10:14:40 +00:00
|
|
|
if (priv->load_size_async)
|
|
|
|
{
|
2009-03-12 10:38:39 +00:00
|
|
|
g_signal_emit (self, texture_signals[SIZE_CHANGE], 0,
|
|
|
|
cogl_texture_get_width(handle),
|
|
|
|
cogl_texture_get_height (handle));
|
2009-03-12 10:14:40 +00:00
|
|
|
}
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_unref (handle);
|
2009-01-07 17:02:43 +00:00
|
|
|
}
|
2009-01-12 16:54:30 +00:00
|
|
|
|
|
|
|
g_signal_emit (self, texture_signals[LOAD_FINISHED], 0, error);
|
2009-01-12 17:09:47 +00:00
|
|
|
|
|
|
|
clutter_actor_queue_relayout (CLUTTER_ACTOR (self));
|
2009-01-12 16:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_thread_idle_func (gpointer user_data)
|
2009-01-12 16:54:30 +00:00
|
|
|
{
|
2009-02-25 17:10:54 +00:00
|
|
|
ClutterTextureAsyncData *data = user_data;
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
/* Grab the mutex so we can be sure the thread has unlocked it
|
|
|
|
before we destroy it */
|
|
|
|
g_mutex_lock (data->mutex);
|
|
|
|
g_mutex_unlock (data->mutex);
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_async_load_complete (data->texture, data->load_bitmap,
|
|
|
|
data->load_error);
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_async_data_free (data);
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-01-07 17:02:43 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
static void
|
|
|
|
clutter_texture_thread_func (gpointer user_data, gpointer pool_data)
|
2009-01-07 17:02:43 +00:00
|
|
|
{
|
2009-02-25 17:10:54 +00:00
|
|
|
ClutterTextureAsyncData *data = user_data;
|
|
|
|
gboolean should_abort;
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
/* Make sure we haven't been told to abort before the thread had a
|
|
|
|
chance to run */
|
|
|
|
g_mutex_lock (data->mutex);
|
|
|
|
should_abort = data->abort;
|
|
|
|
g_mutex_unlock (data->mutex);
|
|
|
|
|
|
|
|
if (should_abort)
|
2009-02-17 12:00:08 +00:00
|
|
|
{
|
2009-02-25 17:10:54 +00:00
|
|
|
/* If we've been told to abort then main thread has disowned the
|
|
|
|
async data and we need to free it */
|
|
|
|
clutter_texture_async_data_free (data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
data->load_bitmap = cogl_bitmap_new_from_file (data->load_filename,
|
|
|
|
&data->load_error);
|
|
|
|
|
|
|
|
/* Check again if we've been told to abort */
|
|
|
|
g_mutex_lock (data->mutex);
|
|
|
|
|
|
|
|
if (data->abort)
|
|
|
|
{
|
|
|
|
g_mutex_unlock (data->mutex);
|
|
|
|
|
|
|
|
clutter_texture_async_data_free (data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Make sure we give the image to GL in the main thread, where we
|
|
|
|
* hold the main Clutter lock. Once load_idle is non-NULL then the
|
|
|
|
* main thread is guaranteed not to set the abort flag. It can't
|
|
|
|
* set it while we're holding the mutex so we can safely start the
|
|
|
|
* idle handler now without the possibility of calling the
|
|
|
|
* callback after it is aborted */
|
|
|
|
data->load_idle =
|
2009-03-12 10:14:40 +00:00
|
|
|
clutter_threads_add_idle_full (G_PRIORITY_LOW, clutter_texture_thread_idle_func, data, NULL);
|
2009-02-25 17:10:54 +00:00
|
|
|
|
|
|
|
g_mutex_unlock (data->mutex);
|
2009-02-17 12:00:08 +00:00
|
|
|
}
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
return;
|
2009-01-07 17:02:43 +00:00
|
|
|
}
|
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
static gboolean
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_idle_func (gpointer user_data)
|
2009-01-12 16:54:30 +00:00
|
|
|
{
|
2009-02-25 17:10:54 +00:00
|
|
|
ClutterTextureAsyncData *data = user_data;
|
|
|
|
GError *internal_error = NULL;
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
data->load_bitmap = cogl_bitmap_new_from_file (data->load_filename,
|
2009-01-12 16:54:30 +00:00
|
|
|
&internal_error);
|
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_async_load_complete (data->texture, data->load_bitmap,
|
|
|
|
internal_error);
|
2009-01-12 16:54:30 +00:00
|
|
|
|
|
|
|
if (internal_error)
|
|
|
|
g_error_free (internal_error);
|
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_async_data_free (data);
|
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clutter_texture_async_load:
|
2009-02-25 17:10:54 +00:00
|
|
|
* @self: a #ClutterTExture
|
|
|
|
* @filename: name of the file to load
|
2009-01-12 16:54:30 +00:00
|
|
|
* @error: return location for a #GError
|
|
|
|
*
|
|
|
|
* Starts an asynchronous load of the file name stored inside
|
2009-02-25 17:10:54 +00:00
|
|
|
* the load_filename member of @data.
|
2009-01-12 16:54:30 +00:00
|
|
|
*
|
|
|
|
* If threading is enabled we use a GThread to perform the actual
|
|
|
|
* I/O; if threading is not enabled, we use an idle GSource.
|
|
|
|
*
|
|
|
|
* The I/O is the only bit done in a thread -- uploading the
|
|
|
|
* texture data to the GL pipeline must be done from within the
|
|
|
|
* same thread that called clutter_main(). Threaded upload should
|
|
|
|
* be part of the GL implementation.
|
|
|
|
*
|
|
|
|
* This function will block until we get a size from the file
|
|
|
|
* so that we can effectively get the size the texture actor after
|
|
|
|
* clutter_texture_set_from_file().
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the asynchronous loading was successfully
|
|
|
|
* initiated, %FALSE otherwise
|
|
|
|
*/
|
|
|
|
static gboolean
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_async_load (ClutterTexture *self,
|
|
|
|
const gchar *filename,
|
|
|
|
GError **error)
|
2009-01-12 16:54:30 +00:00
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv = self->priv;
|
2009-02-25 17:10:54 +00:00
|
|
|
ClutterTextureAsyncData *data;
|
2009-01-12 16:54:30 +00:00
|
|
|
gint width, height;
|
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
/* ask the file for a size; if we cannot get the size then
|
|
|
|
* there's no point in even continuing the asynchronous
|
|
|
|
* loading, so we just stop there
|
|
|
|
*/
|
2009-03-11 18:26:30 +00:00
|
|
|
|
|
|
|
if (priv->load_size_async)
|
|
|
|
{
|
|
|
|
res = TRUE;
|
2009-03-12 10:14:40 +00:00
|
|
|
width = 0;
|
|
|
|
height = 0;
|
2009-03-11 18:26:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
res = cogl_bitmap_get_size_from_file (filename, &width, &height);
|
|
|
|
}
|
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
if (!res)
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Failed to create COGL texture");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
2009-01-12 17:09:47 +00:00
|
|
|
{
|
|
|
|
priv->width = width;
|
|
|
|
priv->height = height;
|
|
|
|
}
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
clutter_texture_async_load_cancel (self);
|
|
|
|
|
|
|
|
data = g_slice_new (ClutterTextureAsyncData);
|
|
|
|
|
|
|
|
data->abort = FALSE;
|
|
|
|
data->texture = self;
|
|
|
|
data->load_idle = 0;
|
|
|
|
data->load_filename = g_strdup (filename);
|
|
|
|
data->load_bitmap = NULL;
|
|
|
|
data->load_error = NULL;
|
|
|
|
|
|
|
|
priv->async_data = data;
|
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
if (g_thread_supported ())
|
|
|
|
{
|
2009-02-25 17:10:54 +00:00
|
|
|
data->mutex = g_mutex_new ();
|
|
|
|
|
|
|
|
if (async_thread_pool == NULL)
|
|
|
|
/* This apparently can't fail if exclusive == FALSE */
|
|
|
|
async_thread_pool
|
|
|
|
= g_thread_pool_new (clutter_texture_thread_func,
|
2009-03-10 13:00:57 +00:00
|
|
|
NULL, 1, FALSE, NULL);
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
g_thread_pool_push (async_thread_pool, data, NULL);
|
2009-01-12 16:54:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-25 17:10:54 +00:00
|
|
|
data->mutex = NULL;
|
2009-01-12 16:54:30 +00:00
|
|
|
|
2009-02-25 17:10:54 +00:00
|
|
|
data->load_idle
|
|
|
|
= clutter_threads_add_idle (clutter_texture_idle_func, data);
|
2009-01-12 16:54:30 +00:00
|
|
|
}
|
2009-02-25 17:10:54 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2009-01-12 16:54:30 +00:00
|
|
|
}
|
|
|
|
|
2006-09-19 19:27:16 +00:00
|
|
|
/**
|
2008-04-25 13:37:36 +00:00
|
|
|
* clutter_texture_set_from_file:
|
2006-09-19 19:27:16 +00:00
|
|
|
* @texture: A #ClutterTexture
|
2008-04-25 13:37:36 +00:00
|
|
|
* @filename: The filename of the image in GLib file name encoding
|
2007-07-24 17:38:35 +00:00
|
|
|
* @error: Return location for a #GError, or %NULL
|
2006-09-19 19:27:16 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Sets the #ClutterTexture image data from an image file. In case of
|
2007-07-24 17:38:35 +00:00
|
|
|
* failure, %FALSE is returned and @error is set.
|
2006-09-19 19:27:16 +00:00
|
|
|
*
|
2009-01-12 17:09:47 +00:00
|
|
|
* If #ClutterTexture:load-async is set to %TRUE, this function
|
|
|
|
* will return as soon as possible, and the actual image loading
|
2009-03-12 11:48:44 +00:00
|
|
|
* from disk will be performed asynchronously. #ClutterTexture::size-change
|
2009-05-12 13:15:18 +00:00
|
|
|
* will be emitten when the size of the texture is available and
|
2009-03-12 11:48:44 +00:00
|
|
|
* #ClutterTexture::load-finished will be emitted when the image has been
|
|
|
|
* loaded or if an error occurred.
|
2009-01-12 17:09:47 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Return value: %TRUE if the image was successfully loaded and set
|
2007-07-24 17:38:35 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Since: 0.8
|
2007-07-24 17:38:35 +00:00
|
|
|
*/
|
2007-05-25 10:56:09 +00:00
|
|
|
gboolean
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_set_from_file (ClutterTexture *texture,
|
|
|
|
const gchar *filename,
|
|
|
|
GError **error)
|
2006-09-19 19:27:16 +00:00
|
|
|
{
|
2009-01-12 16:54:30 +00:00
|
|
|
ClutterTexturePrivate *priv;
|
|
|
|
CoglHandle new_texture = COGL_INVALID_HANDLE;
|
|
|
|
GError *internal_error = NULL;
|
2009-01-18 14:51:19 +00:00
|
|
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
2009-02-06 13:50:16 +00:00
|
|
|
gint min_filter, mag_filter;
|
2009-01-12 16:54:30 +00:00
|
|
|
gint max_waste = -1;
|
2007-05-25 10:56:09 +00:00
|
|
|
|
2008-03-18 17:56:50 +00:00
|
|
|
priv = texture->priv;
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2009-03-12 10:14:40 +00:00
|
|
|
if (priv->load_data_async)
|
2009-02-25 17:10:54 +00:00
|
|
|
return clutter_texture_async_load (texture, filename, error);
|
2009-01-07 17:02:43 +00:00
|
|
|
|
2009-02-05 20:00:05 +00:00
|
|
|
if (!priv->no_slice)
|
2009-01-12 16:54:30 +00:00
|
|
|
max_waste = priv->max_tile_waste;
|
|
|
|
|
|
|
|
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
|
2009-01-18 14:51:19 +00:00
|
|
|
flags |= COGL_TEXTURE_AUTO_MIPMAP;
|
2009-01-12 16:54:30 +00:00
|
|
|
|
|
|
|
new_texture = cogl_texture_new_from_file (filename,
|
2009-01-18 14:51:19 +00:00
|
|
|
max_waste, flags,
|
2009-01-12 16:54:30 +00:00
|
|
|
COGL_PIXEL_FORMAT_ANY,
|
|
|
|
&internal_error);
|
|
|
|
if (new_texture == COGL_INVALID_HANDLE)
|
2008-04-25 13:37:36 +00:00
|
|
|
{
|
|
|
|
/* If COGL didn't give an error then make one up */
|
2009-01-12 16:54:30 +00:00
|
|
|
if (internal_error == NULL)
|
2008-04-25 13:37:36 +00:00
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Failed to create COGL texture");
|
|
|
|
}
|
2009-01-12 16:54:30 +00:00
|
|
|
else
|
|
|
|
g_propagate_error (error, internal_error);
|
|
|
|
|
|
|
|
g_signal_emit (texture, texture_signals[LOAD_FINISHED], 0, error);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-03-18 17:56:50 +00:00
|
|
|
|
2009-02-06 13:50:16 +00:00
|
|
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
|
|
|
&min_filter,
|
|
|
|
&mag_filter);
|
|
|
|
|
|
|
|
cogl_texture_set_filters (new_texture, min_filter, mag_filter);
|
2006-06-20 20:29:45 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_set_cogl_texture (texture, new_texture);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_unref (new_texture);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2009-01-12 16:54:30 +00:00
|
|
|
g_signal_emit (texture, texture_signals[LOAD_FINISHED], 0, error);
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
return TRUE;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-06-12 11:43:25 +00:00
|
|
|
* clutter_texture_set_filter_quality:
|
|
|
|
* @texture: a #ClutterTexture
|
|
|
|
* @filter_quality: new filter quality value
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-06-10 11:18:19 +00:00
|
|
|
* Sets the filter quality when scaling a texture. The quality is an
|
|
|
|
* enumeration currently the following values are supported:
|
2008-06-12 11:43:25 +00:00
|
|
|
* %CLUTTER_TEXTURE_QUALITY_LOW which is fast but only uses nearest neighbour
|
|
|
|
* interpolation. %CLUTTER_TEXTURE_QUALITY_MEDIUM which is computationally a
|
|
|
|
* bit more expensive (bilinear interpolation), and
|
|
|
|
* %CLUTTER_TEXTURE_QUALITY_HIGH which uses extra texture memory resources to
|
|
|
|
* improve scaled down rendering as well (by using mipmaps). The default value
|
|
|
|
* is %CLUTTER_TEXTURE_QUALITY_MEDIUM.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
void
|
2008-06-07 15:08:05 +00:00
|
|
|
clutter_texture_set_filter_quality (ClutterTexture *texture,
|
|
|
|
ClutterTextureQuality filter_quality)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv;
|
2008-06-07 15:08:05 +00:00
|
|
|
ClutterTextureQuality old_quality;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2007-07-26 11:04:04 +00:00
|
|
|
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
priv = texture->priv;
|
2007-07-26 11:04:04 +00:00
|
|
|
|
2008-06-07 15:08:05 +00:00
|
|
|
old_quality = clutter_texture_get_filter_quality (texture);
|
2008-10-31 16:59:51 +00:00
|
|
|
|
2008-06-07 15:08:05 +00:00
|
|
|
if (filter_quality != old_quality)
|
2008-04-25 13:37:36 +00:00
|
|
|
{
|
2008-12-23 16:39:11 +00:00
|
|
|
CoglHandle cogl_texture = clutter_texture_get_cogl_texture (texture);
|
2009-02-06 13:50:16 +00:00
|
|
|
gint min_filter, mag_filter;
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
priv->filter_quality = filter_quality;
|
|
|
|
|
2009-02-06 13:50:16 +00:00
|
|
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
|
|
|
&min_filter,
|
|
|
|
&mag_filter);
|
|
|
|
|
2008-10-31 16:59:51 +00:00
|
|
|
/* Is this actually needed - causes problems with TFP mipmaps */
|
2008-12-23 16:39:11 +00:00
|
|
|
if (cogl_texture != COGL_INVALID_HANDLE)
|
2009-02-06 13:50:16 +00:00
|
|
|
cogl_texture_set_filters (cogl_texture, min_filter, mag_filter);
|
2008-06-12 11:43:25 +00:00
|
|
|
|
2008-06-07 15:08:05 +00:00
|
|
|
if ((old_quality == CLUTTER_TEXTURE_QUALITY_HIGH ||
|
|
|
|
filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH) &&
|
|
|
|
CLUTTER_ACTOR_IS_REALIZED (texture))
|
|
|
|
{
|
2008-11-07 16:50:23 +00:00
|
|
|
gboolean was_visible;
|
|
|
|
|
|
|
|
was_visible = CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (texture));
|
|
|
|
|
|
|
|
clutter_actor_unrealize (CLUTTER_ACTOR (texture));
|
|
|
|
clutter_actor_realize (CLUTTER_ACTOR (texture));
|
|
|
|
|
|
|
|
if (was_visible)
|
|
|
|
clutter_actor_show (CLUTTER_ACTOR (texture));
|
2008-06-07 15:08:05 +00:00
|
|
|
}
|
2008-10-31 16:59:51 +00:00
|
|
|
|
2008-06-10 10:49:21 +00:00
|
|
|
g_object_notify (G_OBJECT (texture), "filter-quality");
|
2008-04-25 13:37:36 +00:00
|
|
|
|
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-25 13:37:36 +00:00
|
|
|
* clutter_texture_get_filter_quality
|
2006-06-22 09:14:35 +00:00
|
|
|
* @texture: A #ClutterTexture
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Gets the filter quality used when scaling a texture.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Return value: The filter quality value.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2008-06-07 15:08:05 +00:00
|
|
|
ClutterTextureQuality
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_get_filter_quality (ClutterTexture *texture)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
ClutterTexturePrivate *priv;
|
2008-03-18 17:56:50 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), 0);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
priv = texture->priv;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-10-31 16:59:51 +00:00
|
|
|
return priv->filter_quality;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-25 13:37:36 +00:00
|
|
|
* clutter_texture_set_max_tile_waste
|
2006-06-22 09:14:35 +00:00
|
|
|
* @texture: A #ClutterTexture
|
2008-04-25 13:37:36 +00:00
|
|
|
* @max_tile_waste: Maximum amount of waste in pixels or -1
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Sets the maximum number of pixels in either axis that can be wasted
|
|
|
|
* for an individual texture slice. If -1 is specified then the
|
|
|
|
* texture is forced not to be sliced and the texture creation will
|
|
|
|
* fail if the hardware can't create a texture large enough.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* The value is only used when first creating a texture so changing it
|
|
|
|
* after the texture data has been set has no effect.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
void
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_texture_set_max_tile_waste (ClutterTexture *texture,
|
|
|
|
gint max_tile_waste)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2008-03-18 17:56:50 +00:00
|
|
|
ClutterTexturePrivate *priv;
|
2008-12-23 16:39:11 +00:00
|
|
|
CoglHandle cogl_texture;
|
2008-03-18 17:56:50 +00:00
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
|
|
|
|
|
|
|
|
priv = texture->priv;
|
2008-12-23 16:39:11 +00:00
|
|
|
cogl_texture = clutter_texture_get_cogl_texture (texture);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* There's no point in changing the max_tile_waste if the texture
|
|
|
|
has already been created because it will be overridden with the
|
|
|
|
value from the texture handle */
|
2008-12-23 16:39:11 +00:00
|
|
|
if (cogl_texture == COGL_INVALID_HANDLE)
|
2008-04-25 13:37:36 +00:00
|
|
|
priv->max_tile_waste = max_tile_waste;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-25 13:37:36 +00:00
|
|
|
* clutter_texture_get_max_tile_waste
|
2006-06-22 09:14:35 +00:00
|
|
|
* @texture: A #ClutterTexture
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Gets the maximum waste that will be used when creating a texture or
|
|
|
|
* -1 if slicing is disabled.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Return value: The maximum waste or -1 if the texture waste is
|
|
|
|
* unlimited.
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
clutter_texture_get_max_tile_waste (ClutterTexture *texture)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2007-03-19 10:00:38 +00:00
|
|
|
ClutterTexturePrivate *priv;
|
2008-12-23 16:39:11 +00:00
|
|
|
CoglHandle cogl_texture;
|
2007-03-19 10:00:38 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_TEXTURE (texture), 0);
|
2007-10-12 08:17:00 +00:00
|
|
|
|
2007-03-19 10:00:38 +00:00
|
|
|
priv = texture->priv;
|
2008-12-23 16:39:11 +00:00
|
|
|
cogl_texture = clutter_texture_get_cogl_texture (texture);
|
2007-03-19 10:00:38 +00:00
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
if (cogl_texture == COGL_INVALID_HANDLE)
|
2008-04-25 13:37:36 +00:00
|
|
|
return texture->priv->max_tile_waste;
|
|
|
|
else
|
|
|
|
/* If we have a valid texture handle then use the value from that
|
|
|
|
instead */
|
2008-12-23 16:39:11 +00:00
|
|
|
return cogl_texture_get_max_waste (cogl_texture);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-25 13:37:36 +00:00
|
|
|
* clutter_texture_new_from_file:
|
|
|
|
* @filename: The name of an image file to load.
|
|
|
|
* @error: Return locatoin for an error.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Creates a new ClutterTexture actor to display the image contained a
|
|
|
|
* file. If the image failed to load then NULL is returned and @error
|
|
|
|
* is set.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Return value: A newly created #ClutterTexture object or NULL on
|
|
|
|
* error.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Since: 0.8
|
2006-05-29 08:59:36 +00:00
|
|
|
**/
|
2008-04-25 13:37:36 +00:00
|
|
|
ClutterActor*
|
|
|
|
clutter_texture_new_from_file (const gchar *filename,
|
|
|
|
GError **error)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
ClutterActor *texture = clutter_texture_new ();
|
2007-03-19 10:00:38 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (!clutter_texture_set_from_file (CLUTTER_TEXTURE (texture),
|
|
|
|
filename, error))
|
|
|
|
{
|
|
|
|
g_object_ref_sink (texture);
|
|
|
|
g_object_unref (texture);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return texture;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-25 13:37:36 +00:00
|
|
|
* clutter_texture_new:
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Creates a new empty #ClutterTexture object.
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Return value: A newly created #ClutterTexture object.
|
2006-05-29 08:59:36 +00:00
|
|
|
**/
|
2008-04-25 13:37:36 +00:00
|
|
|
ClutterActor *
|
|
|
|
clutter_texture_new (void)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
return g_object_new (CLUTTER_TYPE_TEXTURE, NULL);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/**
|
|
|
|
* clutter_texture_get_base_size:
|
|
|
|
* @texture: A #ClutterTexture
|
|
|
|
* @width: Pointer to gint to be populated with width value if non NULL.
|
|
|
|
* @height: Pointer to gint to be populated with height value if non NULL.
|
2008-02-12 13:41:44 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
* Gets the size in pixels of the untransformed underlying texture pixbuf data.
|
2008-02-12 13:41:44 +00:00
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
**/
|
|
|
|
void /* FIXME: rename to get_image_size */
|
|
|
|
clutter_texture_get_base_size (ClutterTexture *texture,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_TEXTURE (texture));
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
/* Attempt to realize, mainly for subclasses ( such as labels )
|
|
|
|
* which may not create pixbuf data and thus base size until
|
|
|
|
* realization happens.
|
|
|
|
*/
|
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (texture))
|
|
|
|
clutter_actor_realize (CLUTTER_ACTOR (texture));
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (width)
|
|
|
|
*width = texture->priv->width;
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (height)
|
|
|
|
*height = texture->priv->height;
|
2007-12-20 14:26:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_texture_set_area_from_rgb_data:
|
|
|
|
* @texture: A #ClutterTexture
|
|
|
|
* @data: Image data in RGB type colorspace.
|
2008-02-15 15:49:44 +00:00
|
|
|
* @has_alpha: Set to TRUE if image data has an alpha channel.
|
2007-12-20 14:26:07 +00:00
|
|
|
* @x: X coordinate of upper left corner of region to update.
|
|
|
|
* @y: Y coordinate of upper left corner of region to update.
|
|
|
|
* @width: Width in pixels of region to update.
|
|
|
|
* @height: Height in pixels of region to update.
|
2008-02-07 12:55:51 +00:00
|
|
|
* @rowstride: Distance in bytes between row starts on source buffer.
|
2008-12-23 16:29:29 +00:00
|
|
|
* @bpp: bytes per pixel (Currently only 3 and 4 supported,
|
2008-07-01 10:11:39 +00:00
|
|
|
* depending on @has_alpha)
|
2007-12-20 14:26:07 +00:00
|
|
|
* @flags: #ClutterTextureFlags
|
2007-12-24 16:24:26 +00:00
|
|
|
* @error: return location for a #GError, or %NULL
|
2007-12-20 14:26:07 +00:00
|
|
|
*
|
2008-02-15 15:49:44 +00:00
|
|
|
* Updates a sub-region of the pixel data in a #ClutterTexture.
|
2007-12-20 14:26:07 +00:00
|
|
|
*
|
2007-12-24 16:24:26 +00:00
|
|
|
* Return value: %TRUE on success, %FALSE on failure.
|
2007-12-20 14:26:07 +00:00
|
|
|
*
|
2008-12-05 14:08:06 +00:00
|
|
|
* Since: 0.6
|
2007-12-24 16:24:26 +00:00
|
|
|
*/
|
2007-12-20 14:26:07 +00:00
|
|
|
gboolean
|
|
|
|
clutter_texture_set_area_from_rgb_data (ClutterTexture *texture,
|
|
|
|
const guchar *data,
|
|
|
|
gboolean has_alpha,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gint rowstride,
|
|
|
|
gint bpp,
|
|
|
|
ClutterTextureFlags flags,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv;
|
2008-04-25 13:37:36 +00:00
|
|
|
CoglPixelFormat source_format;
|
2008-12-23 16:39:11 +00:00
|
|
|
CoglHandle cogl_texture;
|
2007-12-20 14:26:07 +00:00
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (has_alpha)
|
2007-12-20 14:26:07 +00:00
|
|
|
{
|
2008-04-25 13:37:36 +00:00
|
|
|
if (bpp != 4)
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Unsupported BPP");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
source_format = COGL_PIXEL_FORMAT_RGBA_8888;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (bpp != 3)
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Unsupported BPP");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
source_format = COGL_PIXEL_FORMAT_RGB_888;
|
2007-12-20 14:26:07 +00:00
|
|
|
}
|
2008-04-25 13:37:36 +00:00
|
|
|
if ((flags & CLUTTER_TEXTURE_RGB_FLAG_BGR))
|
|
|
|
source_format |= COGL_BGR_BIT;
|
|
|
|
if ((flags & CLUTTER_TEXTURE_RGB_FLAG_PREMULT))
|
|
|
|
source_format |= COGL_PREMULT_BIT;
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
clutter_actor_realize (CLUTTER_ACTOR (texture));
|
2007-12-20 14:26:07 +00:00
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
cogl_texture = clutter_texture_get_cogl_texture (texture);
|
|
|
|
if (cogl_texture == COGL_INVALID_HANDLE)
|
2008-04-25 13:37:36 +00:00
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Failed to realize actor");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-12-23 16:39:11 +00:00
|
|
|
if (!cogl_texture_set_region (cogl_texture,
|
2008-04-25 13:37:36 +00:00
|
|
|
0, 0,
|
|
|
|
x, y, width, height,
|
|
|
|
width, height,
|
|
|
|
source_format,
|
|
|
|
rowstride,
|
|
|
|
data))
|
|
|
|
{
|
|
|
|
g_set_error (error, CLUTTER_TEXTURE_ERROR,
|
|
|
|
CLUTTER_TEXTURE_ERROR_BAD_FORMAT,
|
|
|
|
"Failed to upload COGL texture data");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-12-20 14:26:07 +00:00
|
|
|
|
|
|
|
/* rename signal */
|
|
|
|
g_signal_emit (texture, texture_signals[PIXBUF_CHANGE], 0);
|
|
|
|
|
2008-03-19 15:05:16 +00:00
|
|
|
if (CLUTTER_ACTOR_IS_VISIBLE (texture))
|
|
|
|
clutter_actor_queue_redraw (CLUTTER_ACTOR (texture));
|
2007-12-20 14:26:07 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-02-06 14:39:04 +00:00
|
|
|
static void
|
|
|
|
on_fbo_source_size_change (GObject *object,
|
|
|
|
GParamSpec *param_spec,
|
|
|
|
ClutterTexture *texture)
|
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv = texture->priv;
|
|
|
|
guint w, h;
|
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
clutter_actor_get_transformed_size (priv->fbo_source, &w, &h);
|
2008-02-12 13:41:44 +00:00
|
|
|
|
2008-02-06 14:39:04 +00:00
|
|
|
if (w != priv->width || h != priv->height)
|
|
|
|
{
|
2009-01-18 14:51:19 +00:00
|
|
|
CoglTextureFlags flags = COGL_TEXTURE_NONE;
|
2009-02-06 13:50:16 +00:00
|
|
|
gint min_filter, mag_filter;
|
2009-04-30 13:32:19 +00:00
|
|
|
CoglHandle tex;
|
2009-01-18 14:51:19 +00:00
|
|
|
|
2008-02-08 10:37:38 +00:00
|
|
|
/* tear down the FBO */
|
2009-04-30 14:00:01 +00:00
|
|
|
if (priv->fbo_handle != COGL_INVALID_HANDLE)
|
|
|
|
cogl_handle_unref (priv->fbo_handle);
|
2008-02-06 14:39:04 +00:00
|
|
|
|
|
|
|
texture_free_gl_resources (texture);
|
|
|
|
|
2009-01-18 14:51:19 +00:00
|
|
|
priv->width = w;
|
|
|
|
priv->height = h;
|
|
|
|
|
|
|
|
if (priv->filter_quality == CLUTTER_TEXTURE_QUALITY_HIGH)
|
|
|
|
flags |= COGL_TEXTURE_AUTO_MIPMAP;
|
2008-02-06 14:39:04 +00:00
|
|
|
|
2009-04-30 13:32:19 +00:00
|
|
|
tex = cogl_texture_new_with_size (MAX (priv->width, 1),
|
|
|
|
MAX (priv->height, 1),
|
|
|
|
-1,
|
|
|
|
flags,
|
|
|
|
COGL_PIXEL_FORMAT_RGBA_8888);
|
|
|
|
|
|
|
|
cogl_material_set_layer (priv->material, 0, tex);
|
2008-02-06 14:39:04 +00:00
|
|
|
|
2009-02-06 13:50:16 +00:00
|
|
|
clutter_texture_quality_to_filters (priv->filter_quality,
|
|
|
|
&min_filter,
|
|
|
|
&mag_filter);
|
|
|
|
|
2009-04-30 13:32:19 +00:00
|
|
|
cogl_texture_set_filters (tex, min_filter, mag_filter);
|
|
|
|
|
|
|
|
priv->fbo_handle = cogl_offscreen_new_to_texture (tex);
|
2008-02-06 14:39:04 +00:00
|
|
|
|
2009-04-30 13:32:19 +00:00
|
|
|
/* The material now has a reference to the texture so it will
|
|
|
|
stick around */
|
|
|
|
cogl_handle_unref (tex);
|
2008-02-12 13:41:44 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->fbo_handle == COGL_INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
g_warning ("%s: Offscreen texture creation failed", G_STRLOC);
|
|
|
|
CLUTTER_ACTOR_UNSET_FLAGS (CLUTTER_ACTOR (texture),
|
|
|
|
CLUTTER_ACTOR_REALIZED);
|
|
|
|
return;
|
|
|
|
}
|
2008-02-06 14:39:04 +00:00
|
|
|
|
2009-01-12 17:12:24 +00:00
|
|
|
clutter_actor_set_size (CLUTTER_ACTOR (texture), w, h);
|
2008-02-06 14:39:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_fbo_parent_change (ClutterActor *actor,
|
|
|
|
ClutterActor *old_parent,
|
|
|
|
ClutterTexture *texture)
|
|
|
|
{
|
|
|
|
ClutterActor *parent = CLUTTER_ACTOR(texture);
|
|
|
|
|
|
|
|
while ((parent = clutter_actor_get_parent (parent)) != NULL)
|
|
|
|
if (parent == actor)
|
2008-02-08 10:37:38 +00:00
|
|
|
{
|
|
|
|
g_warning ("Offscreen texture is ancestor of source!");
|
|
|
|
/* Desperate but will avoid infinite loops */
|
|
|
|
clutter_actor_unparent (actor);
|
|
|
|
}
|
2008-02-06 14:39:04 +00:00
|
|
|
}
|
|
|
|
|
2008-02-01 15:29:00 +00:00
|
|
|
/**
|
|
|
|
* clutter_texture_new_from_actor:
|
2008-02-12 13:41:44 +00:00
|
|
|
* @actor: A source #ClutterActor
|
2008-02-01 15:29:00 +00:00
|
|
|
*
|
2008-02-12 13:41:44 +00:00
|
|
|
* Creates a new #ClutterTexture object with its source a prexisting
|
2008-02-08 10:37:38 +00:00
|
|
|
* actor (and associated children). The textures content will contain
|
2008-02-12 13:41:44 +00:00
|
|
|
* 'live' redirected output of the actors scene.
|
2008-02-01 15:29:00 +00:00
|
|
|
*
|
|
|
|
* Note this function is intented as a utility call for uniformly applying
|
2008-02-15 15:18:02 +00:00
|
|
|
* shaders to groups and other potential visual effects. It requires that
|
2008-12-23 16:29:29 +00:00
|
|
|
* the %CLUTTER_FEATURE_OFFSCREEN feature is supported by the current backend
|
2008-06-06 13:44:22 +00:00
|
|
|
* and the target system.
|
2008-02-08 10:37:38 +00:00
|
|
|
*
|
|
|
|
* Some tips on usage:
|
|
|
|
*
|
|
|
|
* <itemizedlist>
|
|
|
|
* <listitem>
|
2008-02-12 13:41:44 +00:00
|
|
|
* <para>The source actor must be made visible (i.e by calling
|
2008-07-04 10:44:18 +00:00
|
|
|
* #clutter_actor_show).</para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
|
|
|
* <para>The source actor must have a parent in order for it to be
|
|
|
|
* allocated a size from the layouting mechanism. If the source
|
|
|
|
* actor does not have a parent when this function is called then
|
|
|
|
* the ClutterTexture will adopt it and allocate it at its
|
|
|
|
* preferred size. Using this you can clone an actor that is
|
|
|
|
* otherwise not displayed. Because of this feature if you do
|
|
|
|
* intend to display the source actor then you must make sure that
|
|
|
|
* the actor is parented before calling
|
|
|
|
* clutter_texture_new_from_actor() or that you unparent it before
|
|
|
|
* adding it to a container.</para>
|
2008-08-01 12:23:57 +00:00
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
|
|
|
* <para>When getting the image for the clone texture, Clutter
|
|
|
|
* will attempt to render the source actor exactly as it would
|
|
|
|
* appear if it was rendered on screen. The source actor's parent
|
|
|
|
* transformations are taken into account. Therefore if your
|
|
|
|
* source actor is rotated along the X or Y axes so that it has
|
|
|
|
* some depth, the texture will appear differently depending on
|
|
|
|
* the on-screen location of the source actor. While painting the
|
|
|
|
* source actor, Clutter will set up a temporary asymmetric
|
|
|
|
* perspective matrix as the projection matrix so that the source
|
|
|
|
* actor will be projected as if a small section of the screen was
|
|
|
|
* being viewed. Before version 0.8.2, an orthogonal identity
|
|
|
|
* projection was used which meant that the source actor would be
|
|
|
|
* clipped if any part of it was not on the zero Z-plane.</para>
|
2008-02-08 13:52:11 +00:00
|
|
|
* </listitem>
|
2008-02-08 10:37:38 +00:00
|
|
|
* <listitem>
|
|
|
|
* <para>Avoid reparenting the source with the created texture.</para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
2008-02-12 13:41:44 +00:00
|
|
|
* <para>A group can be padded with a transparent rectangle as to
|
2008-02-08 10:37:38 +00:00
|
|
|
* provide a border to contents for shader output (blurring text
|
|
|
|
* for example).</para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
2008-02-12 13:41:44 +00:00
|
|
|
* <para>The texture will automatically resize to contain a further
|
2008-02-15 15:18:02 +00:00
|
|
|
* transformed source. However, this involves overhead and can be
|
2008-02-08 10:37:38 +00:00
|
|
|
* avoided by placing the source actor in a bounding group
|
|
|
|
* sized large enough to contain any child tranformations.</para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
2008-03-18 17:56:50 +00:00
|
|
|
* <para>Uploading pixel data to the texture (e.g by using
|
2008-04-25 13:37:36 +00:00
|
|
|
* clutter_actor_set_from_file()) will destroy the offscreen texture data
|
2008-02-15 15:18:02 +00:00
|
|
|
* and end redirection.</para>
|
2008-02-08 10:37:38 +00:00
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
2008-04-25 13:37:36 +00:00
|
|
|
* <para>cogl_texture_get_data() with the handle returned by
|
|
|
|
* clutter_texture_get_cogl_texture() can be used to read the
|
|
|
|
* offscreen texture pixels into a pixbuf.</para>
|
2008-02-08 10:37:38 +00:00
|
|
|
* </listitem>
|
|
|
|
* </itemizedlist>
|
2008-02-01 15:29:00 +00:00
|
|
|
*
|
2008-02-15 15:18:02 +00:00
|
|
|
* Return value: A newly created #ClutterTexture object, or %NULL on failure.
|
2008-02-08 13:52:11 +00:00
|
|
|
*
|
|
|
|
* Since: 0.6
|
|
|
|
*/
|
2008-02-01 15:29:00 +00:00
|
|
|
ClutterActor *
|
|
|
|
clutter_texture_new_from_actor (ClutterActor *actor)
|
|
|
|
{
|
|
|
|
ClutterTexture *texture;
|
|
|
|
ClutterTexturePrivate *priv;
|
|
|
|
guint w, h;
|
|
|
|
|
2008-02-03 01:53:10 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), NULL);
|
|
|
|
|
2008-02-01 15:29:00 +00:00
|
|
|
if (clutter_feature_available (CLUTTER_FEATURE_OFFSCREEN) == FALSE)
|
|
|
|
return NULL;
|
|
|
|
|
2008-02-03 01:53:10 +00:00
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (actor))
|
|
|
|
{
|
|
|
|
clutter_actor_realize (actor);
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-02-03 01:53:10 +00:00
|
|
|
if (!CLUTTER_ACTOR_IS_REALIZED (actor))
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-06-10 Emmanuele Bassi <ebassi@openedhand.com>
Bug #815 - Split up request, allocation, and paint box
* clutter/clutter-actor.[ch]: Rework the size allocation,
request and paint area. Now ::request_coords() is called
::allocate(), and ::query_coords() has been split into
::get_preferred_width() and ::get_preferred_height(). See
the documentation and the layout test on how to implement
a container and layout manager with the new API. (#915,
based on a patch by Havoc Pennington, Lucas Rocha and Johan
Bilien)
* clutter/clutter-clone-texture.c: Port CloneTexture to
the new size negotiation API; it just means forwarding
the requests to the parent texture.
* clutter/clutter-deprecated.h: Add deprecated and replaced
API.
* clutter/clutter-entry.c: Port Entry to the new size
negotiation API.
* clutter/clutter-group.c: Port Group to the new size
negotiation API; the semantics of the Group actor do not
change.
* clutter/clutter-label.c: Port Label to the new size
negotiation API, and vastly simplify the code.
* clutter/clutter-main.[ch]: Add API for executing a
relayout when needed.
* clutter/clutter-private.h: Add new Stage private API.
* clutter/clutter-rectangle.c: Update the get_abs_opacity()
call to get_paint_opacity().
* clutter/clutter-stage.c:
(clutter_stage_get_preferred_width),
(clutter_stage_get_preferred_height),
(clutter_stage_allocate),
(clutter_stage_class_init): Port Stage to the new size
negotiation API.
* clutter/clutter-texture.c: Port Texture to the new size
negotiation API.
* clutter/clutter-types.h: Add ClutterRequestMode enumeration.
* clutter/x11/clutter-stage-x11.c: Port the X11 stage
implementation to the new size negotiation API.
* tests/Makefile.am: Add the layout manager test case.
* tests/test-opacity.c: Update.
* tests/test-project.c: Update.
* tests/test-layout.c: Test case for a layout manager implemented
using the new size negotiation API; the layout manager handles
both transformed and untransformed children.
2008-06-10 17:07:52 +00:00
|
|
|
clutter_actor_get_transformed_size (actor, &w, &h);
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-02-03 01:53:10 +00:00
|
|
|
if (w == 0 || h == 0)
|
|
|
|
return NULL;
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-02-08 10:37:38 +00:00
|
|
|
/* Hopefully now were good.. */
|
2008-12-23 16:29:29 +00:00
|
|
|
texture = g_object_new (CLUTTER_TYPE_TEXTURE,
|
2008-06-06 13:44:22 +00:00
|
|
|
"disable-slicing", TRUE,
|
|
|
|
NULL);
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-02-03 01:53:10 +00:00
|
|
|
priv = texture->priv;
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-07-04 10:44:18 +00:00
|
|
|
priv->fbo_source = g_object_ref_sink (actor);
|
|
|
|
|
|
|
|
/* If the actor doesn't have a parent then claim it so that it will
|
|
|
|
get a size allocation during layout */
|
|
|
|
if (clutter_actor_get_parent (actor) == NULL)
|
|
|
|
clutter_actor_set_parent (actor, CLUTTER_ACTOR (texture));
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2008-02-06 14:39:04 +00:00
|
|
|
/* Connect up any signals which could change our underlying size */
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"notify::width",
|
|
|
|
G_CALLBACK(on_fbo_source_size_change),
|
|
|
|
texture);
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"notify::height",
|
|
|
|
G_CALLBACK(on_fbo_source_size_change),
|
|
|
|
texture);
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"notify::scale-x",
|
|
|
|
G_CALLBACK(on_fbo_source_size_change),
|
|
|
|
texture);
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"notify::scale-y",
|
|
|
|
G_CALLBACK(on_fbo_source_size_change),
|
|
|
|
texture);
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"notify::rotation-angle-x",
|
|
|
|
G_CALLBACK(on_fbo_source_size_change),
|
|
|
|
texture);
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"notify::rotation-angle-y",
|
|
|
|
G_CALLBACK(on_fbo_source_size_change),
|
|
|
|
texture);
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"notify::rotation-angle-z",
|
|
|
|
G_CALLBACK(on_fbo_source_size_change),
|
|
|
|
texture);
|
|
|
|
|
|
|
|
/* And a warning if the source becomes a child of the texture */
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"parent-set",
|
|
|
|
G_CALLBACK(on_fbo_parent_change),
|
|
|
|
texture);
|
|
|
|
|
2008-02-03 01:53:10 +00:00
|
|
|
priv->width = w;
|
|
|
|
priv->height = h;
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2009-01-12 17:12:24 +00:00
|
|
|
clutter_actor_set_size (CLUTTER_ACTOR (texture), priv->width, priv->height);
|
2008-02-01 15:29:00 +00:00
|
|
|
|
2009-01-12 17:12:24 +00:00
|
|
|
return CLUTTER_ACTOR (texture);
|
2008-02-01 15:29:00 +00:00
|
|
|
}
|
2008-02-03 23:25:12 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
texture_fbo_free_resources (ClutterTexture *texture)
|
|
|
|
{
|
|
|
|
ClutterTexturePrivate *priv;
|
|
|
|
|
|
|
|
priv = texture->priv;
|
|
|
|
|
|
|
|
CLUTTER_MARK();
|
|
|
|
|
|
|
|
if (priv->fbo_source != NULL)
|
|
|
|
{
|
2008-07-04 10:44:18 +00:00
|
|
|
/* If we parented the texture then unparent it again so that it
|
|
|
|
will lose the reference */
|
|
|
|
if (clutter_actor_get_parent (priv->fbo_source)
|
|
|
|
== CLUTTER_ACTOR (texture))
|
|
|
|
clutter_actor_unparent (priv->fbo_source);
|
|
|
|
|
2008-02-12 13:41:44 +00:00
|
|
|
g_signal_handlers_disconnect_by_func
|
|
|
|
(priv->fbo_source,
|
|
|
|
G_CALLBACK(on_fbo_parent_change),
|
2008-02-08 10:37:38 +00:00
|
|
|
texture);
|
2008-02-12 13:41:44 +00:00
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func
|
|
|
|
(priv->fbo_source,
|
|
|
|
G_CALLBACK(on_fbo_source_size_change),
|
2008-02-08 10:37:38 +00:00
|
|
|
texture);
|
|
|
|
|
2008-02-03 23:25:12 +00:00
|
|
|
g_object_unref (priv->fbo_source);
|
2008-02-08 10:37:38 +00:00
|
|
|
|
2008-02-03 23:25:12 +00:00
|
|
|
priv->fbo_source = NULL;
|
|
|
|
}
|
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
if (priv->fbo_handle != COGL_INVALID_HANDLE)
|
2008-02-03 23:25:12 +00:00
|
|
|
{
|
2009-04-01 16:16:44 +00:00
|
|
|
cogl_handle_unref (priv->fbo_handle);
|
2008-04-25 13:37:36 +00:00
|
|
|
priv->fbo_handle = COGL_INVALID_HANDLE;
|
2008-02-03 23:25:12 +00:00
|
|
|
}
|
|
|
|
}
|