pre_paint() and post_paint() implementations don't need
to check whether an effect is disabled: Clutter will
not apply an effect unless it is enabled.
So remove code which checks whether the effect is
enabled or disabled from the example applications and the
documentation.
Add a recipe showing how to implement two simple
effects, based on ClutterEffect: an always gray background,
and a border with configurable width and color.
Also explains the necessity to queue a redraw on
the associated actor if the effect's properties change,
and shows how to implement that.
The example gives the GObject code for both effects,
as well as an example application showing how to use them.
The example also demonstrates how to disable/enable an effect,
making the border round an actor togglable.
Add example of a simple background color effect applied via
pre_paint() implementation in a ClutterEffect subclass.
This is a simple effect with an incomplete GObject
implementation (no properties, setters or getters)
to make it as easy to follow as possible.
The texture containing the image for the redirected actor will always
be painted at a 1:1 texel:pixel ratio so there's no need to use linear
filtering. This should also counteract some of the effects of rounding
errors when calculating the geometry for the quad.
On a Fedora system (and maybe others) there is a wrapper script called
i686-pc-mingw32-pkg-config. This script unsets the PKG_CONFIG_PATH
variable and then sets the PKG_CONFIG_LIBDIR variable so that it won't
pick up the native system .pc files. This breaks cross compiling in
mingw-fetch-dependencies.sh because it ends up removing its attempts
to set a local search path.
To fix this, the mingw-fetch-dependencies script now generates its own
wrapper script which instead sets PKG_CONFIG_LIBDIR to the local
clutter-cross prefix and then runs the original pkg-config program
from the search path. This should have the same benefit of preventing
it from finding native system .pc files on systems that don't provide
a cross pkg-config. The cross compiling for json-glib and the
recommend args to pass to configure when building clutter are updated
to set the PKG_CONFIG varible to point to this wrapper script.
Since there is very little now left in the env.sh file generated by
mingw-fetch-dependencies.sh it can be removed. What remained (The
CFLAGS="-mms-bitfields" and PKG_CONFIG_PATH=$ROOT_DIR/lib/pkgconfig) can
simply be passed explicitly when calling ./configure.
This removes the use of -mno-cygwin from our generated env.sh for cross
compiling with mingw.
I don't know that anyone is building clutter under cygwin, and our
BuildingClutterOnWindows wiki page only describes building with msys not
cygwin so I think its fair to assume that this build configuration is
untested and thus not supported by us currently. Since the -mno-cygwin
option is deprecated it could well be that there is a better
cross-compilation solution available for cygwin these days if you want
to build programs that don't depend on cygwin libraries.
This remove CXXFLAGS since we don't have any c++ code in Clutter and
also removes the redundant -L$ROOT_DIR/lib from LDFLAGS and
-I$ROOT_DIR/include from CPPFLAGS and CFLAGS. (These should get added by
pkg-config)
This adds some blurb at the end the mingw-fetch-dependencies.sh script
that gives an example of how to go on and build clutter after fetching
all dependencies.
Since Tor does not currently provide win32 binaries for json-glib we
need to cross compile it before we can build clutter. This extends
mingw-fetch-dependencies.sh so it can fetch, unpack and cross-compile
json-glib into the same prefix as the binary dependencies.
It shouldn't be necessary to explicitly override CC,CPP,AR,NM,LD etc in
the env.sh helper script that mingw-fetch-dependencies.sh generates.
Clutter's ./configure script should figure all of those out for us.
This removes the "Do you want to checkout and build Clutter?" option
from the mingw-cross-compile.sh script and renames the script
mingw-fetch-dependencies.sh
As it stands the mingw-cross-compile.sh script isn't enough to fetch all
the dependencies for building clutter, since Tor doesn't provide binaries
for json-glib so the option to checkout and build clutter can't work.
Also it doesn't seem ideal to clone a fresh clutter repo instead of
being able to compile the source of the current repo.
if cross compiling clutter using mingw using an out of tree build
directory then a pre-requisite for creating the resources.o file
containing the transparent cursor is for the win32 directory itself to
be created at $(top_builddir)/clutter/win32.
glib already has a data type to manage a list of callbacks called a
GHookList so we might as well use it instead of maintaining Cogl's own
type. The glib version may be slightly more efficient because it
avoids using a GList and instead encodes the prev and next pointers
directly in the GHook structure. It also has more features than
CoglCallbackList.
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.
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
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.
Drawing and clipping to paths is generally quite expensive because the
geometry has to be tessellated into triangles in a single VBO which
breaks up the journal batching. If we can detect when the path
contains just a single rectangle then we can instead divert to calling
cogl_rectangle which will take advantage of the journal, or by pushing
a rectangle clip which usually ends up just using the scissor.
This patch adds a boolean to each path to mark when it is a
rectangle. It gets cleared whenever a node is added or gets set to
TRUE whenever cogl2_path_rectangle is called. This doesn't try to
catch cases where a rectangle is composed by cogl_path_line_to and
cogl_path_move_to commands.
ClutterDragAction should be able to use the newly added ClutterSettings
property exposing the system's drag threshold.
Currently, the x-drag-threshold and the y-drag-threshold properties (and
relative accessors) use an unsigned integer for their values; we should
be able to safely expand the range to include -1 as the minimum value,
and use this new value to tell the ClutterDragAction that it should query
the ClutterSettings object for the drag threshold.
The storage of the properties has been changed, albeit in a compatible
way, as GObject installs a uint ↔ int transformation function for GValue
automatically.
The setter for the drag thresholds has been changes to use a signed
integer, but the getter has been updated to always Do The Right Thing™:
it never returns -1 but, instead, will return the valid drag threshold,
either from the value set or from the Settings singleton.
This change is ABI compatible.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2583
ClutterState is missing some documentation on how to define transitions
using ClutterScript definitions; it is also missing some example code
for both the C API and the ClutterScript syntax.
The allocation of the ClutterBox is not enough to be used as the paint
volume, because children might decide to paint outside that area.
Instead, we should use the allocation if the Box has a background color
and then do what Group does, and union all the paint volumes of the
children.
http://bugzilla.clutter-project.org/show_bug.cgi?id=2600
In 9ff04e8a99 the builtin uniforms were moved to the common shader
boilerplate. However the common boilerplate is positioned before the
default precision specifier on GLES2 so it would fail to compile
because the uniforms end up with no precision in the fragment
shader. This patch just moves the precision specifier to above the
common boilerplate.
The CLUTTER_ENTER and CLUTTER_LEAVE event types were mistakenly ignored
by clutter_event_get_device(), when returning the device from a
non-allocated ClutterEvent.
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.
Instead of unconditionally combining the modelview and projection
matrices and then iterating each of the vertices to call
cogl_matrix_transform_point for each one in turn we now only combine the
matrices if there are more than 4 vertices (with less than 4 vertices
its less work to transform them separately) and we use the new
cogl_vertex_{transform,project}_points APIs which can hopefully
vectorize the transformations.
Finally the perspective divide and viewport scale is done in a separate
loop at the end and we don't do the spurious perspective divide and
viewport scale for the z component.
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.
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.
This simplifies the implementation of the ClutterStage apply_transform
vfunc by using the new cogl_matrix_view_2d_in_perspective utility API
which can setup up a view transform for a given perspective so that a
cross section of the view frustum at an arbitrary depth can be mapped
directly to 2D stage coordinates with (0,0) at the top left.
This adds two new experimental functions to cogl-matrix.c:
cogl_matrix_view_2d_in_perspective and cogl_matrix_view_2d_in_frustum
which can be used to setup a view transform that maps a 2D coordinate
system (0,0) top left and (width,height) bottom right to the current
viewport.
Toolkits such as Clutter that want to mix 2D and 3D drawing can use
these APIs to position a 2D coordinate system at an arbitrary depth
inside a 3D perspective projected viewing frustum.
Firstly Clutter shouldn't be using OpenGL directly so this needed
changing but also conceptually it doesn't make sense for
clutter_stage_read_pixels to validate the requested area to read against
the viewport it would make more sense to compare against the window
size. Finally checking that the width of the area is less than the
viewport or window width without considering the x isn't enough to know
if the area extends outside the windows bounds. (same for the height)
This patch removes the validation of the read area from
clutter_stage_read_pixels and instead we now simply rely on the
semantics of cogl_read_pixels for reading areas outside the window
bounds.
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.
This makes a change to the original point_in_poly algorithm from:
http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
The aim was to tune the test so that tests against screen aligned
rectangles are more resilient to some in-precision in how we transformed
that rectangle into screen coordinates. In particular gnome-shell was
finding that for some stage sizes then row 0 of the stage would become a
dead zone when going through the software picking fast-path and this was
because the y position of screen aligned rectangles could end up as
something like 0.00024 and the way the algorithm works it doesn't have
any epsilon/fuz factor to consider that in-precision.
We've avoided introducing an epsilon factor to the comparisons since we
feel there's a risk of changing some semantics in ways that might not be
desirable. One of those is that if you transform two polygons which
share an edge and test a point close to that edge then this algorithm
will currently give a positive result for only one polygon.
Another concern is the way this algorithm resolves the corner case where
the horizontal ray being cast to count edge crossings may cross directly
through a vertex. The solution is based on the "idea of Simulation of
Simplicity" and "pretends to shift the ray infinitesimally down so that
it either clearly intersects, or clearly doesn't touch". I'm not
familiar with the idea myself so I expect a misplaced epsilon is likely
to break that aspect of the algorithm.
The simple solution this patch applies is to pixel align the polygon
vertices which should eradicate most noise due to in-precision.
https://bugzilla.gnome.org/show_bug.cgi?id=641197
Anything that is not CLUTTER_INIT_SUCCESS is to be considered an error.
This fixes the Clutter initialization sequence to actually error out
on pre-conditions and backend initialization failures.
clutter_offscreen_effect_pre_paint was using the unitialized value of
the ‘box’ variable whenever the actor doesn't have a paint
volume. This patch makes it just set the offset to 0,0 instead.