Commit Graph

588 Commits

Author SHA1 Message Date
Tomeu Vizoso
0ede622f51 Give a chance to effects for running when picking
Some effects can change the actor's shape and position, so they need
to run when picking.

https://bugzilla.gnome.org/show_bug.cgi?id=651700
2011-06-13 15:45:36 +01:00
Tomeu Vizoso
700c543850 Rename ClutterEffect::run to ClutterEffect::paint
In preparation for adding ClutterEffect::pick

https://bugzilla.gnome.org/show_bug.cgi?id=651700
2011-06-13 15:44:58 +01:00
Emmanuele Bassi
4f0769d69d docs: Update missing documentation 2011-06-13 13:47:09 +01:00
Emmanuele Bassi
2b81d90dd7 Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.

We always used it to conform to the platform, at least for public-facing
API.

At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.

Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:

  https://bugzilla.gnome.org/show_bug.cgi?id=644611

Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 16:06:24 +01:00
Emmanuele Bassi
19c986c0c6 actor: Avoid queueing redraws during destruction
If an actor or the stage to which it belongs are being destroyed then
there is no point in queueing a redraw that will not be seen anyway.
Bailing out early also avoids the case in which a redraw is queued
during destruction wil cause redraw entries will be added to the Stage,
which will take references on it and cause the Stage never to be
finalized.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2652
2011-06-07 14:25:17 +01:00
Emmanuele Bassi
835fc2381c Deprecate ClutterShader
With the instantiatable ClutterShaderEffect, the only reason for
ClutterShader to exist is to make the ClutterActor::paint implementation
miserable.

Yes, ClutterShader doesn't use a FBO, so it's "more efficient" on
ClutterTextures. It's also generally wrong unless you know *exactly* how
the actor's pipeline is set up — something we cannot even guarantee
internally unless we start doing lame type checks.
2011-06-07 14:09:53 +01:00
Chris Lord
f9d7650b97 actor: Ensure the validity of the queue_redraw_entry pointer
In _clutter_actor_queue_redraw_with_clip, there was the possibility that
the actor will add itself to the stage's redraw queue without keeping track
of the allocated list member.

In clutter_actor_unparent, the redraw queue entry was being invalidated
before the mapped notify signal was being fired, meaning that queueing a
redraw of an unmapped actor in the mapped notification callback could
cause a crash.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2621
2011-05-14 01:14:22 +01:00
Neil Roberts
d95258e987 clutter-actor: Store the queue_redraw_entry when queueing a redraw
_clutter_stage_queue_actor_redraw returns a pointer to the
ClutterStageQueueRedrawEntry struct which it allocates. The actor is
expected to store a pointer to this so that it doesn't need to search
the list of queued redraws next time a queue redraw is called. However
_clutter_actor_queue_redraw_full wasn't storing this pointer which
meant that it thought every queue redraw was the first queue
redraw. That meant that queueing a redraw with a clip or an effect
would override any previous attempts to queue a redraw instead of
trying to combine them.

I think this happened because the old queue_redraw_with_clip also
didn't store the pointer and queue_redraw_full was based on that.
2011-05-13 15:36:38 +01:00
Neil Roberts
701440efd8 clutter-actor: Add a 'has_overlaps' virtual
This adds a virtual to ClutterActor so that an actor subclass can
report whether it has overlapping primitives. ClutterActor uses this
to determine whether it needs to use ClutterFlattenEffect to implement
the opacity property. The default implementation of the virtual
returns TRUE which means that most actors will end up being redirected
offscreen when the opacity != 255. ClutterTexture and ClutterRectangle
override this to return FALSE because they should never need to be
redirected. ClutterClone overrides it to divert to the source.

The values for the ClutterOffscreenRedirect enum have changed to:

AUTOMATIC_FOR_OPACITY

 The actor will only be redirected if has_overlaps returns TRUE and
 the opacity is < 255

ALWAYS_FOR_OPACITY

 The actor will always be redirected if the opacity < 255 regardless
 of the return value of has_overlaps

ALWAYS

 The actor will always be redirected offscreen.

This means that the property can't be used to prevent the actor from
being redirected but only to increase the likelihood that it will be
redirected.

ClutterActor now adds and removes the flatten effect depending on
whether flattening is needed directly in clutter_actor_paint(). There
are new internal versions of add/remove_effect that don't queue a
redraw. This means that ClutterFlattenEffect is now just a no-op
subclass of ClutterOffscreen. It is only needed because
ClutterOffscreen is abstract. Removing the effect also makes it so
that the cached image will be freed as soon as an actor is repainted
without being flattened.
2011-05-13 01:46:32 +01:00
Neil Roberts
7f78237ee5 clutter-actor: Add an 'offscreen-redirect' property
This adds a property which can be used to redirect the actor through
an FBO before painting so that it becomes flattened in an image. The
image can be used as a cache to avoid having to repaint the actor if
something unrelated in the scene changes. It can also be used to
implement correct opacity even if the actor has overlapping
primitives. The property is an enum that takes three values:

CLUTTER_OFFSCREEN_REDIRECT_NEVER: The default behaviour which is to
  never flatten the actor.

CLUTTER_OFFSCREEN_REDIRECT_ALWAYS: The actor is always redirected
  through an FBO.

CLUTTER_OFFSCREEN_REDIRECT_ONLY_FOR_OPACITY: The actor is only
  redirected through an FBO if the paint opacity is not 255. This
  value would be used if the actor wants correct opacity. It will
  avoid the overhead of using an FBO whenever the actor is fully
  opaque.

