The z coordinate of the origin should be checked against the same
coordinate of the vertex behind it. Given that most actors are flat
surfaces, this check should always succeed.
https://bugzilla.gnome.org/show_bug.cgi?id=675396
Creating PaintVolume instances is not possible, and it's not recommended
anyway. It is, though, necessary to union paint volumes, especially with
2D boxes, in some cases.
Clutter should provide a simple convenience function that allows
unioning volumes to boxes in a moderately efficient way.
https://bugzilla.gnome.org/show_bug.cgi?id=670021
This should avoid trying to fix the origin of a paint volume set from
the allocation's origin, and thus breaking everything.
A PaintVolume for an actor is defined to be relative to the actor's
modelview unless specifically modified by internal functions; the origin
of an actor's allocation is, on the other hand, parent-relative.
If we do project() → get_bounding_box(), we'll try to complete the
volume twice, which whacks out all the lazily computed vertices.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
In _clutter_actor_set_default_paint_volume we were returning FALSE if an
actor has an empty allocation because we were claiming it doesn't have a
paint-volume. Actually an empty/degenerate pv is valid and has different
semantics to returning FALSE because FALSE means the pv is unknown and
so Clutter will have to assume the worst - that the pv is basically
un-bounded.
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
This updates _clutter_paint_volume_get_stage_paint_box to try and
calculate more stable paint-box sizes for fixed sized paint-volumes by
not basing the size on the volume's sub-pixel position.
So the aim is that for a given rectangle defined with floating point
coordinates we want to determine a stable quantized size in pixels that
doesn't vary due to the original box's sub-pixel position.
The reason this is important is because effects will use this API to
determine the size of offscreen framebuffers and so for a fixed-size
object that may be animated across the screen we want to make sure that
the stage paint-box has an equally stable size so that effects aren't
made to continuously re-allocate a corresponding fbo.
The other thing we consider is that the calculation of this box is
subject to floating point precision issues that might be slightly
different to the precision issues involved with actually painting the
actor, which might result in painting slightly leaking outside the
user's calculated paint-volume. This patch now adds padding to consider
this too.
Signed-off-by: Neil Roberts <neil@linux.intel.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
The implementation of _clutter_actor_set_default_paint_volume which
simply uses the actor's allocation to determine a paint-volume was
needlessly using the allocation rounded to integers by internally using
clutter_actor_get_allocation_geometry instead of
clutter_actor_get_allocation_box. This was introducing a lot of
instability into the paint-volume due to the way rounding was done.
The code has now been updated to use clutter_actor_get_allocation_box
so we are dealing with the floating point allocation instead.
Signed-off-by: Neil Roberts <neil@linux.intel.com>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
This removes the is_axis_aligned assertions for the width/height/depth
getters and setters, since for example it is legitimate to query the
width, height or depth of a container's child actors which aren't
necessarily axis aligned.
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Although this patch doesn't make them public, it documents the
_clutter_actor_get/apply_relative_transform_matrix functions so they
could easily be made public if desired. I think these API could be
useful to have publicly, and I originally documented them because I
thought they would be needed in the MX toolkit.
On reviewing the clutter-actor.c code using
_apply_modelview_transform_recursive I noticed various comments stating
that it will never call the stage's ->apply_transform vfunc to transform
into eye coordinates, but actually looking at the implementation that's
not true. The comments probably got out of sync with an earlier
implementation that had that constraint. This removes the miss-leading
comments and also updates various uses of the api where we were manually
applying the stage->apply_transform.
This removes the pv->is_xis_aligned assertion in
_clutter_paint_volume_union. We were already considering the case where
the second volume may not be axis aligned and aligning it into a
temporary variable in that case, but we now also consider that the first
pv may also not be aligned.
The removes the pv->is_complete assertion from
_clutter_paint_volume_axis_align() and instead if the volume isn't
complete it calls _clutter_paint_volume_complete().
When calculating the union of a volume with an empty volume we aim to
simply take the contents of the non-empty volume, but we were not
copying the flags across. We now use
_clutter_paint_volume_set_from_volume which copies all the flags except
the is_static flag.
In _clutter_paint_volume_set_from_volume we were using memcpy to simply
copy everything from one volume to another, but that meant we were
trashing the is_static flag which determines if the destination
paint-volume was slice allocated or not.
This removes the constraint that a paint-volume must be axis aligned
before _clutter_paint_volume_complete can be called. NB: A paint volume
is represented by one origin vertex and then three axis vertices to
define the width, height and depth of the volume. It's straightforward
to use the vectors from the origin to the axis vertices to deduce the
other 4 vertices so we can remove the is_axis_aligned assertion.
We were mistakenly using the constant 4 to determine the number of
vertices that need to be culled for a paint-volume to be considered
fully culled too. This is only ok for 2d volumes and was resulting in
some 3d volumes being considered culled whenever 4 out of 8 vertices
were culled. This fix is simply to reference the vertex_count variable
instead of assuming 4.
This updates the inner loops of the cull function so now the vertices of
the polygon being culled are iterated in the inner loop instead of the
clip planes and we count how many vertices are outside the current
plane so we can bail out immediately if all the vertices are outside of
any plane and so we can correctly track partial intersections with the
clip region.
The previous approach could catch some partial intersections but for
example a rectangle that was larger than the clip region centred over
the clip region with all corners outside would be reported as outside,
not as a partial intersection.
As documented in cogl-pipeline-private.h, there is a precedence to the
ClutterPaintVolume bitfields that should be considered whenever we
implement code that manipulates PaintVolumes...
Firstly if ->is_empty == TRUE then the values for ->is_complete and
->is_2d are undefined, so we should typically check ->is_empty as the
first priority.
This fixes a bug in _clutter_paint_volume_cull() whereby we were
checking pv->is_complete before checking pv->is_empty which was
resulting in assertions for actors with no size.
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.
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.
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.
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
For Clone actors we will need a way to report the volume of the source
actor as the volume of the clone actor. To make this work though we need
to be able to replace the reference to the source actor with a reference
to the clone actor instead. This adds a private
_clutter_paint_volume_set_reference_actor function to do that.
This adds a way to initialize a paint volume from another source paint
volume. This lets us for instance pass the contents of one paint volume
back through the out param of a get_paint_volume implementation.
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.