Using test-cogl-vertex-buffer as a test case which is CPU bound due to
hls -> rgb conversions this alternative algorithm looked to be ~10%
faster when tested on an X61s Lenovo.
Queuing an animation on an actor cannot be done from within the
::completed signal handler, because we guarantee that the Animation
instance is valid and attached to the actor it animates for the
whole duration of the signal emission chain.
In order to queue animations you have to install an idle handler
on the main loop, and call clutter_actor_animate() inside it.
The documentation should be more clear about this caveat in the
memory management of ClutterAnimations created by the animate()
family of functions.
There are various constraints for when we can support multi-texturing and
when they can't be met we try and print a clear warning explaining why the
operation isn't supported, but we shouldn't endlessly repeat the warning for
every primitive of every frame. This patch fixes that.
This function was renamed a while ago in the .c file from
cogl_vertex_buffer_draw_range_elements but the corresponding .h and
doc/reference/cogl changes weren't made.
For convenience it is now valid to avoid a seperate call to
cogl_vertex_buffer_submit() and assume that the _draw() calls will do this
for you (though of course if you do this you still need to ensure the
attribute pointers remain valid until your draw call.)
Bug 1495 - Timelines run 4% short
Previously the timelines were timed by calculating the interval
between each frame stored as an integer number of milliseconds so some
precision is lost. For example, requesting 60 frames per second gets
converted to 16 ms per frame which is actually 62.5 frames per
second. This makes the timeline shorter by 4%.
This patch merges the common code for timing from the timeout pools
and frame sources into an internal clutter-timeout-interval file. This
stores the interval directly as the FPS and counts the number of
frames that have been reached instead of the elapsed time.
The Animation API should follow this pattern:
- functions with an Interval as part of the arguments should have
"interval" inside their name, e.g.:
clutter_animation_bind_interval
clutter_animation_update_interval
- functions dealing with property names should have "property"
inside their name, e.g.:
clutter_animation_has_property
clutter_animation_unbind_property
- unless -
- functions dealing with a property and its value should not
have any modifier, e.g.:
clutter_animation_bind
The change from update_property() to update_interval() frees up
clutter_animation_update(), to be added at a later date.
Bug 1454 - move queue_redraw virtualization to ClutterActor
The ClutterActor::queue-redraw signal allows parent containers to
track whether their children need a redraw.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
A common use of setting clip is to keep an actor inside its allocation;
right now to do this you have to set up a callback on notify::allocation.
There's no overhead added by sticking another bit in ClutterActor
clip-to-allocation that will clip painting to the allocation if set.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Bug 1419 - Add clutter_animation_bind, rename clutter_animation_bind_interval
This is a different approach from the clutter_actor_animatev
vector variant. The single call should be even easier on
automatic bindings, since calls can be chained like:
new Clutter.Animation({object: myactor}).bind("x", 42).bind("y", 43);
Note clutter_animation_bind_property which took a ClutterInterval
is renamed to clutter_animation_bind_interval for clarity, and to
discourage use since there are friendlier APIs about.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
If we are animating an actor using the clutter_actor_animate*() family
of functions we might want to expose a getter for the Animation instance
we are using, to avoid excessing bookkeeping.
The ::completed signal requires an emitter in case we want to stop
the animation and safely dispose it inside application code without
breaking invariants.
The memory management of the ClutterAnimation instances should be
heavily documented, given its "automagical" nature, so that other
people might understand it and avoid breaking it in the future.
It's reasonably normal for a relayout of the stage to cause the stage
to be queued for drawing; for this reason we should do the relayout before
we clear stage->update_idle. (But want to clear update_idle() before actually
doing the redraw to handle the corner case where the draw queues another
redraw.)
Bug 1499 - clutter_actor_notify_if_geometry_changed causes sync
layout cycles
Whenever clutter_actor_set_{width,height,x,y,size...} is used, extra
synchronous size requests are triggered in
clutter_actor_notify_if_geometry_changed.
If the get_preferred_width() and get_preferred_height() implementations
are particularly costly (e.g. ClutterText) this will result in a performance
impact.
To avoid excessive allocation or requisition cycles we use the
cached values and flags. If we don't have an allocation, we assume
that we need to notify all the properties; if we don't have a size
requisition we notify only width and height; finally, if we do have
a valid allocation we notify only on the changed values.
_cogl_add_path_to_stencil_buffer and _cogl_add_stencil_clip were leaving
the projection matrix current when calling cogl_rectangle which was
upsetting _cogl_current_matrix_state_flush.
Adds glFrustum wrappers (GLES only accepts floats not doubles, and GLES2
needs to use our internal cogl_wrap_glFrustumf)
Adds GL_TEXTURE_MATRIX getter code in cogl_wrap_glGetFloatv
Adds a GL_TEXTURE_MATRIX define for GLES2
Its not intended that users should use these with any other matrix mode, and
internally we now have the _cogl_current_matrix API if we need to play with
other modes.
If we later add internal flags to CoglMatrix then this code wouldn't
initialize those flags. The ways it's now done adds a redundant copy, but
if that turns out to be something worth optimizing we can look again at
using a cast but adding another way for initializing internal flags.
This is useful because sometimes we need to get the current matrix, which
is too expensive when indirect rendering.
In addition, this virtualization makes it easier to clean up the API in
the future.
Only have load-data-async and load-async properties, both are construct
only and the latter adds the former load-size-async behavior on top of
load-data-async.
This commit yesterday:
89e3e3a4cc
[animation] Add vector variants for ::animate()
broke the "fixed::" attribute on properties in clutter_actor_animate(),
because the fixed:: part is still on the string when it checks to see if
it's a valid property the class knows about.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
As a convenience, if NULL is passed for the text argument of
clutter_text_set_text() (and for consistency,
clutter_text_set_markup()), treat that the same as "".
Bug 1480 - Clutter groups don't output their name when
CLUTTER_DEBUG=paint
This is a really useful thing to do debugging-wise - as you can see
istantly when (and if) clutter objects are being drawn - as often
there's quite a hierarchy of objects in groups.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Add missing (out) annotations to the doc comments for ClutterActor methods
with multiple return values.
Fix the definition of clutter_actor_get_allocation_vertices() to be
consistent with the declaration and have verts[4] rather than verts[].x
http://bugzilla.openedhand.com/show_bug.cgi?id=1481
Bug 1501 - clutter_text_insert_text not working right with non-onebyte
character
In clutter_text_insert_text(), the position is expressed in characters, not
in bytes.
Actually, it turns out to be working on bytes, so when there are already
multi-byte character in the text buffer, insert text at the position after
the multi-byte character will not work right.
Also, the position is not updated after the insert work is done.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Bug 1500 - [Patch] clutter_text crash with non one-byte utf8 text exceed
max_length
In clutter_text_set_text_internal(), when text length in character is greater
than max_length, and there are multi-byte character in it, then the new text
string buffer is not malloc()'ed with right length. This will cause the app to
crash with segmention fault.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
The fixed-point values are converted to integers, which obviously
messes up the conversion. Instead, they should be converted to
floating point values before normalizing to bytes for the assignment
to ClutterColor components.
$(builddir) isn't always defined in earlier versions of Automake
(although I can't track down exactly which version it appeared
in). According to the autoconf docs it is "rigorously equal to `.'" so
we might as well not use it.
The private CoglContext is created using g_malloc() and not
zeroed; this means we have to initialize the values we are
going to check, to avoid hitting garbage.
Thanks to Tommi Komulainen.
Commit a383929 added the $(srcdir) prefix to all of the source files
but some files are generated by the configure script and other make
rules so they actually live in $(builddir). Out-of-tree builds
therefore broke.
Bug 1438 - Implicit Animation API could use animatev variants
The clutter_actor_animate* family of functions use va_lists to
handle the property/value pairs for the final state of the
animation.
Language bindings have problems with variadic arguments functions,
and usually prefer vector-based API which allow a greater level
of control and conversion from native data types.
For each variadic arguments function in the clutter_actor_animate*
family there should be a vector-based version that takes:
- the number of property/value pairs
- a constant array of constant strings
- an array of GValues
Most of the internal implementation can be refactored from the
current one, thus both the var_args and the vector entry points
share a common implementation of the code; then, both versions
of the API are just loops over a list of arguments.
Based on a patch by: Robert Carr <carrr@rpi.edu>
Since the switch from fixed point to floating point, and the introduction
of CoglFixed, ClutterFixed has been typedef'd into a float. This makes
ClutterFixed the worst fixed point API ever.
Now that Clutter has been migrated to CoglFixed and gfloat whenever needed,
ClutterFixed can be safely removed.
The only thing that Clutter should still provide is ClutterParamSpecFixed,
for installing fixed point properties into GObject classes.
The ClutterFixed symbols have been entirely removed from the API.
A GValue containing a ClutterUnit should be transformable into a
GValue holding an integer, a floating point value or a fixed point
value.
This means adding more transformation functions when registering
the ClutterUnit GType.
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.
The type machinery for CoglFixed should be implemented by COGL
itself, now that COGL exports the GType of its types.
This allows moving most of what ClutterFixed did directly to
CoglFixed where it belongs.
ClutterFixed as a type is going away, superceded by CoglFixed. The
fixed point entry points in the API should be ported to the
CoglFixed type so that they are useful again.
Since the conversion of a floating point value to a fixed point
value is already done in double precision we can safely expose
a macro that converts a double precision floating point value to
a CoglFixed one.
Grabs are an entirely evil way to override the whole event delivery
machinery that Clutter has in place.
A pointer grab can be effectively replaced by a much more reliable
::captured-event signal handler, for instance.
Sometimes, grabs are a necessary evil -- and that is why Clutter
exposes them in the API; that should not fool anyone into thinking
that they should be used unless strictly necessary.
When calling clutter_actor_animate() on an actor that is being
currently animated the default behaviour is to update the duration
of the animation; the easing mode; update all the common properties;
and finally add the new properties.
This:
clutter_actor_animate (actor, 500, CLUTTER_LINEAR,
"width", 100,
"height", 100,
NULL);
clutter_actor_animate (actor, 250, CLUTTER_EASE_IN_CUBIC,
"x", 100,
"y", 100,
"height", 200,
NULL);
Is logically equivalent to:
clutter_actor_animate (actor, 250, CLUTTER_EASE_IN_CUBIC,
"x", 100,
"y", 100,
"width", 100,
"height", 200,
NULL);
The documentation of the function should be slightly more verbose
in describing the default behaviour.
The generation of the GObject introspection data has broken
the distcheck phase.
The location of the header and source files should always be
depending on the $(top_srcdir) and $(srcdir) variables,
respectively; the special handling of the COGL API inside the
GIR generation should also take those two variables into
account.
COGL should ship its own pkg-config file, obviously still pointing
to Clutter's compiler flags and linking options, for COGL-specific
variables that might be queried at configure time.
For instance, it's easier (and less verbose) to do:
PKG_CHECK_EXISTS([cogl-gl-1.0],
[has_gl_backend=yes],
[has_gl_backend=no])
Than doing:
AC_MSG_CHECKING([for GL support in COGL])
cogl_backend=`$PKG_CONFIG --variable=cogl clutter-0.9`
if test x$cogl_backend = xgl; then
has_gl_backend=yes
AC_MSG_RESULT([found])
else
has_gl_backend=no
AC_MSG_RESULT([not found])
fi
ClutterShader contains a lot of duplication, as the vertex and fragment
shader code paths are mostly the same.
The code should be simplified by adding new internal functions that can
be called with a value from the already present ClutterShaderType
enumeration.
In the future it'll also be possible to deprecate the current split API
and expose the generic accessors instead.
The ClutterColor API has some inconsistencies:
- the string deserialization function does not match the rest of
the conversion function naming policy; the naming should be:
clutter_color_parse() -> clutter_color_from_string()
and the first parameter should be the ClutterColor that will
be set from the string, not the string itself (a GDK-ism).
- the fixed point API should not be exposed, especially in the
form of ClutterFixed values
- the non-fixed point HLS conversion functions do not make any
sense. The values returned should be:
hue := range [ 0, 360 ]
luminance := range [ 0, 1 ]
saturation := range [ 0, 1 ]
like the current fixed point API does. Returning a value in
the [ 0, 255 ] range is completely useless
- the clutter_color_equal() should be converted for its use inside
a GHashTable; a clutter_color_hash() should be added as well
- the second parameter of the clutter_color_shade() function should
be the shading factor, not the result (another GDK-ism). this way
the function call can be translated from this:
color.shade(out result, factor)
to the more natural:
color.shade(factor, out result)
This somewhat large commit fixes all these issues and updates the
internal users of the API.
The CoglPango code falls under the COGL "jurisdiction"; this means
that it cannot include Clutter headers unless strictly necessary.
The CoglPangoRenderer code was using the CLUTTER_NOTE() macro. Now
that COGL has it's own COGL_NOTE() similar macro, CoglPango should
use that and avoid including clutter-debug.h (which pulls in
clutter-private.h which in turn pulls in clutter-actor.h).
A new flag, COGL_DEBUG_PANGO, has been added to the COGL debug
flags.
Bug 1493 - GL ES does not work since Jan 9 in PowerVR SGX 535, Intel
The mapped flag needs to be set on the stage otherwise
clutter_actor_queue_redraw will never queue a redraw and never draw
anything.
In these two backends there is not really a way to hide the stage so
they both set the mapped flag immediatly when clutter_actor_show is
called.
Using glEnable() directly confuses COGL and can result in problems
like subsequent pick operations not working correctly. Get the
material for the ClutterTexture and call cogl_material_flush_gl_state()
instead.
http://bugzilla.openedhand.com/show_bug.cgi?id=1483
When event delivery is invoked by synthetic events through
clutter_do_event from inside an event handler clutter was silently
ignoring it, this warning will hopefully help resolving some issues.
In the future if we want to annotate matrices with internal flags, and add
caching of the inverse matrix then we need to ensure that all matrix
modifications are done by cogl_matrix API so we'd know when to dirty the
cache or update the flags.
This just adds documentation to that effect, and assuming the most likley
case where someone would try and directly write to matrix members would
probably be to load a constant matrix other than the identity matrix; I
renamed cogl_matrix_init_from_gl_matrix to cogl_matrix_init_from_array to
make it seem more general purpose.
The font options accessors in ClutterBackend only deal with const
cairo_font_options_t values, since:
- set_font_options() will copy the font options
- get_font_options() will return a pointer to the internal
font options
Not using const in these cases makes the API confusing and might lead
to erroneous calls to cairo_font_options_destroy().
gcc warns about casting a pointer to a guint because it is a different
size on 64-bit machines. However the pointer is only used as a hash so
it doesn't matter if we lose the most significant bits. The patch
makes it use GPOINTER_TO_UINT instead which first casts it to a gulong
and avoids the warning.
Instead of creating a separate thread for each texture load, the loads
are now queued in a thread pool which will use at most 3 textures at a
time. This avoids the potentially large overhead of creating and
destroying a thread for every image while still avoiding throttling
the CPU if a large number of textures are loaded at the same time.
If the load is cancelled the old code needed to join the thread which
effectively meant it had to wait for the load to finish. With this
model the threads are owned by the thread pool so there is no need to
wait for them to finish. Instead, each thread is given its own thread
data which we can use to mark the thread as aborted. Once the load is
finished the thread will check whether it is aborted before setting
the texture data. That way the ClutterTexture can just disown threads
that it needs to cancel.
The duration in ClutterMedia is currently expressed in integer multiples
of a second. This does not offer enough granularity for media playback
that has fractionary durations -- 2.3 seconds; 1 minute, 23.4 seconds;
1 hour, 23 minutes, 4.5 seconds; etc.
The duration value should be expressed in seconds with a sub-second
granularity; for this reason, a double should be used insted of an
unsigned integer.
The semantics haven't changed: the :duration property still exposes
seconds.
Bug 1474 - ClutterMedia interface
The GET_INTERFACE() macro is still using the old type name of
the ClutterMedia interface structure in the cast.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Bug 1473 - CoglPixelFormat enum data must be declared static
When registering an enumeration GType, the GEnumValue or GFlagsValue
arrays must be declared static; otherwise, you get a segmentation
fault when calling the function again.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Instead of using a fixed size array for storing the scenegraph sub-node
during event delivery we should use a GPtrArray. The benefits are:
- a smaller allocation
- no undocumented yet binding constraint on the scenegraph size