The property is implemented by installing a ClutterFlattenEffect.
ClutterFlattenEffect is a new internal class which subclasses
ClutterOffscreen to redirect the painting to an FBO. When
ClutterOffscreen paints, the effect sets an opacity override on the
actor so that the image will always contain the actor at full
opacity. The opacity is then applied to the resulting image before
painting it to the stage. This means the actor does not need to be
redrawn while the opacity is being animated.

The effect has a high internal priority so that it will always occur
before any other effects and it gets hidden from the application.
2011-05-13 01:46:32 +01:00
Neil Roberts
8df8d4ff0f clutter-actor: Redraw or relayout when clearing effects or constraints
When calling clutter_actor_clear_constraints the layout of the actor
may change so we need to queue a relayout. Similarly when the effects
are cleared we need to queue a redraw.
2011-05-13 01:46:32 +01:00
Neil Roberts
9423214783 clutter-actor-meta: Add an internal 'priority' property
This adds a priority property to all ClutterActorMetas. The
ClutterMetaGroup keeps the list sorted so that higher priority metas
remain at the beginning of the list. The priority is a signed integer
with the default as zero. An actor meta can therefore be put before
all default metas with a positive number, or after with a negative
number.

There are constants to set an 'internal' priority. The intention is
that applications wouldn't be allowed to use these values so that we
can keep special internal metas to that are before or after all
application metas.

The property isn't a real GObject property because for now it is
completely internal and only used to implement the 'transparency'
property of ClutterActor. ClutterMetaGroup doesn't currently resort
the list if the property changes so if we wanted to make it public we
should either make it construct-only or make the meta group listen for
changes on the property and resort accordingly.

The methods in ClutterActor that get the list of metas now use a new
function that filters out internal metas from the meta
group. Similarly for clearing the metas, the internal metas are left
in.
2011-05-13 01:46:32 +01:00
Neil Roberts
00b733a85a clutter-effect: Add clutter_effect_queue_rerun
This adds a new public function to queue a rerun of an effect. If
nothing else queues a redraw then when the effect's actor is painted
the effect will be run without the CLUTTER_EFFECT_RUN_ACTOR_DIRTY
flag. This allows parametrised offscreen effects to report that they
need to redraw the image without having to redraw the underlying
actor. This will be used to implement the 'transparency' effect of
ClutterActor.

If multiple redraws are queued with different effects then redrawing
is started from the one that occurs last in the list of effects.

Internally the function is a wrapper around the new function
_clutter_actor_queue_redraw_full. This is intended to be the sole
point of code for queuing redraws on an actor. It has parameters for
the clip and the effect. The other two existing functions to queue a
redraw (one with a clip and one without) now wrap around this function
by passing a NULL effect.
2011-05-13 01:46:32 +01:00
Neil Roberts
c3aa4d24bf clutter-effect: Add a 'run' virtual
This adds a new virtual to ClutterEffect which is intended to be a
more flexible replacement for the pre and post_paint functions. The
implementation of a run virtual would look something like this:

void
effect_run (ClutterEffect *effect,
            ClutterEffectRunFlags flags)
{
  /* Set up state */
  /* ... */

  /* Chain to the next item in the paint sequence */
  clutter_actor_continue_paint (priv->actor);

  /* Clean up state */
  /* ... */
}

ClutterActor now just calls this virtual instead of the pre_paint and
post_paint functions. It keeps track of the next effect in the list so
that it knows what to do when clutter_actor_continue_paint is
called. clutter_actor_continue_paint is a new function added just for
implementing effects.

The default implementation of the run virtual just calls pre_paint and
post_paint so that existing effects will continue to work.

An effect is allowed to conditionally skip calling
clutter_actor_continue_paint(). This is useful to implement effects
that cache the image of an actor. The flags parameter can be used to
determine if the actor is dirty since the last paint. ClutterActor
sets this flag whenever propagated_one_redraw is TRUE which means that
a redraw for this actor or one of its children was queued.
2011-05-13 01:46:31 +01:00
Emmanuele Bassi
043f804452 Make the pick id pool per Stage
The id pool used for the actor's id should be a per-stage field. At some
point, we might have a Stage mapped to multiple framebuffers, or each
Stage mapped to a different framebuffer; also, on backend with low
color precision we don't want to exhaust the size of the available ids
with a global pool. Finally, it's yet another thing we can remove from
the global Clutter context.

Having the id pool allocated per-stage, and the pick id assigned on
Actor:mapped will make the whole pick-id more reliable and future proof.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2633

https://bugzilla.gnome.org/show_bug.cgi?id=647876
2011-05-06 17:47:41 +01:00
Emmanuele Bassi
f6e6c803d9 Deprecate actor id
The actor's id, which is currently used to generate the pick color,
should not be part of the public API: it's an internal detail of the
pick implementation, and having it exposed is like punching a hole
through the abstraction.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2633

https://bugzilla.gnome.org/show_bug.cgi?id=647876
2011-05-06 17:47:41 +01:00
Emmanuele Bassi
b01cbbb8c3 actor: Use _clutter_actor_meta_get_debug_name()
The ActorMeta name can be more informative than just the GType class
name.
2011-04-15 13:43:15 +01:00
Emmanuele Bassi
e467ad5ad1 Use the actor's debug name consistently
Do not use the generic GType class name: we have a :name property on
ClutterActor that is generally used for debugging purposes — so we
should use it when creating debugging spew in a consistent way.
2011-04-14 18:04:39 +01:00
Robert Bragg
8557bc3d26 actor: visualize culling with CLUTTER_PAINT=redraws
This extends visualization for CLUTTER_PAINT=redraws so it now also
draws outlines for actors to show how they are being culled. Actors get
a green outline if they are fully inside the clip region, blue if fully
outside and greeny-blue if only partially inside.
2011-04-11 17:54:35 +01:00
Robert Bragg
c739cb2809 stage: adds internal_get_active_framebuffer API
This adds an internal _clutter_stage_get_active_framebuffer function
that can be used to get a pointer to the current CoglFramebuffer pointer
that is in use, in association with a given stage.

The "active" infix in the function name is there because we shouldn't
assume that a stage will always correspond to only a single framebuffer
so we aren't getting a pointer to a sole framebuffer, we are getting
a pointer to the framebuffer that is currently in use/being painted.

This API is now used for culling purposes where we need to check if we
are currently painting an actor to a framebuffer that is offscreen, that
doesn't correspond to the stage.
2011-04-11 15:28:53 +01:00
Robert Bragg
997ea0fdee framebuffer: expose experimental cogl_get_draw_framebuffer
This renames the two internal functions _cogl_get_draw/read_buffer
as cogl_get_draw_framebuffer and _cogl_get_read_framebuffer. The
former is now also exposed as experimental API.
2011-04-11 15:28:53 +01:00
Robert Bragg
49ca9e8f12 culling: Don't cull actors not being painted on the stage
Previously we were applying the culling optimization to any actor
painted without considering that we may be painting to an offscreen
framebuffer where the stage clip isn't applicable.

For now we simply expose a getter for the current draw framebuffer
and we can assume that a return value of NULL corresponds to the
stage.

Note: This will need to be updated as stages start to be backed by real
CoglFramebuffer objects and so we won't get NULL in those cases.
2011-03-10 21:02:29 +00:00
Robert Bragg
5ce13b58fe debug: Add more CLIPPING debug notes
To give quick visibility to the things going on relating to clipping and
culling this adds some more CLIPPING debug notes to clutter-actor.c and
clutter-stage.c
2011-03-10 19:07:50 +00:00
Neil Roberts
d1c819b563 clutter-actor: Fix test for avoiding calculating the paint volume
There's an optimisation in clutter-actor.c to avoid calculating the
last known paint volume whenever culling and clipped redraws are both
disabled. However there was a small thinko in the logic so that it
would also avoid calculating the paint volume whenever only one of the
debug flags is enabled. This fixes it to explicitly check that the two
flags are not both enabled before skipping the paint volume
calculation.
2011-03-07 15:35:05 +00:00
Robert Bragg
3b88029f38 actor: Cache per-actor transforms
Previously each time we needed to retrieve the model transform for a
given actor we would call the apply_transform vfunc which would build up
a transformation matrix based on the actor's current anchor point, its
scale, its allocation and rotation. The apply_transform implementation
would repeatedly call API like cogl_matrix_rotate, cogl_matrix_translate
and cogl_matrix_scale.

All this micro matrix manipulation APIs were starting to show up in the
profiles of dynamic applications so this adds priv->transform matrix
cache which maintains the combined result of the actors scale, rotation
and anchor point etc. Whenever something like the rotation changes then
then the matrix is marked as dirty, but so long as the matrix isn't
dirty then the apply_transform vfunc now just calls cogl_matrix_multiply
with the cached transform matrix.
2011-03-07 13:26:20 +00:00
Robert Bragg
19b8622983 Optimize culling by doing culling in eye-coordinates
This implements a variation of frustum culling whereby we convert screen
space clip rectangles into eye space mini-frustums so that we don't have
to repeatedly transform actor paint-volumes all the way into screen
coordinates to perform culling, we just have to apply the modelview
transform and then determine each points distance from the planes that
make up the clip frustum.

By avoiding the projective transform, perspective divide and viewport
scale for each point culled this makes culling much cheaper.
2011-03-07 13:26:20 +00:00
Robert Bragg
013b2433f0 viewport: consistently use floats for viewports
OpenGL < 4.0 only supports integer based viewports and internally we
have a mixture of code using floats and integers for viewports. This
patch switches all viewports throughout clutter and cogl to be
represented using floats considering that in the future we may want to
take advantage of floating point viewports with modern hardware/drivers.
2011-03-07 13:26:19 +00:00
Neil Roberts
3fab04805e clutter-actor: Add an internal _clutter_actor_get_opacity_override
This is needed if an effect wants to temporarily override the paint
opacity. It needs to be able to restore the old opacity override in
the post_paint handler otherwise it would replace the effect of the
opacity override from any outer effects.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2541
2011-03-03 16:54:51 +00:00
Jasper St. Pierre
0c576c0c33 Remove private helper #define's
Finish off the second half of 09a830d294.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2596
2011-03-03 11:47:49 +00:00
Emmanuele Bassi
d27b335b61 Move ClutterEffect private symbols to a private header
No point in cluttering up clutter-private.h even more than necessary.
2011-02-18 16:00:39 +00:00
Emmanuele Bassi
689aac56c9 Wrap id-pool access
The ClutterIdPool is held by the ClutterMainContext; we should hide its
direct usage into sensible private API.
2011-02-18 15:46:13 +00:00
Emmanuele Bassi
2593bbaadc Wrap shader stack into private functions
The shader stack held by ClutterMainContext should only be accessed
using functions, and not directly.

Since it's a stack, we can use stack-like operations: push, pop and
peek.
2011-02-18 15:44:17 +00:00
Emmanuele Bassi
89a0d514b4 Continue hiding the ClutterMainContext
We should strive to make the main context as transparent as possible,
and hide accessing its data through private functions.
2011-02-18 12:56:13 +00:00
Emmanuele Bassi
fc89513295 actor: Move the ShaderData out of the private data
Let's try and start reducing the size of ClutterActorPrivate by moving
some optional, out-of-band data from it to GObject data.

The ShaderData structure is a prime candidate for this migration: it
does not need to be inspected by the actor, and its relationship with an
actor is transient and optional.

By attaching it to the actor's instance through g_object_set_data() we
neatly tie its lifetime to the instance, and we don't have to care
cleaning it up in the finalize()/dispose() implementation of
ClutterActor itself.
2011-02-18 11:43:27 +00:00
Neil Roberts
71f57eef1b clutter-actor: Free the paint volume when queue a clip redraw
In _clutter_actor_queue_redraw_with_clip it has a local variable to
mark when a new paint volume for the clip is created so that it can be
freed when the function returns. However the actual code to free the
paint volume went missing in 3b789490d2 so the variable did
nothing. This patch just adds the free back in.
2011-02-16 19:00:05 +00:00
Emmanuele Bassi
5c398c18ad More ISO C90 warning fixes in Clutter
This time, in Clutter core.

The ObjC standard library provides a type called 'id', which obviously
requires any library to either drop the useful shadowed variable warning
or stop using 'id' as a variable name.

Yes, it's almost unbearably stupid. Well, at least it's not 'index' in
string.h, or 'y2' in math.h.
2011-02-15 12:40:11 +00:00
Chris Lord
b152a97ea5 actor: Rename in_clone_paint parameter to avoid variable shadowing
The 'in_clone_paint' parameter of the private function
_clutter_actor_set_in_clone_paint() shadowed the private function
in_clone_paint(). Rename this parameter to 'is_in_clone_paint' to remove
a compiler warning.
2011-02-11 16:27:46 +00:00
Chris Lord
b2ea7d1352 actor: Replace private opacity_parent with opacity_override
Replace the opacity_parent with an opacity_override variable, to allow
direct overriding of the paint opacity and simplify this mechanism
somewhat.

This also required a new private flag, in_clone_paint, to maintain the
functionality of the public function clutter_actor_is_in_clone_paint()
2011-02-11 16:17:57 +00:00
Emmanuele Bassi
1558975bc3 docs: Fix documentation for clutter_actor_pop_internal()
http://bugzilla.clutter-project.org/show_bug.cgi?id=2534
2011-01-31 13:37:32 +00:00
Emmanuele Bassi
ef36d7cbcc docs: Update the documentation for clutter_actor_unparent()
Make sure that we document the semantics of unparent() and who should
call it.
2011-01-31 12:51:14 +00:00
Emmanuele Bassi
e32253508d docs: Update documentation for ::destroy
The ::destroy signal is meant to be used to break reference cycles on
third party code. The documentation should really make it clear.
2011-01-31 12:50:25 +00:00
Emmanuele Bassi
ef78104227 Expose deprecated symbols whilst building Clutter
Don't use ugly "#undef CLUTTER_DISABLE_DEPRECATED" inside source code
using deprecated symbols; we have the handy CLUTTER_COMPILATION define
that we can use as part of the "disable deprecated" conditional.
2011-01-20 13:29:37 +00:00
Emmanuele Bassi
6c244c0549 geometry: Avoid sign issues when interpolating
Width and height in ClutterGeometry are unsigned, and this might lead to
overflow and wrap around issues.
2010-12-17 13:53:28 +00:00
Alexandre Quessy
01b93537ab Fixed "the the" repetitions in some doc strings
http://bugzilla.clutter-project.org/show_bug.cgi?id=2450
2010-11-25 18:18:51 +00:00
Chris Lord
186d5698ce actor: Use the internal child list for map/unmap
Use the internal child list for the default map/unmap vfuncs. This removes
the requirement for non-container composite actors to implement their own
map/unmap functions.
2010-11-24 16:51:59 +00:00
Robert Bragg
4752cc38b2 actor: re-work unrealize to work with composite actors
Unrealizing an actor is a recursive process that needs to traverse the
children of an actor to ensure they are also unrealized. This maintains
the invariant that if any given actor is marked as unrealized then you
know that all its children have also been unrealized.

The previous implementation would use the container interface's
foreach_with_internals vfunc to explicitly traverse the children of
container actors but this didn't consider composite actors that aren't
containers.

Since clutter-actor now maintains an explicit list of children we can
also handle composite actors that aren't containers using
_clutter_actor_traverse.
2010-11-24 16:51:59 +00:00
Robert Bragg
4bda674732 actor: make _clutter_actor_traverse more flexible
This makes it possible to choose the traversal order; either depth first
or breadth first and when visiting actors in a depth first order there
is now a callback called before children are traversed and one called
after. Some tasks such as unrealizing actors need to explicitly control
the traversal order to maintain the invariable that all children of an
actor are unrealized before we actually mark the parent as unrealized.

The callbacks are now passed the relative depth in the graph of the
actor being visited and instead of only being able to return a boolean
to bail out of further traversal it can now do one of: continue,
skip_children or break. To implement something like unrealize it's
desirable to skip children that you find have already been unrealized.
2010-11-24 16:51:59 +00:00
Owen W. Taylor
8e6fac38fa Don't update or use last_paint_box when painting inside a clone
The last_paint_box for an actor represents its "normal" position - we
shouldn't update it or use it to cull drawing if we are painting
a clone of the actor. Tracking whether we are painting a clone is
done by adding  _clutter_actor_push/pop_clone_paint() and a global
"clone paint level".

http://bugzilla.clutter-project.org/show_bug.cgi?id=2396
2010-11-23 12:50:29 +00:00
Robert Bragg
305bb124b7 use cogl_matrix_transform_points in clutter
When transforming a paint-volume or transforming allocation vertices we
are transforming more than one point at a time so we can batch those
together with cogl_matrix_transform_points instead of
cogl_matrix_transform_point. Also in both of these cases we don't need
to do a projective transform so using cogl_matrix_transform_points also
lets us reduce the per-vertex computation.
2010-11-23 12:50:29 +00:00
Emmanuele Bassi
d39277d0cf actor: Reset the last paint box on unmap
This allows hiding + moving + showing an actor without repainting the
wrong area.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2395
2010-11-19 14:49:00 +00:00
Emmanuele Bassi
694632ce95 build: Re-arrange headers
Try to minimize the included headers, especially in clutter-actor.h.
2010-11-18 18:23:49 +00:00
Emmanuele Bassi
a35708eb74 Deprecate ClutterBehaviour and sub-classes
The Behaviour class and its implementations have been replaced by the
new animation framework API and by the constraints for layout-related
animations.

Currently, we need to make tests build, so we undef DISABLE_DEPRECATED
in specific test cases while they get ported.
2010-11-18 15:21:16 +00:00
Emmanuele Bassi
a94ea93bde paint-volume: Do not take a reference on the actor
The paint volume structure is cached in the Actor it references, and
this causes a reference cycle.

The paint volume is going to be used when painting, so the actor must
still be valid - otherwise Clutter will bail out far before than
accessing the actor pointer in ClutterPaintVolume.

Otherwise, we could have used dispose() to check for a valid actor and
remove a reference if the actor field is !NULL; it feels less clean,
though, since we're effectively managing an extra reference on
ourselves.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2431
2010-11-18 11:11:03 +00:00
Emmanuele Bassi
0371ba3976 actor: Group bitfields together 2010-11-18 11:10:59 +00:00
Emmanuele Bassi
a731682ac3 actor: Simple show/hide optimizations
Showing a visible (and hiding an invisible) actor is far less cheap than
it should be.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2422
2010-11-17 08:32:55 +00:00
Emmanuele Bassi
b3f5a6e2ba actor: Do not queue relayouts on actors being destroyed
Simple optimization is simple.
2010-11-15 16:00:48 +00:00
Emmanuele Bassi
0523d6db08 actor: Add a get_debug_name() private Actor method
For internal usage, writing:

  clutter_actor_get_name (actor) != NULL
    ? clutter_actor_get_name (actor)
    : G_OBJECT_TYPE_NAME (actor)

is overly verbose and does two type checks. A simple, internal method
for getting the same result without type checks would be much more
appreciated.
2010-11-15 16:00:48 +00:00
Robert Bragg
632412c9c8 actor: Check "paint" handlers in _get_paint_volume
Instead of waiting until clutter_actor_paint to check if there are any
handlers connected to the "paint" signal, we now do the check whenever
the paint-volume is requested in _actor_get_paint_volume_mutable().

Previously we checked in clutter_actor_paint(), but at that time we may
already be using a stage clip that could be derived from an invalid
paint-volume. We used to try and handle that by queuing a follow up,
unclipped, redraw but anyway there was an additional problem with the
previous approach because the checking wasn't enough to always catch
invalid volumes involved in culling (considering that containers may
derive their volume from children that haven't yet been painted)

By moving the check to _get_paint_volume time not only do we now
correctly check children in cases where a container derives its volume
from its children's volumes but we no longer need to queue follow up
redraws to cover up artefacts.

Since we now never queue follow up redraws, this in turn means we should
no longer clobber redraws queued with an explicit clip which was
something affecting gnome-shell since it connects a handler to the paint
signal of the stage.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2388
2010-11-05 17:22:05 +00:00
Owen W. Taylor
0b4b1ca1ca Don't leave stale invalidated queued redraws around
Once an actor had _clutter_stage_queue_redraw_entry_invalidate()
called on it once, then priv->queue_redraw_entry would point to
an entry with entry->actor NULL. _clutter_stage_queue_actor_redraw()
doesn't handle this case and no further redraws would be queued.

To fix this, NULL out priv->queue_redraw_entry() and then make sure
we free the invalidated entry in
_clutter_stage_maybe_finish_queue_redraws() just as we do for
still valid entries.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2389
2010-11-03 15:43:55 +00:00
Emmanuele Bassi
46c597a1f6 Clean up clutter-private.h/6
Move all Actor private API to a separate file.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
cf3a29f224 Clean up clutter-private.h/5
Move PaintVolume private API to a separate header.
2010-10-21 12:22:17 +01:00
Emmanuele Bassi
8613013ab0 Clean up clutter-private.h/3
Move Stage private API to a separate header.
2010-10-21 11:33:26 +01:00
Emmanuele Bassi
7dd09e2186 Use G_DEFINE_BOXED_TYPE for all boxed types
We actually need a couple more macros for registering GValue
transformation functions. Those should be added to upstream
GLib.
2010-10-18 11:26:45 +01:00
Emmanuele Bassi
2b4ee9ab54 actor: Add more checks to the redraw queue 2010-10-15 16:05:44 +01:00
Robert Bragg
f456116c18 When unparenting an actor, remove queued redraws for all descendants
We need to make sure that redraws queued for actors on a stage are for
actors actually in the stage. So in clutter_actor_unparent() descend
through the children and remove redraws. Just removing the actor itself
isn't good enough since an entire hierarchy can be removed from the
stage without breaking it up into individual actors.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2359

This is based on an original patch from Owen Taylor who debugged the
root cause of this bug; thanks.
2010-10-14 16:19:55 +01:00
Emmanuele Bassi
3f27afde24 actor: Use an explicit check for NULL
Follow the coding style, and don't use the implicit C boolean
equivalence for NULL pointers.
2010-10-12 14:08:07 +01:00
Emmanuele Bassi
3b72fdb20c actor: Queue a relayout when adding/removing constraints
Constraints change the way an actor is allocated; this warrants a
relayout.
2010-10-12 14:07:27 +01:00
Emmanuele Bassi
91a9a355c3 actor: Check CluterActorMeta:enabled
Instead of delegating the check for the ActorMeta:enabled property to
the sub-classes of ClutterActorMeta, ClutterActor can do the check prior
to using the ClutterActorMeta instances.
2010-10-12 14:07:17 +01:00
Emmanuele Bassi
3f6b82c9c9 actor: Add debugging note for allocation changes 2010-10-12 14:04:05 +01:00
Emmanuele Bassi
89a389cd2b actor-box: Split out ActorBox into its own file
clutter-actor.c is getting way too large, so splitting it up wherever
possible makes sense.
2010-10-11 15:57:22 +01:00
Emmanuele Bassi
7a54bdc65d vertex: Register progress function
This allows animating properties storing a ClutterVertex.
2010-10-11 15:52:50 +01:00
Emmanuele Bassi
4931802fee geometry: Register a progress function
This allows animating properties storing a ClutterGeometry.
2010-10-11 15:44:09 +01:00
Emmanuele Bassi
a5fc90d4d9 actor-box: Register a progress function
So that we can animate properties storing ClutterActorBox.
2010-10-11 15:39:19 +01:00
Emmanuele Bassi
e1a1050a39 actor-box: Constify arguments for union
The input arguments for clutter_actor_box_union() should be constified,
since they will not be modified by the function.
2010-10-04 11:27:16 +01:00
Robert Bragg
fba6335291 actor: don't ignore clip for clipped redraws
In all the changes made recently to how we handle redraws and adding
support for paint-volumes we stopped looking at explicit clip regions
passed to _clutter_actor_queue_redraw_with_clip.

In _clutter_actor_finish_queue_redraw we had started always trying to
clip the redraw to the paint-volume of the actor, but forgot to consider
that the user may have already determined the clip region for us!

Now we first check if the given clip != NUll and if so we don't need to
calculate the paint-volume of the actor.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2349
2010-09-30 11:44:12 +01:00
Robert Bragg
42f6364cac actor: don't dirty pick buffer in _real_queue_redraw
Since re-working how redraws are queued it is no longer necessary to
dirty the pick buffer in _clutter_actor_real_queue_redraw since this
should now reliably be handled in _clutter_stage_queue_actor_redraw.
2010-09-29 15:13:01 +01:00
Robert Bragg
51fca9d968 actor: Adds private _clutter_actor_traverse API
This adds two internal functions relating to explicit traversal of the
scenegraph:
_clutter_actor_foreach_child
_clutter_actor_traverse

_clutter_actor_foreach_child just iterates the immediate children of an
actor, and with a new ClutterForeachCallback type it allows the
callbacks to break iteration early.

_clutter_actor_traverse traverses the given actor and all of its
decendants. Again traversal can be stopped early if a callback returns
FALSE.

The first intended use for _clutter_actor_traverse is to maintain a
cache pointer to the stage for all actors. In this case we will need to
update the pointer for all descendants of an actor when an actor is
reparented in any way.
2010-09-29 15:13:01 +01:00
Robert Bragg
9a1abbc713 actor: Adds private _clutter_actor_get_n_children
This adds a private getter to query the number of children an actor has.
One use planned for this API is to avoid calling get_paint_volume on
such actors. (It's not clear what the best semantics for
get_paint_volume are for actors with children, so we are considering
leaving the semantics undefined for the initial clutter 1.4 release)
2010-09-29 15:13:01 +01:00
Robert Bragg
239d83f952 actor: explicitly track children in clutter-actor.c
We now explicitly track the list of children each actor has in a private
GList. This gives us a reliable way to know how many children an actor
has - even for composite actors that don't implement the container
interface. This also will allow us to directly traverse the scenegraph
in a more generalized fashion. Previously the scenegraph was
more-or-less represented implicitly according the implementation of
paint methods.
2010-09-29 15:13:01 +01:00
Robert Bragg
b3edd3e922 debug: fix blue outlines for paint-volumes debug opt
When using the CLUTTER_PAINT=paint-volumes debug option we try and show
when a paint volume couldn't be determined by drawing a blue outline of
the allocation instead. There was a typo though and instead we were
drawing an outline the size of the stage instead of for the given actor.
This fixes that and removes a FIXME comment relating to the blue outline
that is now implemented.
2010-09-29 15:13:00 +01:00
Robert Bragg
f6ba69f82d Revert "actor: don't immediately queue redraw when queuing relayout"
This reverts commit ca44c6a7d8abe9f2c548bee817559ea8adaa7a80.

In reality there are probably lots of actors that depend on the exact
semantics as they are documented so this change isn't really acceptable.
For example when the font changes in ClutterText we only queue a
relayout, and since it's possible that the font will have the same size
and the actor won't get a new allocation it wouldn't otherwise queue a
redraw.

Since queue_redraw requests now get deferred until just before a paint
run it is actually no longer a problem to queue the redraw here.
2010-09-29 15:13:00 +01:00
Robert Bragg
3b789490d2 actor: defer queue-redraw signaling
Instead of immediately, recursively emitting the "queue-redraw" signal
when clutter_actor_queue_redraw is called we now defer this process
until all stage updates are complete. This allows us to aggregate
repeated _queue_redraw requests for the same actor avoiding redundant
paint volume transformations. By deferring we also increase the
likelihood that the actor will have a valid paint volume since it will
have an up to date allocation; this in turn means we will more often be
able to automatically queue clipped redraws which can have a big impact
on performance.

Here's an outline of the actor queue redraw mechanism:

The process starts in clutter_actor_queue_redraw or
_clutter_actor_queue_redraw_with_clip.

These functions queue an entry in a list associated with the stage which
is a list of actors that queued a redraw while updating the timelines,
performing layouting and processing other mainloop sources before the
next paint starts.

We aim to minimize the processing done at this point because there is a
good chance other events will happen while updating the scenegraph that
would invalidate any expensive work we might otherwise try to do here.
For example we don't try and resolve the screen space bounding box of an
actor at this stage so as to minimize how much of the screen redraw
because it's possible something else will happen which will force a full
redraw anyway.

When all updates are complete and we come to paint the stage (see
_clutter_stage_do_update) then we iterate this list and actually emit
the "queue-redraw" signals for each of the listed actors which will
bubble up to the stage for each actor and at that point we will
transform the actors paint volume into screen coordinates to determine
the clip region for what needs to be redrawn in the next paint.

Note: actors are allowed to queue a redraw in reseponse to a
queue-redraw signal so we repeat the processing of the list until it
remains empty. An example of when this happens is for Clone actors or
clutter_texture_new_from_actor actors which need to queue a redraw if
their source queues a redraw.
2010-09-29 15:13:00 +01:00
Robert Bragg
bfacca3011 actor: don't queue_redraw actors not descended from stage
This makes clutter_actor_queue_redraw simply bail out early if the actor
isn't a descendant of a ClutterStage since the request isn't meaningful
and it avoids a crash when trying to queue a clipped redraw against the
stage to clear the actors old location.
2010-09-29 15:13:00 +01:00
Robert Bragg
3040b140bc paint_volume: Splits out clutter_paint_volume code
This splits out all the clutter_paint_volume code from clutter-actor.c
into clutter-paint-volume.c. Since clutter-actor.c and
clutter-paint-volume.c both needed the functionality of
_fully_transform_vertices, this function has now been moved to
clutter-utils.c as _clutter_util_fully_transform_vertices.
2010-09-29 15:13:00 +01:00
Robert Bragg
72eeb8e809 actor: make default get_paint_volume more conservative
There are too many examples where the default assumption that an actor
paints inside its allocation isn't true, so we now return FALSE in the
base implementation instead. This means that by default we are saying
"we don't know the paint volume of the actor", so developers need to
implement the get_paint_volume virtual to take advantage of culling and
clipped redraws with their actors.

This patch provides very conservative get_paint_volume implementations
for ClutterTexture, ClutterCairoTexture, ClutterRectangle and
ClutterText which all explicitly check the actor's object type to avoid
making any assumptions about subclasses.
2010-09-29 15:12:59 +01:00
Robert Bragg
d9a7f1b03b actor: don't always check needs_allocation for clipped redraw
We were always explicitly checking priv->needs_allocation in
_clutter_actor_queue_redraw_with_clip, but we only need to do that if
the CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION flag is used.
2010-09-29 15:12:59 +01:00
Robert Bragg
072595a1bf actor: new actors should start with an empty paint box
This initializes priv->last_paint_box with a degenerate box, so a newly
allocated actor added to the scenegraph and made visible only needs to
trigger a redraw of its initial position. If we don't have a valid
last_paint_box though we would instead trigger a full stage redraw.
2010-09-29 15:12:59 +01:00
Robert Bragg
c2ea35b5ca actor: when culling/clipped redraws disable ignore paint box
To make comparing the performance with culling/clipped redraws
enabled/disabled fairer we now avoid querying the paint box when they
are disabled, so that results should reflect how the cost of
transforming paint volumes into screen space etc gets offset against the
benefit of culling.
2010-09-29 15:12:59 +01:00
Robert Bragg
2235e70585 actor: don't immediately queue redraw when queuing relayout
We have bent the originally documented semantics a bit so now where we
say "Queueing a new layout automatically queues a redraw as well" it
might be clearer to say "Queuing a new layout implicitly queues a redraw
as well if anything in the layout changes".

This should be close enough to the original semantics to not cause any
problems.

Without this change then we we fail to take advantage of clipped redraws
in a lot of cases because queuing a redraw with priv->needs_allocation
== TRUE will automatically be promoted to a full stage redraw since it's
not possible to determine a valid paint-volume.

Also queuing a redraw here will end up registering a redundant clipped
redraw for the current location, doing quite a lot of redundant
transforms, and then later when re-allocated during layouting another
queue redraw would happen with the correct paint-volume.
2010-09-29 15:12:58 +01:00
Robert Bragg
b499696d83 Use paint volumes to do automatic culling
This uses actor paint volumes to perform culling during
clutter_actor_paint.

When performing a clipped redraw (because only a few localized actors
changed) then as we traverse the scenegraph painting the actors we can
now ignore actors that don't intersect the clip region. Early testing
shows this can have a big performance benefit; e.g. 100% fps improvement
for test-state with culling enabled and we hope that there are even much
more compelling examples than that in the real world,

Most Clutter applications are 2Dish interfaces and have quite a lot of
actors that get continuously painted when anything is animated. The
dynamic actors are often localized to an area of user focus though so
with culling we can completely avoid painting any of the static actors
outside the current clip region.

Obviously the cost of culling has to be offset against the cost of
painting to determine if it's a win, but our (limited) testing suggests
it should be a win for most applications.

Note: we hope we will be able to also bring another performance bump
from culling with another iteration - hopefully in the 1.6 cycle - to
avoid doing the culling in screen space and instead do it in the stage's
model space. This will hopefully let us minimize the cost of
transforming the actor volumes for culling.
2010-09-29 15:12:58 +01:00
Robert Bragg
ef8be9e25e actor: Use paint volumes to always queue clipped redraws
This makes clutter_actor_queue_redraw transparently use an actor's paint
volume to queue a clipped redraw.

We save the actors paint box each time it is painted so that when
clutter_actor_queue_redraw is called we can determine the old and new
location of the actor so we know the full bounds of what must be redrawn
to clear its old view and show the new.
2010-09-29 15:12:58 +01:00
Robert Bragg
13c4d7b95d actor: make _transform_and_project_box static
This makes _clutter_actor_transform_and_project_box a static function
and removes the prototype from clutter-private.h since it is no longer
used outside clutter-actor.c
2010-09-29 15:12:58 +01:00
Robert Bragg
120d7595e3 actor: _real_queue_relayout shouldn't queue redraw
The base implementation for the actor queue_relayout method was queuing
an implicit redraw, but there shouldn't be anything implied from the
mere process of queuing a redraw that should force us to queue a redraw.
If actors are moved as a part of relayouting later then they will queue
a redraw.  Also clutter_actor_queue_relayout() still also explicitly
queues a redraw so I think this may have been doubly redundant.
2010-09-29 15:12:58 +01:00
Robert Bragg
dc97692271 actor: re-allocation implies need to redraw
If clutter_actor_allocate finds it necessary to update an actors
allocation then it now also queue a redraw of that actor. Currently we
queue redraws for actors very early on when queuing a relayout instead
of waiting to determine the final outcome of relayouting to determine if
a redraw is really required. With this in place we can move away from
preemptive queuing of redraws.
2010-09-29 15:12:58 +01:00
Robert Bragg
267e458a43 actor: separate the queue redraw code
clutter_actor_queue_relayout currently queues a relayout and a redraw,
but the plan is to change it to only queue a relayout and honour the
documentation by assuming that the process of relayouting will
result queuing redraws for any actors whos allocation changes.

This doesn't make that change it just adds an internal
_clutter_actor_queue_only_relayout function which
clutter_actor_queue_relayout now uses as well as calling
clutter_actor_queue_redraw.
2010-09-29 15:12:58 +01:00
Robert Bragg
1ea7145efc Queue clipped redraws work in terms of paint volumes
There is an internal _clutter_actor_queue_redraw_with_clip API that gets
used for texture-from-pixmap to minimize what we redraw in response to
Damage events. It was previously working in terms of a ClutterActorBox
but it has now been changed so an actor can queue a redraw of volume
instead.

The plan is that clutter_actor_queue_redraw will start to transparently
use _clutter_actor_queue_redraw_with_clip when it can determine a paint
volume for the actor.
2010-09-29 15:12:57 +01:00
Robert Bragg
066220f983 paint volumes: CLUTTER_PAINT=paint-volumes debug option
This adds a debug option to visualize the paint volumes of all actors.
When CLUTTER_PAINT=paint-volumes is exported in the environment before
running a Clutter application then all actors will have their bounding
volume drawn in green with a label corresponding to the actors type.
2010-09-29 15:12:57 +01:00
Robert Bragg
3540d222e1 paint volumes: another pass at the design
This is a fairly extensive second pass at exposing paint volumes for
actors.

The API has changed to allow clutter_actor_get_paint_volume to fail
since there are times - such as when an actor isn't a descendent of the
stage - when the volume can't be determined. Another example is when
something has connected to the "paint" signal of the actor and we simply
have no way of knowing what might be drawn in that handler.

The API has also be changed to return a const ClutterPaintVolume pointer
(transfer none) so we can avoid having to dynamically allocate the
volumes in the most common/performance critical code paths. Profiling was
showing the slice allocation of volumes taking about 1% of an apps time,
for some fairly basic tests. Most volumes can now simply be allocated on
the stack; for clutter_actor_get_paint_volume we return a pointer to
&priv->paint_volume and if we need a more dynamic allocation there is
now a _clutter_stage_paint_volume_stack_allocate() mechanism which lets
us allocate data which expires at the start of the next frame.

The API has been extended to make it easier to implement
get_paint_volume for containers by using
clutter_actor_get_transformed_paint_volume and
clutter_paint_volume_union. The first allows you to query the paint
volume of a child but transformed into parent actor coordinates. The
second lets you combine volumes together so you can union all the
volumes for a container's children and report that as the container's
own volume.

The representation of paint volumes has been updated to consider that
2D actors are the most common.

The effect apis, clutter-texture and clutter-group have been update
accordingly.
2010-09-29 15:12:57 +01:00
Robert Bragg
48a24a2e08 actor-box: Adds clutter_actor_box_union utility
When using ClutterActorBoxs for representing clip regions it can be
convenient to be able to union multiple boxes together.
2010-09-29 15:12:57 +01:00
Emmanuele Bassi
044809edb8 docs: Add PaintVolume to the API reference
And document the various related functions.
2010-09-29 15:12:57 +01:00