Commit Graph

2158 Commits

Author SHA1 Message Date
Neil Roberts
97921a7d13 [pango-display-list] Use indexed vertices on GLES
Now that CoglVertexBuffers support indices we can use them with GLES
to avoid duplicating vertices. Regular GL still uses GL_QUADS because
it is shown to still have a performance benefit over indices with the
Intel drivers.
2009-06-01 14:50:52 +01:00
Neil Roberts
67544f38d4 [cogl-vertex-buffer] Add cogl_vertex_buffer_indices_get_for_quads
This function can be used as an efficient way of drawing groups of
quads without using GL_QUADS. It generates a VBO containing the
indices needed to render using pairs of GL_TRIANGLES. The VBO is
globally cached so that it only needs to be uploaded whenever more
indices are requested than ever before.
2009-06-01 14:50:52 +01:00
Emmanuele Bassi
4afe1e9a8b [actor] Add allocate_available_size()
The allocate_available_size() method is a convenience method in
the same spirit as allocate_preferred_size(). While the latter
will allocate the preferred size of an actor regardless of the
available size provided by the actor's parent -- and thus it's
suitable for simple fixed layout managers like ClutterGroup -- the
former will take into account the available size provided by the
parent and never allocate more than that; it is, thus, suitable
for simple fluid layout managers.
2009-05-29 17:53:19 +01:00
Emmanuele Bassi
293eeed507 [build] Remove cogl-enum-types.h on distclean
The cogl-enum-types.h file is created by glib-mkenums under
/clutter/cogl/common, and then copied in /clutter/cogl in order
to make the inclusion of that file work inside cogl.h.

Since we're copying it in a different location, the Makefile
for that location has to clean up the copy.
2009-05-29 17:50:58 +01:00
Emmanuele Bassi
936f638a42 [build] Fix dist issues
* cogl-deprecated.h is not being installed

* cogl-enum-types.c.in is not part of the dist
2009-05-29 17:10:27 +01:00
Jonas Bonn
faec5c468b Freeze notifiers around property setters
Notifications should be fired off from both the internal timeline and
the wrapping animation here, so notifiers should be frozen around these
property setters.

Signed-off-by: Jonas Bonn <jonas@southpole.se>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-29 16:22:46 +01:00
Jonas Bonn
1187972e45 [animation] Final cleanups to new Animation model
Just a couple of final cleanups after the reimplementation of the
Animation model.

i)  _set_mode does not need to set the timeline on the alpha
ii) freeze notifications around the setting of a new alpha

Signed-off-by: Jonas Bonn <jonas@southpole.se>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-29 16:22:27 +01:00
Emmanuele Bassi
c5e659d592 [master clock] Use StageManager::peek_stages()
Use the new StageManager::peek_stages() method to avoid a copy
of the stages list.
2009-05-29 15:13:55 +01:00
Emmanuele Bassi
5d4974ed36 [stage manager] Add peek_stages()
We need an method for StageManager that returns a const pointer
to the internal list, to avoid the copy.
2009-05-29 15:13:55 +01:00
Emmanuele Bassi
63c7cc0175 [master clock] Handle Timeline::started signal correctly
The "started" signal is sent first after the timeline has been set to the
'running' state. For this reason, checking if the clock has any running
timelines running will always return true in the "started" signal handler:
the timeline that sent the signal is running.

What needs to be checked in the signal handler is if there are any
timelines running other than the one that emitted the ::started signal,
which we know is running anyway.

This prevents frames from being lost at the beginning of an animation when
a timeline is started after a quiescent period.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1617

Signed-off-by: Jonas Bonn <jonas@southpole.se>
Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-29 15:13:55 +01:00
Emmanuele Bassi
cbbc1a9ca3 [build] Copy cogl-enum-types.h under the guard
We avoid rebuilding cogl-enum-types.h and cogl-enum-types.c by
using a "guard" -- a stamp file that will block Makefile. Since
we need cogl-enum-types.h into /clutter/cogl as well for the
cogl.h include to work, if we copy the cogl-enum-types.h
unconditionally it will cause a rebuild of the whole COGL; which
will cause a full rebuild.

To solve this, we can copy the header file when generating it
under the stamp file.
2009-05-29 15:13:55 +01:00
Emmanuele Bassi
e565c1f1db [build] Encode the target into the backend library
The libclutter-cogl internal object should be the only dependency
for Clutter, since we are already copying it inside clutter/cogl
for the introspection scanner. For this reason, the backend-specific,
real internal object should be built with the backend encoded into
the file name, like libclutter-common. This makes the build output
a little bit more clear: instead of having two:

  LINK libclutter-cogl-common.la
  ...
  LINK libclutter-cogl.la
  LINK libclutter-cogl.la

We'll have:

  LINK libclutter-cogl-common.la
  ...
  LINK libclutter-cogl-gl.la
  LINK libclutter-cogl.la

Same applies for the GLES backend.
2009-05-29 12:50:48 +01:00
Emmanuele Bassi
b4861cbd21 Use g_once when registering enumeration types
Just like we do with GObject types and G_DEFINE_TYPE, we should
use the g_once_init_enter/g_once_init_leave mechanism to make the
GType registration of enumeration types thread safe.
2009-05-29 12:40:23 +01:00
Emmanuele Bassi
3248bb1b75 [cogl] Generate enumeration GTypes
COGL is starting to have more enumerations than I can handle
by hand. Let's use glib-mkenums and be done with it.
2009-05-29 12:31:47 +01:00
Emmanuele Bassi
7b75f93db1 [docs] Fixes for the API reference
* Add unused symbols

* Document and sync argument names with their gtk-doc counterpart

* Add missing descriptions
2009-05-28 17:18:13 +01:00
Emmanuele Bassi
9557328e4e Merge branch 'master' into 1.0-integration
* master:
  [test-text-perf] Use queue_redraw instead of painting the stage directly
  [actor] In paint when opacity == 0, clear the queued_redraw flag
2009-05-28 15:53:56 +01:00
Emmanuele Bassi
7252c14197 [cogl] Make cogl_setup_viewport() a private function
The setup_viewport() function should only be used by Clutter and
not by application code.

It can be emulated by changing the Stage size and perspective and
requeueing a redraw after calling clutter_stage_ensure_viewport().
2009-05-28 14:14:50 +01:00
Emmanuele Bassi
32018584c0 [cogl deprecated] Add backface culling deprecation
The backface culling enabling function was split and renamed, just
like the depth testing one, so we need to add the macro to the
cogl-deprecated.h header.
2009-05-28 14:14:50 +01:00
Robert Bragg
be826ed4e7 [cogl vertex buffers] Give indices a CoglHandle so they are shareable
Previously indices were tightly bound to a particular Cogl vertex buffer
but we would like to be able to share indices so now we have
cogl_vertex_buffer_indices_new () which returns a CoglHandle.

In particular we could like to have a shared set of indices for drawing
lists of quads that can be shared between the pango renderer and the
Cogl journal.
2009-05-28 13:27:54 +01:00
Robert Bragg
f0849fc3e2 [cogl journal] If we are only flushing one quad use a TRIANGLE_FAN
At the moment Cogl doesn't do much batching of quads so most of the time we
are flushing a single quad at a time.  This patch simplifies how we submit
those quads to OpenGL by using glDrawArrays with GL_TRIANGLE_FAN mode
instead of sending indexed vertices using GL_TRIANGLES mode.

Note: I hope to follow up soon with changes that improve our batching and
also move the indices into a VBO so they don't need to be re-validated every
time we call glDrawElements.
2009-05-28 02:43:36 +01:00
Robert Bragg
57cb20dc06 [deprecated defines] Adds some missing cogl_texture_* deprecated defines
To assist people porting code from 0.8, the cogl_texture_* functions that
have been replaced now have defines that give some hint as to how they
should be replaced.
2009-05-28 02:43:36 +01:00
Robert Bragg
605243d952 [cogl] renamed cogl_enable_* to cogl_set_*_enabled + added getters
cogl_enable_depth_test and cogl_enable_backface_culling have been renamed
and now have corresponding getters, the new functions are:
  cogl_set_depth_test_enabled
  cogl_get_depth_test_enabled
  cogl_set_backface_culling_enabled
  cogl_get_backface_culling_enabled
2009-05-28 02:43:36 +01:00
Robert Bragg
96188bab62 [cogl matrix] Support ortho and perspective projections.
This adds cogl_matrix api for multiplying matrices either by a perspective
or ortho projective transform.  The internal matrix stack and current-matrix
APIs also have corresponding support added.

New public API:
cogl_matrix_perspective
cogl_matrix_ortho
cogl_ortho
cogl_set_modelview_matrix
cogl_set_projection_matrix
2009-05-28 02:43:35 +01:00
Robert Bragg
12c8ff8606 [cogl] Remove cogl_{create,destroy}_context from the public API
cogl_create_context is dealt with internally when _cogl_get_default context
is called, and cogl_destroy_context is currently never called.

It might be nicer later to get an object back when creating a context so
Cogl can support multiple contexts, so these functions are being removed
from the API until we get a chance to address context management properly.

For now cogl_destroy_context is still exported as _cogl_destroy_context so
Clutter could at least install a library deinit handler to call it.
2009-05-28 02:43:35 +01:00
Robert Bragg
59bd824404 [vbo indices] tweak add_indices api to return an id and add delete_indices api
Originally cogl_vertex_buffer_add_indices let the user pass in their own unique
ID for the indices; now the Id is generated internally and returned to the
caller.
2009-05-28 02:43:35 +01:00
Robert Bragg
d51faed660 [cogl-vertex-buffer] Seal GL types from the public API
We now have CoglAttributeType and CoglVerticesMode typedefs to replace the
use of GLenum in the public API.
2009-05-28 02:43:35 +01:00
Robert Bragg
6bb6686666 [cogl-vertex-buffers] Support putting index arrays into VBOS
It's now possible to add arrays of indices to a Cogl vertex buffer and
they will be put into an OpenGL vertex buffer object. Since it's quite
common for index arrays to be static it saves the OpenGL driver from
having to validate them repeatedly.

This changes the cogl_vertex_buffer_draw_elements API: It's no longer
possible to provide a pointer to an index array at draw time. So
cogl_vertex_buffer_draw_elements now takes an indices identifier that
should correspond to an idendifier returned when calling
cogl_vertex_buffer_add_indices ()
2009-05-28 02:43:34 +01:00
Robert Bragg
68214fe4b8 [cogl] Remove cogl_flush_gl_state from the API
This is being removed before we release Clutter 1.0 since the implementation
wasn't complete, and so we assume no one is using this yet.  Util we have
someone with a good usecase, we can't pretend to support breaking out into
raw OpenGL.
2009-05-28 02:43:34 +01:00
Robert Bragg
f322da3794 [material] Reduce the material API in preperation for releasing Clutter 1.0
There were a number of functions intended to support creating of new
primitives using materials, but at this point they aren't used outside of
Cogl so until someone has a usecase and we can get feedback on this
API, it's being removed before we release Clutter 1.0.
2009-05-28 02:43:34 +01:00
Robert Bragg
f28d5e481b [cogl-material] Removes all the API made redundant by the blend strings API
This removes the following API:
  cogl_material_set_blend_factors
  cogl_material_set_layer_combine_function
  cogl_material_set_layer_combine_arg_src
  cogl_material_set_layer_combine_arg_op

These were rather awkward to use, so since it's expected very few people are
using them at this point and it should be straight forward to switch over
to blend strings, the API is being removed before we release Clutter 1.0.
2009-05-28 02:43:34 +01:00
Robert Bragg
33994caa71 [cogl-material] Support string based blending and layer combine descriptions
Setting up layer combine functions and blend modes is very awkward to do
programatically.  This adds a parser for string based descriptions which are
more consise and readable.

E.g. a material layer combine function could now be given as:
  "RGBA = ADD (TEXTURE[A], PREVIOUS[RGB])"
or
  "RGB = REPLACE (PREVIOUS)"
  "A = MODULATE (PREVIOUS, TEXTURE)"

The simple syntax and grammar are only designed to expose standard fixed
function hardware, more advanced combining must be done with shaders.

This includes standalone documentation of blend strings covering the aspects
that are common to blending and texture combining, and adds documentation
with examples specific to the new cogl_material_set_blend() and
cogl_material_layer_set_combine() functions.

Note: The hope is to remove the now redundant bits of the material API
before 1.0
2009-05-28 02:43:28 +01:00
Robert Bragg
ef1a771fde [build] Fixes some compiler warnings when building for GLES 2
There were a number of variables shadowing other symbols, and an unused
display variable.
2009-05-28 01:15:41 +01:00
Emmanuele Bassi
ccd3b4c886 [animation] Simplify the Animation code
After long deliberation, the Animation class handling of the
:mode, :duration and :loop properties, as well as the conditions
for creating the Alpha and Timeline instances, came out as far too
complicated for their own good.

This is a rework of the API/parameters matrix and behaviour:

  - :mode accessors will create an Alpha, if needed
  - :duration and :loop accessors will create an Alpha and a Timeline
    if needed
  - :alpha will set or unset the Alpha
  - :timeline will set or unset the Timeline

Plus, more documentation on the Animation class itself.

Many thanks to Jonas Bonn <jonas@southpole.se> for the feedback
and the ideas.
2009-05-27 18:28:37 +01:00
Emmanuele Bassi
6fff1bcdc6 [animatable] Allow validation in ::animate_property
The Animatable interface implementation will always have the computed
value applied, whilst the non-Animatable objects go through the
interval validation first to avoid incurring in assertions and
warnings.

The Animatable::animate_property() should also be able to validate the
property it's supposed to interpolate, and eventually discard it. This
requires adding a return value to the virtual function (and its wrapper
function).

The Animation code will then apply the computed value only if the
animate_property() returns TRUE -- unifying the code path with the
non-Animatable objects.
2009-05-27 13:01:31 +01:00
Emmanuele Bassi
7edaf8ece8 [animation] Proxy properties whenever possible
The Animation class should proxy the :mode, :duration and :loop
properties whenever possible, to avoid them going out of sync when
changed using the Alpha and Timeline instances directly.

Currently, if Timeline:duration is changed, querying Animation:duration
will yield the old value, but the animation itself (being driven by
the Timeline) will use the Timeline's :duration new value. This holds
for the :loop and :mode properties as well.

Instead, the getters for the Animation's :duration, :loop and
:mode properties should ask the relevant object -- if any. The
loop, duration and mode values inside AnimationPrivate should only
be used if no Timeline or no Alpha instances are available, or
when creating new instances.
2009-05-27 12:12:11 +01:00
Emmanuele Bassi
1f44c3584c [animation] Defer the timeline handling to the Alpha
The Animation should not directly manipulate a Timeline instance,
but it should defer to the Alpha all handling of the timeline.

This means that:

  - set_duration() and set_loop() will either create a Timeline or
    will set the :duration and :loop properties on the Timeline; if
    the Timeline must be created, and no Alpha instance is available,
    then a new Alpha instance will be created as well and the newly
    create Timeline will be assigned to the Alpha

  - if set_mode() on an Animation instance without an Alpha, the
    Alpha will be created; a Timeline will also be created

  - set_alpha() will replace the Alpha; if the new Alpha does not
    have a Timeline associated then a Timeline will be created using
    the current :duration and :loop properties of Animation; otherwise,
    if the replaced Alpha had a timeline, the timeline will be
    transferred to the new one
2009-05-27 11:52:40 +01:00
Emmanuele Bassi
b05d4be19d Use GLib variant of strcasecmp()
The GLib version of strcasecmp() ignores any non-ASCII character,
unlike the original which is locale-dependent.
2009-05-25 12:42:17 +01:00
Emmanuele Bassi
ec374c7ab9 [build] Clean up cogl-pango Makefile 2009-05-25 12:41:16 +01:00
Emmanuele Bassi
71498a6376 [cogl] Remove max_waste argument from Texture ctors
The CoglTexture constructors expose the "max-waste" argument for
controlling the maximum amount of wasted areas for slicing or,
if set to -1, disables slicing.

Slicing is really relevant only for large images that are never
repeated, so it's a useful feature only in controlled use cases.
Specifying the amount of wasted area is, on the other hand, just
a way to mess up this feature; 99% the times, you either pull this
number out of thin air, hoping it's right, or you try to do the
right thing and you choose the wrong number anyway.

Instead, we can use the CoglTextureFlags to control whether the
texture should not be sliced (useful for Clutter-GST and for the
texture-from-pixmap actors) and provide a reasonable value for
enabling the slicing ourself. At some point, we might even
provide a way to change the default at compile time or at run time,
for particular platforms.

Since max_waste is gone, the :tile-waste property of ClutterTexture
becomes read-only, and it proxies the cogl_texture_get_max_waste()
function.

Inside Clutter, the only cases where the max_waste argument was
not set to -1 are in the Pango glyph cache (which is a POT texture
anyway) and inside the test cases where we want to force slicing;
for the latter we can create larger textures that will be bigger than
the threshold we set.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
Signed-off-by: Robert Bragg <robert@linux.intel.com>
Signed-off-by: Neil Roberts <neil@linux.intel.com>
2009-05-23 19:35:19 +01:00
Emmanuele Bassi
87465355d3 Add repaint functions
Sometimes it is necessary for third party code to have a
function called during the redraw process, so that you can
update the scenegraph before it is painted.
2009-05-23 19:33:04 +01:00
Neil Roberts
654c26a130 [actor] In paint when opacity == 0, clear the queued_redraw flag
If we are short-circuiting the paint when the opacity is zero we still
need to clear the queued_redraw flag otherwise it won't be possible to
queue another redraw of the actor until something else has caused a
paint first.
2009-05-22 14:50:37 +01:00
Emmanuele Bassi
c262ab0b63 Merge branch 'master' into 1.0-integration
* master:
  [cogl-vertex-buffer] Ensure the clip state before rendering
  [test-text-perf] Small fix-ups
  Add a test for text performance
  [build] Ensure that cogl-debug is disabled by default
  [build] The cogl GE macro wasn't passing an int according to the format string
  Use the right internal format for GL_ARB_texture_rectangle
  [actor_paint] Ensure painting is a NOP for actors with opacity = 0
  Make backface culling work with vertex buffers
2009-05-22 12:00:33 +01:00
Neil Roberts
b3fe1b8a8a [cogl-vertex-buffer] Ensure the clip state before rendering
Before any rendering is done by Cogl it needs to ensure the clip stack
is set up correctly by calling cogl_clip_ensure. This was not being
done for the Cogl vertex buffer so it would still use the clip from
the previous render.
2009-05-22 11:48:34 +01:00
Damien Lespiau
309f680d32 [texture] size-change closure is now VOID:FLOAT,FLOAT
Now that everything is float, the marsharlling function of the
size-change signal should reflect that fact.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-22 09:09:31 +01:00
Neil Roberts
d513c1c540 Merge branch 'pango-vbo' into 1.0-integration
This makes it cache the geometry of PangoLayouts into a VBO as
described in bug #1572.
2009-05-21 16:52:23 +01:00
Neil Roberts
7e18109f9b [cogl-pango-display-list] Use GL_TRIANGLES under GLES
GLES doesn't support GL_QUADS. This patch makes it use GL_TRIANGLES
instead in that case. Unfortunately this means submitting two extra
vertices per quad. It could be better to use indexed elements once
CoglVertexBuffers gains support for that.
2009-05-21 15:51:25 +01:00
Robert Bragg
14c3ef1f8d [build] The cogl GE macro wasn't passing an int according to the format string
This patch simply updates the arguments passed to g_warning inline with the
given format string.
2009-05-21 15:10:38 +01:00
Owen W. Taylor
5481681e5c Use the right internal format for GL_ARB_texture_rectangle
When ClutterGLXTexturePixmap uses GL_ARB_texture_rectangle,
it needs to pass the right internal format (GL_RGB or GL_RGBA)
when it initializes the texture with glTexImage2D() or later
handling won't recognize the alpha channel.

http://bugzilla.openedhand.com/show_bug.cgi?id=1586

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-05-21 15:10:37 +01:00
Robert Bragg
2c6719502a [actor_paint] Ensure painting is a NOP for actors with opacity = 0
Since it is convenient to use geometry with an opacity of 0 for input only
purposes it's a worthwhile optimization to avoid submitting anything
for such actors while painting.
2009-05-21 15:10:37 +01:00
Neil Roberts
f13c3ee309 Make backface culling work with vertex buffers
Backface culling is enabled as part of cogl_enable so the different
rendering functions in Cogl need to explicitly opt-in to have backface
culling enabled. Cogl vertex buffers should allow backface culling so
they should check whether it is enabled and then set the appropriate
cogl_enable flag.
2009-05-21 14:57:07 +01:00
Neil Roberts
3fc64dfaa7 [pango-render] Keep a reference to the first line to detect layout changes
In order to cope with the situation where an application renders with
a PangoLayout, makes some changes and then renders again with the same
layout, CoglPangoRenderer needs to detect that the changes have
occured so that it can recreate the display list. This is acheived by
keeping a reference to the first line of the layout. When the layout
is changed Pango will clear the layout pointer in the first line and
create a new line. So if the layout pointer in the line becomes NULL
then we know the layout has changed. This trick was suggested by
Behdad Esfahbod in this email:

http://mail.gnome.org/archives/gtk-i18n-list/2009-May/msg00019.html
2009-05-21 12:17:12 +01:00
Neil Roberts
085be4cebc [cogl-pango-render] Fix the positioning when calling cogl_pango_render_layout
When a position is given to cogl_pango_render_layout_subpixel it
translates the GL matrix by the coordinates. However it was not
dividing by PANGO_SCALE so the coordinates were completely wrong.
2009-05-21 12:09:16 +01:00
Emmanuele Bassi
1985fa75b1 [texture] Use a box instead of int coordinates
Most of the operations involving the texture's allocated area require
floats -- either for computations or for setting the geometry into
COGL. So it doesn't make any sense to use get_allocation_coords() and
cast everything to floats.
2009-05-20 17:38:58 +01:00
Emmanuele Bassi
3428e4dd1d [actor] Do not try to dereference NULL data
If the shader_data bound to an Actor is NULL we should not try to access
its members.
2009-05-20 17:26:39 +01:00
Emmanuele Bassi
f8f54989be Merge commit 'origin/master' into 1.0-integration
Conflicts:
	clutter/clutter-texture.c
	clutter/cogl/gl/cogl-fbo.c
2009-05-20 16:49:22 +01:00
Emmanuele Bassi
4f5a5f38f7 Add more padding in Model and ModelIter classes
ClutterModel and ClutterModelIter have 4 padding slots, but if they
have to survive the 1.x API cycle they will need at least twice that
amount.
2009-05-20 16:06:09 +01:00
Emmanuele Bassi
c74586d019 [cogl] Do no include gprintf.h
We are not using any of the g_printf* family of functions, so we
can import glib.h instead.
2009-05-20 15:21:32 +01:00
Emmanuele Bassi
1f1d19f634 [cogl] Move debugging to a configure-time switch
Currently, COGL depends on defining debug symbols by manually
modifying the source code. When it's done, it will forcefully
print stuff to the console.

Since COGL has also a pretty, runtime selectable debugging API
we might as well switch everything to it.

In order for this to happen, configure needs a new:

        --enable-cogl-debug

command line switch; this will enable COGL debugging, the
CoglHandle debugging and will also turn on the error checking
for each GL operation.

The default setting for the COGL debug defines is off, since
it slows down the GL operations; enabling it for a particular
debug build is trivial, though.
2009-05-19 16:00:18 +01:00
Emmanuele Bassi
df1a9b7a74 [cogl] Rework the debug messages
COGL has a debug message system like Clutter's own. In parallel,
it also uses a coupld of #defines. Spread around there are also
calls to printf() instead to the more correct g_log* wrappers.

This commit tries to unify and clean up the macros and the
debug message handling inside COGL to be more consistent.
2009-05-19 14:44:29 +01:00
Emmanuele Bassi
529e48fbbe Remove duplicate cogl-internal.h header
The cogl-internal.h header has been moved inside cogl/common in
commit 8a1b4f8326 but has been left behind inside cogl/gl and
cogl/gles.
2009-05-19 14:42:37 +01:00
Emmanuele Bassi
407ac5075f [texture] Add missing accessors
ClutterTexture has many properties that can only be accessed using
the GObject API. This is fairly inefficient and makes binding the
class overly complicated.

The Texture class should have accessor methods for all its properties,
properly documented.
2009-05-19 13:24:56 +01:00
Emmanuele Bassi
3115a61688 [cogl] Rework the GL-error-to-string conversion
The code for the conversion of the GL error enumeration code
into a string is not following the code style and conventions
we follow in Clutter and COGL.

The GE() macro is also using fprintf(stderr) directly instead
of using g_warning() -- which is redirectable to an alternative
logging system using the g_log* API.
2009-05-19 13:24:56 +01:00
Emmanuele Bassi
cd3acca2b7 [build] Link Cogl against -lm
We use math routines inside Cogl, so it's correct to have it in
the LIBADD line. In normal usage something else was pulling in
-lm, but the introspection is relying on linking against the
convenience library.

Based on a patch by: Colin Walters <walters@verbum.org>

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-14 23:23:00 +01:00
Emmanuele Bassi
08ac50faae [build] List cogl-internal.h
During the Makefile clean up, cogl-internal.h got lost and this
broke the dist. Let's put it back in.
2009-05-14 19:51:03 +01:00
Emmanuele Bassi
2f5012e38c [animation] Do not leak timelines
The timeline created when calling set_timeline(NULL) is referenced
even though we implicitly own it. When the Animation is destroyed,
the timeline is then leaked.

Thanks to: Richard Heatley <richard.heatley@starleaf.com>

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1548
2009-05-14 16:20:12 +01:00
Emmanuele Bassi
21e3901d62 [text] Expose position_to_coords()
The clutter_text_position_to_coords() is useful for ClutterText
subclasses.

See bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1521

Based on a patch by: Raymond Liu <raymond.liu@intel.com>
2009-05-14 16:19:15 +01:00
Emmanuele Bassi
ca23838752 [text] Add ClutterText::delete_selection()
Add a method for deleting the current selection inside a Text actor.

This is useful for subclasses.

See bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1521

Based on a patch by: Raymond Liu <raymond.liu@intel.com>
2009-05-14 16:16:06 +01:00
Emmanuele Bassi
79cb0a3515 [animation] Remove InitiallyUnowned from Animation
ClutterAnimation currently inherits the initial floating reference
semantics from GInitiallyUnowned. An Animation is, though, meant to
be used as a top-level object, like a Timeline or a Behaviour, and
not "owned" by another object. For this reason, the initial floating
reference does not make any sense.
2009-05-14 16:12:36 +01:00
Emmanuele Bassi
092b41d53b [docs] Document the destructor for Timeline
The rest of the API reference lists the destructor for the class
inside the constructor's return value -- except Timeline.
2009-05-14 16:11:38 +01:00
Dan Winship
1c6580afd6 [cairo-texture] Document redrawing behavior
Document that repeated calls to clutter_cairo_texture_create()
continue drawing on the same cairo_surface_t. Add
clutter_cairo_texture_clear() for when you don't want that behavior.

http://bugzilla.openedhand.com/show_bug.cgi?id=1599

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-14 15:53:59 +01:00
Thomas Wood
81a536238d [text] fix problems with scrolling interaction
The cursor x position is already translated, so we do not need to take the
actors allocation into account when calculating scrolling.

Additionally, we need to update the text_x value before running
clutter_text_ensure_cursor_position.
2009-05-14 15:08:31 +01:00
Thomas Wood
a3a5fe5594 [text] scroll to the cursor position if it is outside the allocation
Adjust the text offset to keep the cursor within the allocation. This means
the text will scroll per character
2009-05-14 13:31:51 +01:00
Thomas Wood
cf6c2d9721 [text] account for scrolling in text selections
Account for any scrolling offset in single line mode when calculating the
area that should be selected.
2009-05-14 13:31:21 +01:00
Thomas Wood
e79fd1055d [text] account for scrolling in clutter_text_position_to_coords
Add any scrolling offset to the x value when in single line mode.

Now that the offset is taken into account in the position_to_coords
function, we do not need to adjust the cursor x manually in
clutter_text_paint.
2009-05-14 13:31:21 +01:00
Thomas Wood
16185c78fc [text] take scrolling into account when calculating cursor position
Account for the scrolling in single line more when calculating the cursor
position from coordinates.
2009-05-14 13:31:20 +01:00
Thomas Wood
e162d0b060 [text] position the cursor correctly in single line mode
The position of the text should be increased by the value of TEXT_PADDING
and the cursor offset by the same value as the text offset.
2009-05-14 13:31:20 +01:00
Thomas Wood
cd86e70f41 [text] take text padding into account when in single line mode
In single line mode, extra padding is added to the text which must be
taken into account when reporting the natural size of the actor.
2009-05-14 13:31:20 +01:00
Emmanuele Bassi
0d43d81ee0 [text] Maintain the cursor at the end when deleting
If the cursor is already at the end of the Text contents then we
need to maintain its position when deleting the previous character
using the relative key binding.
2009-05-14 12:00:51 +01:00
Emmanuele Bassi
8174f66cc6 [text] Reset the cursor when setting empty text
When setting the contents of Text to an empty string we should
reset the cursor position and selection bound to -1.
2009-05-14 11:50:42 +01:00
Emmanuele Bassi
608c3e3ab4 [build] Fix with --disable-introspection
The required "fake" libclutter-cogl.la upon with the main clutter
shared object depends is only built with introspection enabled
instead of being built unconditionally.
2009-05-14 10:03:31 +01:00
Owen W. Taylor
d8aa6827ee Don't build Cogl.gir against installed Clutter library
Passing:

 --library=clutter-@CLUTTER_FLAVOUR@-@CLUTTER_API_VERSION@

to g-ir-scanner, when building Cogl was causing g-ir-scanner to
link the introspection program against the installed clutter library,
if it existed or fail otherwise. Instead copy the handling from
the json/ directory where we link against the convenience library
to scan, and do the generation of the typelib later in the
main clutter/directory.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1594

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-13 23:31:43 +01:00
Emmanuele Bassi
447e04bdce [text] Return the correct minimum height
If text is set, ClutterText should never return less than the layout
height for minimum and preferred heights.

This holds unless ellipsize and wrap are enabled, in which case the
minimum height should be the height of the first line -- which is
the height needed to at the very least show the ellipsization.

Based on a patch by: Thomas Wood <thomas@openedhand.com>

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1598

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-13 23:06:43 +01:00
Emmanuele Bassi
aa1246e891 [backend] Abstract the GL context creation
This is the another step into abstracting the backend operations
that are currently spread all across the board back into the
backend implementations where they belong.

The GL context creation, for instance, is demanded to the stage
realization which makes it a critical path for every operation
that is GL-context bound. This usually does not make any difference
since we realize the default stage, but at some point we might
start looking into avoiding the default stage realization in order
to make the Clutter startup faster.

It also makes the code maintainable because every part is self
contained and can be reworked with the minimum amount of pain.
2009-05-13 22:21:48 +01:00
Emmanuele Bassi
1d7a79f343 Update the redraw priority
The master clock is using the redraw priority to create the source
that will be used to spin the paint sequence if something is being
animated using a timeline.

Unfortunately, the priority is too high and this causes starvation
when embedding into other toolkits -- like gtk+.

Thanks to Havoc Pennington for catching this.
2009-05-13 22:20:19 +01:00
Emmanuele Bassi
e59a19bd03 [x11] Abstract XVisualInfo creation
The XVisualInfo for GL is created when a stage is being realized.
When embedding Clutter inside another toolkit we might not want to
realize a stage to extract the XVisualInfo, then set the stage
window using a foreign X Window -- which will cause a re-realization.

Instead, we should abstract as much as possible into the X11 backend.

Unfortunately, the XVisualInfo for GL is requested using GLX API; for
this reason we have to create a ClutterBackendX11 method that we
override inside the ClutterBackendGLX implementation.

This also allows us to move a little bit of complexity from out of
the stage realization, which is currently a very delicate and hard
to debug section.
2009-05-13 21:49:45 +01:00
Robert Bragg
2b1759385e [text] Ensure clutter_text_get_selection copes with start/end positions of -1
I was seeing clutter_text_get_selection trying to malloc up to 4Gb due to
unexpected negative arithmetic for the start/end offsets which resulted
in a crash.

This just tests for positions of -1 before deciding if the start/end
positions need to be swapped.  The conversion from position to byte offset
already works with -1.
2009-05-13 14:34:00 +01:00
Owen W. Taylor
df85b70ab4 Fix chain-up in clutter_list_model_dispose()
Chain up to parent class's dispose() method not parent class's
finalize() method.

http://bugzilla.openedhand.com/show_bug.cgi?id=1595

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-12 16:31:41 +01:00
Robert Bragg
d1fa83039d [picking] Use cogl_clip_push_window_rect to greatly reduce the cost of picking.
cogl_clip_push_window_rect is implemented using GPU scissoring which allows
the GPU to cull anything that falls outside a given rectangle.  Since in the
case of picking we only ever care about a single pixel we can get the GPU to
ignore all geometry that doesn't intersect that pixel and only rasterize for
one pixel.
2009-05-12 15:44:34 +01:00
Robert Bragg
e80fcbc298 [cogl-clip-stack] Support pushing rectangles onto the stack using window coords
Previously clipping could only be specified in object coordinates, now
rectangles can also be pushed in window coordinates.

Internally rectangles pushed this way are intersected and then clipped using
scissoring.  We also transparently try to convert rectangles pushed in
object coordinates into window coordinates as we anticipate the scissoring
path will be faster then the clip planes and undoubtably it will be faster
than using the stencil buffer.
2009-05-12 15:44:33 +01:00
Neil Roberts
e9b863eba2 Don't clear the stencil buffer before painting and picking
The stencil buffer is always cleared the first time a clip is used
that needs it and the stencil test is disabled otherwise so there is
no need to clear before a paint.
2009-05-12 15:36:16 +01:00
Robert Bragg
36cfb60307 [cogl] Remove the COGL{enum,int,uint} typedefs
COGLenum, COGLint and COGLuint which were simply typedefs for GL{enum,int,uint}
have been removed from the API and replaced with specialised enum typedefs, int
and unsigned int. These were causing problems for generating bindings and also
considered poor style.

The cogl texture filter defines CGL_NEAREST and CGL_LINEAR etc are now replaced
by a namespaced typedef 'CoglTextureFilter' so they should be replaced with
COGL_TEXTURE_FILTER_NEAREST and COGL_TEXTURE_FILTER_LINEAR etc.

The shader type defines CGL_VERTEX_SHADER and CGL_FRAGMENT_SHADER are handled by
a CoglShaderType typedef and should be replaced with COGL_SHADER_TYPE_VERTEX and
COGL_SHADER_TYPE_FRAGMENT.

cogl_shader_get_parameteriv has been replaced by cogl_shader_get_type and
cogl_shader_is_compiled. More getters can be added later if desired.
2009-05-12 14:53:44 +01:00
Robert Bragg
cea711cc7e [ClutterTexture] Remove a spurious line I accidentally committed in 741c4bb5
I accidentally changed clutter_texture_set_cogl_texture to always set the
filter quality for the new Cogl texture to medium.
2009-05-12 14:53:43 +01:00
Robert Bragg
08a73a215f Don't call glFinish in _clutter_do_pick
Calling glReadPixels is bad enough in forcing us to synchronize the CPU with
the GPU, but glFinish has even stronger synchonization semantics than
glReadPixels which may negate some driver optimizations possible in
glReadPixels.
2009-05-12 14:53:43 +01:00
Neil Roberts
10783e053b [build] Fix out-of-tree builds for Cogl
Commit 43fa38fcf5 broke out-of-tree builds by removing some of the
builddir directories from the include path. builddir/clutter/cogl and
builddir/clutter are needed because cogl.h and cogl-defines-gl.h are
automatically generated by the configure script. The main clutter
headers are in the srcdir so this needs to be in the path too.
2009-05-12 14:16:46 +01:00
Raymond Liu
dd95939d26 Emit key focus signal when stage state changes
When the stage state changes between active/deactive, send out
key-focus-in/key-focus-out signal for the current key focused
actor on the stage.

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1503

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-05-12 13:47:17 +01:00
Emmanuele Bassi
4b285e02bc [x11] Unset the GL context when re-realizing
Setting the stage window using the set_stage_foreign() method will
lead to a re-realization. We need to make sure that the Drawable
currently associated to the GL context is set to None, to avoid a
BadDrawable error or, if we're unlucky, a segfault in the X server.
2009-05-11 18:17:30 +01:00
Emmanuele Bassi
0b7e459d48 Add more debugging notes 2009-05-11 12:45:33 +01:00
Emmanuele Bassi
8b7c6955de [backend] Unset the current stage if it is unrealized
This commit reverts part of commit 5bcde25c - specifically the
part that forced a realization of the stage if we are ensuring
the GL context with it. This makes Clutter behave like it did
prior to commit 5bcde25c: if we are asked to ensure the GL context
with an unrealized stage we simply pass NULL to the backend
implementation.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
d19f6feb45 [stage] Chain up ::show before showing the implementation
When showing a Stage for the first time we end up realizing the stage
implementation before realizing the wrapper. This leads to segmentation
faults or errors coming from the backend because we're fumbling the
state and realization sequence.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
9582fddb24 [x11] Do not needlessly check XVisualInfo
Since we are destroying any previously set VisualInfo we keep we know
for sure that stage->xvisinfo is going to be None; hence, no reason to
check this condition.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
0acb98e987 [actor] Conditionally verify the map state
The verify_map_state() internal method is conditionally compiled
if we have CLUTTER_ENABLE_DEBUG set; for this reason, all calls to
that method should be made conditional.
2009-05-11 12:45:33 +01:00
Emmanuele Bassi
d00cac6353 [build] Unbreak compilation
When building Clutter with introspection enabled everything stops
at Cogl GIR generation because it depends on the installed library
to work. Since we still require some changes in the API to be able
to build the GIR and the typelib for Cogl we should disable the
generation of the GIR as well.
2009-05-10 00:44:10 +01:00
Emmanuele Bassi
5bcde25cbb Tentative fix for multi-stage support on GLX
The fix for bug 1138 broke multi-stage support on GLX, causing
X11 to segfault with the following stack trace:

Backtrace:
0: /usr/X11R6/bin/X(xf86SigHandler+0x7e) [0x80c91fe]
1: [0xb7eea400]
2: /usr/lib/xorg/modules/extensions//libglx.so [0xb7ae880c]
3: /usr/lib/xorg/modules/extensions//libglx.so [0xb7aec0d6]
4: /usr/X11R6/bin/X [0x8154c24]
5: /usr/X11R6/bin/X(Dispatch+0x314) [0x808de54]
6: /usr/X11R6/bin/X(main+0x4b5) [0x8074795]
7: /lib/i686/cmov/libc.so.6(__libc_start_main+0xe5) [0xb7c75775]
8: /usr/X11R6/bin/X(FontFileCompleteXLFD+0x21d) [0x8073a81]

which I can only track down to clutter_backend_glx_ensure_current()
being passed a NULL stage -- something that happens when a stage
is not correct realized. That should lead to a glXMakeCurrent(None)
and not to a segmentation fault, though.
2009-05-08 17:17:48 +01:00
Emmanuele Bassi
91126558d3 [actor] Relax some of the invariants checks
When destroying a top-level actor we can actually relax the verification
of the map state, since it might be fully asynchronous and we might not
re-enter inside the mainloop in time to receive the unmap notification.
2009-05-08 17:14:49 +01:00
Rob Bradford
692c50ba67 [list-model] Return NULL for first row in a fully filtered model
If the filter means that the there should be no rows left in the model,
clutter_model_get_iter_at_row (model, 0) should return NULL.

Howevever the currene implementation misbehaves and returns a bad iterator.
This change resolves the issue by tracking if we actually found any
non-filtered rows in our pass through the sequence.

OH Bugzilla: 1591
2009-05-08 12:33:44 +01:00
Emmanuele Bassi
9f3927c460 [stage] Chain up to the correct vfunc when picking
The stage is chaining up to the ClutterGroup::paint instead of
the ClutterGroup::pick method. This works anyway because we
detect the stage by default, but it's not a reliable solution
in case we decide to change the picking further on.
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
533c9c5365 [debug] Show the actor name/type on queue_redraw() 2009-05-07 19:25:24 +01:00
Emmanuele Bassi
86bc31bd55 [clock] Rework the master clock
The master clock is currently advanced using a frame source driven
by the default frame rate. This breaks the sync to vblank because
the vblanking rate could be different than 60 Hz -- or it might be
completely disabled (e.g. with CLUTTER_VBLANK=none).

We should be using the main loop to check if we have timelines
playing, and if so queue a redraw on the stages we own.

We should also prepare the subsequent frame at the end of the redraw
process, so if there are new redraw we will have the scene already
in place.

This makes Clutter redraw at the maximum frame rate, which is
limited by the vblanking frequency.
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
ab9c7671f5 [group] Implement pick
Currently, picking in ClutterGroup pollutes the CLUTTER_DEBUG=paint
logs since it just calls the paint function. Reimplementing the pick
doesn't make us lose anything -- it might even be slightly faster
since we don't have to do a (typed) cast and a class dereference.
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
081813fd61 [animation] Do not leak timelines
The timeline created when calling set_timeline(NULL) is referenced
even though we implicitly own it. When the Animation is destroyed,
the timeline is then leaked.

Thanks to: Richard Heatley <richard.heatley@starleaf.com>

Fixes bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1548
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
33ef1675f5 [script] Allow parsing units in em
When creating an actor, using "em" as a unit should result
in an implicit conversion, like for "mm" and "pt".
2009-05-07 19:25:24 +01:00
Emmanuele Bassi
f2c25fd4f7 Allow specifying the font for the em conversion
Currently, the conversion from em to units is done by using the
default font name inside the backend. For actors using their own
font/text layout we need a way to specify the font name along
with the quantity we wish to transform.
2009-05-07 19:25:18 +01:00
Emmanuele Bassi
8ec1c3e2fb Fix remaining ::focus-in signal emission
Commit 515350a7 renamed ::focus-in and ::focus-out to ::key-focus-in
and ::key-focus-out respectively. One signal emission for ::focus-out
escaped the renaming in ClutterStage.
2009-05-07 11:18:51 +01:00
Emmanuele Bassi
2ae9d84a2a [x11] Use -1 as the default screen guard
Currently, the default screen guard value is 0, which is a valid
screen number on X11, and it might not be the default.

Patch suggested by: Owen W. Taylor <otaylor@redhat.com>
2009-05-06 18:32:17 +01:00
Emmanuele Bassi
8ca46d728d [build] Build Cogl introspection data
Currently, the introspection data for Cogl is built right into
Clutter's own typelib. This makes functions like:

  cogl_path_round_rectangle()

Appear as:

  Clutter.cogl_path_round_rectangle()

It should be possible, instead, to have a Cogl namespace and:

  Cogl.path_round_rectangle()

This means building introspection data for Cogl alone. Unfortunately,
there are three types defined in Cogl that confuse the introspection
scanner, and make it impossible to build a typelib:

  COGLint
  COGLuint
  COGLenum

These three types should go away before 1.0, substituted by int,
unsigned int and proper enumeration types. For this reason, we can
just set up the GIR build and wait until the last moment to create
the typelib. Once that has been done, we will be able to safely
remove the Cogl API from the Clutter GIR and typelib and let
people import Cogl if they want to use the Cogl API via introspection.
2009-05-06 17:59:25 +01:00
Emmanuele Bassi
43fa38fcf5 [build] Clean up the makefile
Split out the files into their own variables to clean up the
Makefile template; also use top_srcdir with the header files
instead of top_builddir.
2009-05-06 17:59:25 +01:00
Emmanuele Bassi
c065524b9f Fix inclusion guards and headers
The C++ inclusion guards G_BEGIN_DECLS and G_END_DECLS are
defined by GLib; so we need to include glib.h before using
them.
2009-05-06 17:59:25 +01:00
Emmanuele Bassi
515350a77f [actor] Rename focus-in and focus-out signals
For consistency, and since those signals are key-related, the
::focus-in signal is not ::key-focus-in and the ::focus-out
signal is now ::key-focus-out.
2009-05-06 17:56:40 +01:00
Emmanuele Bassi
d0ad5a8abb [text] Expose position_to_coords()
The clutter_text_position_to_coords() is useful for ClutterText
subclasses.

See bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1521

Based on a patch by: Raymond Liu <raymond.liu@intel.com>
2009-05-06 17:18:12 +01:00
Emmanuele Bassi
a28b9f31eb [text] Add ClutterText::delete_selection()
Add a method for deleting the current selection inside a Text actor.

This is useful for subclasses.

See bug:

  http://bugzilla.openedhand.com/show_bug.cgi?id=1521

Based on a patch by: Raymond Liu <raymond.liu@intel.com>
2009-05-06 17:13:33 +01:00
Emmanuele Bassi
ab1dcb8033 [animation] Remove InitiallyUnowned from Animation
ClutterAnimation currently inherits the initial floating reference
semantics from GInitiallyUnowned. An Animation is, though, meant to
be used as a top-level object, like a Timeline or a Behaviour, and
not "owned" by another object. For this reason, the initial floating
reference does not make any sense.
2009-05-06 17:01:44 +01:00
Emmanuele Bassi
d6d208da7d Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.

ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.

So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:

  - we have to maintain twice the amount of entry points in ClutterActor
  - we still do an integer-to-float implicit conversion
  - we introduce a weird impedance between pixels and "pixels with
    fractionary bits"
  - language bindings will have to choose what to bind, and resort
    to manually overriding the API
    + *except* for language bindings based on GObject-Introspection, as
      they cannot do manual overrides, thus will replicate the entire
      set of entry points

For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:

  void clutter_actor_set_x (ClutterActor *self,
                            gfloat        x);
  void clutter_actor_get_size (ClutterActor *self,
                               gfloat       *width,
                               gfloat       *height);
  gfloat clutter_actor_get_height (ClutterActor *self);

etc.

The issues I have identified are:

  - we'll have a two cases of compiler warnings:
    - printf() format of the return values from %d to %f
    - clutter_actor_get_size() taking floats instead of unsigned ints
  - we'll have a problem with varargs when passing an integer instead
    of a floating point value, except on 64bit platforms where the
    size of a float is the same as the size of an int

To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:

  - we remove ambiguity in the API with regard to pixels and units
  - we remove entry points we get to maintain for the whole 1.0
    version of the API
  - we make things simpler to bind for both manual language bindings
    and automatic (gobject-introspection based) ones
  - we have the simplest API possible while still exposing the
    capabilities of the underlying GL implementation
2009-05-06 16:44:47 +01:00
Emmanuele Bassi
7afdfb080b [docs] Document the destructor for Timeline
The rest of the API reference lists the destructor for the class
inside the constructor's return value -- except Timeline.
2009-05-06 16:42:57 +01:00
Rob Bradford
41bb885486 [model] Add a private row mutator to ClutterModelIter
When calling clutter_model_iter_next () / clutter_model_iter_prev () we need
to update the row for the iterator. In order to improve the peformance of
iterating this change adds a private row mutator and switches ClutterListModel
to use it.
2009-05-05 20:18:28 +01:00
Rob Bradford
b2fbc2c95c [list-model] Use an internal iterator for comparisons
In order to carry out various comparisons for e.g. identifying the first
iterator in the model we need a ClutterModelIter. This change switches from
creating a new iterator each time to reusing an existing iterator.
2009-05-05 19:39:26 +01:00
Emmanuele Bassi
72562cda58 [actor] Add ActorFlags accessor methods
The flags field of ClutterActor should have accessor methods for,
language bindings.

Also, the set_flags() and unset_flags() methods should actively
emit notifications for the changed properties.
2009-05-05 18:08:53 +01:00
Emmanuele Bassi
fc991e9b67 [actor] Add the :realized property
The :realized property is the only missing property for an actor flag.
2009-05-05 15:36:29 +01:00
Robert Bragg
353187ce49 [cogl-material] Adds a cogl_material_set_color4f convenience function
This is simply a wrapper around cogl_color_set_from_4f and
cogl_material_set_color. We already had a prototype for this, it was
an oversight that it wasn't already implemented.
2009-05-02 04:12:26 +01:00
Robert Bragg
a5cdfdfd87 [cogl-offscreen] Cleans up the cogl offscreen API and adds documentation
There were several functions I believe no one is currently using that were
only implemented in the GL backend (cogl_offscreen_blit_region and
cogl_offscreen_blit) that have simply been removed so we have a chance to
think about design later with a real use case.

There was one nonsense function (cogl_offscreen_new_multisample) that
sounded exciting but in all cases it just returned COGL_INVALID_HANDLE
(though at least for GL it checked for multisampling support first!?)
it has also been removed.

The MASK draw buffer type has been removed. If we want to expose color
masking later then I think it at least would be nicer to have the mask be a
property that can be set on any draw buffer.

The cogl_draw_buffer and cogl_{push,pop}_draw_buffer function prototypes
have been moved up into cogl.h since they are for managing global Cogl state
and not for modifying or creating the actual offscreen buffers.

This also documents the API so for example desiphering the semantics of
cogl_offscreen_new_to_texture() should be a bit easier now.
2009-05-02 04:12:26 +01:00
Havoc Pennington
e47b198225 add cogl_push_draw_buffer() and cogl_pop_draw_buffer()
These are necessary if nesting redirections to an fbo,
otherwise there's no way to know how to restore
previous state.

glPushAttrib(GL_COLOR_BUFFER_BIT) would save draw buffer
state, but also saves a lot of other stuff, and
cogl_draw_buffer() relies on knowing about all draw
buffer state changes. So we have to implement a
draw buffer stack ourselves.

Signed-off-by: Robert Bragg <robert@linux.intel.com>
2009-05-02 04:12:26 +01:00
Robert Bragg
d5fc61102f [cogl] Only expose CoglBitmap as a CoglHandle
It was inconsistent that we exposed the CoglBitmap struct instead of an
opaque CoglHandle.
2009-05-02 04:12:26 +01:00
Robert Bragg
ee57192f47 [cogl-material] make _cogl_material_layer_free check for an invalid texture handle
It is valid in some situations to have a material layer with an invalid texture
handle (e.g. if you setup a texture combine mode before setting the texture)
and so _cogl_material_layer_free needs to check for a valid handle before
attempting to unref it.
2009-05-02 04:12:25 +01:00
Robert Bragg
f85377372c [cogl] Updates all file headers and removes lots of trailing white space
Adds missing notices, and ensures all the notices are consistent. The Cogl
blurb also now reads:

 * Cogl
 *
 * An object oriented GL/GLES Abstraction/Utility Layer
2009-05-02 04:12:25 +01:00
Robert Bragg
741c4bb5e9 [cogl] Adds a bitfield argument to cogl_clear for specifying which buffers to clear
Redundant clearing of depth and stencil buffers every render can be very
expensive, so cogl now gives control over which auxiliary buffers are
cleared.

Note: For now clutter continues to clear the color, depth and stencil buffer
each paint.
2009-05-02 04:12:12 +01:00
Neil Roberts
fa9efe4828 Accumulate small deltas
The clutter frame source tries to average out the frame deltas so that
if one frame takes 1 interval plus a little bit of extra time then the
next frame will be 1 interval minus that little bit of extra
time. Therefore the deltas can sometimes be less than the frame
interval. ClutterTimeline should accumulate these small differences
otherwise it will end up missing out frames so the total duration of
the timeline will be a lot longer.

For example this was causing test-actors to appear to run very slow.
2009-05-01 15:12:08 +01:00
Emmanuele Bassi
5be29cf9bc [timeline] Expose the msec advancement
The method of ClutterTimeline that advances the timeline by a
delta (in millisecond) is going to be useful for testing the
timeline's behaviour -- and unbreak the timeline test suite that
was broken by the MasterClock merge.
2009-05-01 15:05:51 +01:00
Emmanuele Bassi
1a87e4e252 [clone] Allow painting hidden source actors
With the introduction of the map/unmap flags and the split of the
visible state from the mapped state we require that every part of
a scene graph branch is mapped in order to be painted. This breaks
the ability of a ClutterClone to paint an hidden source actor.

In order to fix this we need to introduce an override flag, similar
in spirit to the current modelview and paint opacity overrides that
Clone is already using.

The override flag, when set, will force a temporary map on a
Clone source (and its children).
2009-05-01 12:33:42 +01:00
Emmanuele Bassi
5d2d8297e2 [actor] Use foreach_with_internals()
ClutterContainer provides a foreach_with_internals() vfunc for
iterating over all of a container's children, be them added using
the Container API or be them internal to the container itself.

We should be using the foreach_with_internals() function instead
of the plain foreach().
2009-05-01 12:31:06 +01:00
Neil Roberts
20cd885c3d [ClutterTexture] Check before unrefing the fbo_handle
When replacing the fbo_handle with a new handle it first unrefs the
old handle. This was previously a call to cogl_offscreen_unref which
silently ignored attempts to unref COGL_INVALID_HANDLE. However the
new cogl_handle_unref does check for this so we should make sure the
handle is valid to avoid the warning.
2009-04-30 15:09:04 +01:00
Neil Roberts
4f692cc3ee [ClutterTexture] Attach the FBO texture to a layer in the material
Bug 1565 - test-fbo case failed in many platform

clutter_texture_new_from_actor was broken because it created the FBO
texture but then never attached it to the material so it was never
used for rendering. The old behaviour in Clutter 0.8 was to assign the
texture directly to priv->tex. In 0.9 priv->tex is replaced with
priv->material which has a reference to the tex in layer 0. So putting
the FBO texture directly in layer 0 more closely matches the original
behaviour.
2009-04-30 15:09:04 +01:00
Øyvind Kolås
8e6e09c8ef [events] Added handling of missing type to clutter_event_get_state
clutter_event_get_state wasn't returning the state for
CLUTTER_BUTTON_RELEASE, the information was there it just needed to
be returned correctly.
2009-04-30 11:54:09 +01:00
Neil Roberts
bb156970de Render pango layouts with vertex buffers
When rendering a pango layout CoglPangoRenderer now records the
operations into a list called a CoglPangoDisplayList. The entries in
the list are either glyph renderings from a texture, rectangles or
trapezoids. Multiple consecutive glyph renderings from the same glyph
cache texture are combined into a single entry. Note the
CoglPangoDisplayList has nothing to do with a GL display list.

After the display list is built it is attached to the PangoLayout with
g_object_set_qdata so that next time the layout is rendered it can
bypass rebuilding it.

The glyph rendering entries are drawn via a VBO. The VBO is attached
to the display list so it can be used multiple times. This makes the
common case of rendering a PangoLayout contained in a single texture
subsequent times usually boil down to a single call to glDrawArrays
with an already uploaded VBO.

The VBOs are accessed via the cogl_vertex_buffer API so if VBOs are
not available in GL it will resort to a fallback.

Note this will fall apart if the pango layout is altered after the
first render. I can't find a way to detect when the layout is
altered. However this won't affect ClutterText because it creates a
new PangoLayout whenever any properties are changed.
2009-04-29 19:53:24 +01:00
Emmanuele Bassi
01d172293c [model] Rework Model behaviour with a filter
Currently ClutterModel::get_iter_at_row() ignores whether we have
a filter in place. This also extends to the get_n_rows() method.

The more consistent, more intuitive and surely more correct way to
handle a Model with a filter in place is to take into account the
presence of the filter itself -- that is:

  - get_n_rows() should take into account the filter and return the
    number of *filtered* rows

  - get_iter_at_row() should also take the filter into account and
    get the first non-filtered row

These two changes make the ClutterModel with a filter function
behave like a subset of the original Model without a filter in
place.

For instance, given a model with three rows:

  - [row 0]     <does not match filter>
  - [row 1]     <matches filter>
  - [row 2]     <matches filter>
  - [row 3]     <does not match filter>

The get_n_rows() method will return "2", since only two rows will
match the filter; the get_first_iter() method will ask for the
zero-eth row, which will return an iterator pointing to the contents
of row 1 (but the :row property of the iterator will be set to 0);
the get_last_iter() method will ask for the last row, which will
return an iterator pointing to the contents of row 2 (but the :row
property of the iterator will be set to 1).

This changes will hopefully make the Model API more consistent
in its usage whether there is a filter in place or not.
2009-04-29 15:26:05 +01:00
Emmanuele Bassi
44fefa2afe [model] Add :filter-set
Currently, there is no way for implementations of the ClutterModel
abstract class to know whether there is a filter in place. Since
subclasses might implement some optimization in case there is no
filter present, we need a simple (and public) API to ask the model
itself.
2009-04-29 15:14:40 +01:00
Neil Roberts
9fdc9ca583 [ClutterText] Fix actors with a width but no wrapping and the wrap modes
Setting the wrap mode on the PangoLayout seems to have disappeared
during the text-actor-layout-height branch merge so this brings it
back. The test for this in test-text-cache no longer needs to be
disabled.

We also shouldn't set the width on the layout if there is no wrapping
or ellipsizing because otherwise it implicitly enables wrapping. This
only matters if the actor gets allocated smaller than its natural
size.
2009-04-27 17:43:48 +01:00
Owen W. Taylor
e260296cb5 [clone] Redraw when the source changes
Bug 1484 - Redraw ClutterClone when the source changes, even for
           !visible sources

Connect to ::queue-redraw on the clone source and queue a redraw.
This allows redrawing the Clone when the source changes, even in
case of a non visible source actor.

http://bugzilla.openedhand.com/show_bug.cgi?id=1484

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:30:59 +01:00
Emmanuele Bassi
678f99677f Use a single master "clock" to drive timelines
Currently, all timelines install a timeout inside the TimeoutPool
they share. Every time the main loop spins, all the timeouts are
updated. This, in turn, will usually lead to redraws being queued
on the stages.

This behaviour leads to the potential starvation of timelines and
to excessive redraws.

One lesson learned from the games developers is that the scenegraph
should be prepared in its entirety before the GL paint sequence is
initiated. This means making sure that every ::new-frame signal
handler is called before clutter_redraw() is invoked.

In order to do so a TimeoutPool is not enough: we need a master
clock. The clock will be responsible for advancing all the active
timelines created inside a scene, but only when the stage is
being redrawn.

The sequence is:

  + queue_redraw() is invoked on an actor and bubbles up
    to the stage

  + if no redraw() has already been scheduled, install an
    idle handler with a known priority

  + inside the idle handler:

    - advance the master clock, which will in turn advance
      every playing timeline by the amount of milliseconds
      elapsed since the last redraw; this will make every
      playing timeline emit the ::new-frame signal

    - queue a relayout

    - call the redraw() method of the backend

This way we trade multiple timeouts with a single frame source
that only runs if a timeline is playing and queues redraws on
the various stages.
2009-04-24 15:28:15 +01:00
Johan Bilien
51f4e9680b Relinquish the focus when unmapped while owning it
Bug 1547 - when an actor is unmapped while owning the focus, it should
           release it

When an actor is unmapped while owning the focus, the should release it.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:27:47 +01:00
Havoc Pennington
125bded814 Enforce invariants on mapped, realized, visibility states
Bug 1138 - No trackable "mapped" state

* Add a VISIBLE flag tracking application programmer's
  expected showing-state for the actor, allowing us to
  always ensure we keep what the app wants while tracking
  internal implementation state separately.

* Make MAPPED reflect whether the actor will be painted;
  add notification on a ClutterActor::mapped property.
  Keep MAPPED state updated as the actor is shown,
  ancestors are shown, actor is reparented, etc.

* Require a stage and realized parents to realize; this means
  at realization time the correct window system and GL resources
  are known. But unparented actors can no longer be realized.

* Allow children to be unrealized even if parent is realized.
  Otherwise in effect either all actors or no actors are realized,
  i.e. it becomes a stage-global flag.

* Allow clutter_actor_realize() to "fail" if not inside a toplevel

* Rework clutter_actor_unrealize() so internally we have
  a flavor that does not mess with visibility flag

* Add _clutter_actor_rerealize() to encapsulate a somewhat
  tricky operation we were doing in a couple of places

* Do not realize/unrealize children in ClutterGroup,
  ClutterActor already does it

* Do not realize impl by hand in clutter_stage_show(),
  since showing impl already does that

* Do not unrealize in various dispose() methods, since
  ClutterActor dispose implementation already does it
  and chaining up is mandatory

* ClutterTexture uses COGL while unrealizable (before it's
  added to a stage). Previously this breakage was affecting
  ClutterActor because we had to allow realize outside
  a stage. Move the breakage to ClutterTexture, by making
  ClutterTexture just use COGL while not realized.

* Unrealize before we set parent to NULL in clutter_actor_unparent().
  This means unrealize() implementations can get to the stage.
  Because actors need the stage in order to detach from stage.

* Update clutter-actor-invariants.txt to reflect latest changes

* Remove explicit hide/unrealize from ClutterActor::dispose since
  unparent already forces those
  Instead just assert that unparent() occurred and did the right thing.

* Check whether parent implements unrealize before chaining up
  Needed because ClutterGroup no longer has to implement unrealize.

* Perform unrealize in the default handler for the signal.
  This allows non-containers that have children to work properly,
  and allows containers to override how it's done.

* Add map/unmap virtual methods and set MAPPED flag on self and
  children in there. This allows subclasses to hook map/unmap.
  These are not signals, because notify::mapped is better for
  anything it's legitimate for a non-subclass to do.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:27:19 +01:00
Johan Bilien
b73ee6992c Unnecessary glColorMask on alpha drops performance
Bug 1228 - Unnecessary glColorMask on alpha drops performance

With DRI2, alpha is allowed in the window's framebuffer

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:26:32 +01:00
Emmanuele Bassi
08ba42a5ab Allow passing the pick mode to get_actor_at_pos()
Bug 1513 - Allow passing in ClutterPickMode to
           clutter_stage_get_actor_at_pos()

At the moment, clutter_stage_get_actor_at_pos() uses CLUTTER_PICK_ALL
internally to find an actor. It would be useful to allow passing in
ClutterPickMode to clutter_stage_get_actor_at_pos(), so that the caller
can specify CLUTTER_PICK_REACTIVE as a criteria.
2009-04-24 15:25:58 +01:00
Emmanuele Bassi
6064572703 [x11] Use XWithdrawWindow()
Bug 1516 - Does not withdraw toplevels correctly

clutter_stage_x11_hide() needs to use XWithdrawWindow(), not
XUnmapWindow().

As it stands now, if the window is already unmapped (say the WM has
minimized it), then the WM will not know that Clutter has closed the
window and will keep the window managed, showing it in the task list
and so forth.
2009-04-24 15:25:31 +01:00
Havoc Pennington
4f663384c7 Add ClutterContainer::foreach_with_internals()
Bug 1517 - clutter_container_foreach_with_internals()

This allows us to iterate over all children (for things like maintaining
map/realize invariants) or only children that apps added and care about.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-04-24 15:25:08 +01:00
Emmanuele Bassi
d6ccecd79e [alpha] Sanitize easing equations
Bug 1561 - Bad code in clutter-alpha.c

The implementation of the easing modes equations followed closely
the JavaScript and ActionScript counterparts. Obviously, JS and AS
are not C-compatible, so later versions of gcc (4.4.0 for instance)
would complain about uninitialized variables and such. The code is
also obfuscated and hard to debug/understand.

For these reasons, the implementation should be unobfuscated and
sanitized.
2009-04-23 11:35:10 +01:00
Robert Bragg
1d2ac51ea3 [x11-texture-pixmap] Fixes a reported lockup due to an undesireable X server grab
A lockup was reported by fargoilas on #clutter and removing the server grab in
clutter_x11_texture_pixmap_sync_window fixed the problem.

We were doing an x server grab to guarantee that if the XGetWindowAttributes
request reported that our redirected window was viewable then we would also
be able to get a valid pixmap name.  (the composite protocol says it's an
error to request a name for a window if it's not viewable) Without the grab
there would be a race condition.

Instead we now handle error conditions gracefully.
2009-04-22 13:43:53 +01:00
Emmanuele Bassi
ffefbe4661 [text] Avoid a Pango warning with empty markup
When the markup string is empty Pango complains about invalid
characters.
2009-04-21 14:08:55 +01:00
Emmanuele Bassi
1c42e6334e [text] Emit ::cursor-event only on changes
The documentation for the ::cursor-event says that the signal
is emitted only when the cursor position changes. Right now it
is being emitted every time we ensure the cursor position during
the Text paint sequence.

The clutter_text_ensure_cursor_position() function should check
whether the stored cursor position has changed since the last
paint, and emit the ::cursor-event signal only when there has
been a change.
2009-04-21 12:11:42 +01:00
Emmanuele Bassi
368f61fa65 [text] Return the correct minimum height
The correct minimum height in case of ellipsis is still 1px.
2009-04-21 12:11:41 +01:00
Emmanuele Bassi
5c8263ecb7 [text] Limit the Layout width
We only want to eschew the pango_layout_set_width() on editable,
single-line Text actors because they can "scroll" the PangoLayout.

This fixes the ellipsization on entries.
2009-04-21 12:11:41 +01:00
Robert Bragg
e4d3b0536f [gl/cogl.c] #include <gmodule.h> for OS X builds
In unifying the {gl,gles}/cogl.c code recently, moving most of the code into
common/cogl.c the gmodule.h include was also mistakenly moved.

Thanks to Felix Rabe for reporting this issue.

Note: I haven't tested this fix myself, as I'm not set up to be able to
build for OS X
2009-04-20 14:20:37 +01:00
Robert Bragg
46c20f1523 [cogl vertex buffers] Adds fallbacks for drivers without VBO support
Buffer objects aren't currently available for glx indirect contexts, so we
now have a fallback that simply allocates fake client side vbos to store the
attributes.
2009-04-20 13:04:34 +01:00
Robert Bragg
ac21e7b182 [cogl debug] --cogl-debug=rectangles now outlines all cogl rectangles
This makes the #if 0'd debug code that was in _cogl_journal_flush_quad_batch
- which we have repeatedly found usefull for debugging various geometry
issues in Clutter apps - a runtime debug option.

The outline colors rotate in order from red to green to blue which can also
help confirm the order that your geometry really drawn.

The outlines are not affected by the current material state, so if you e.g.
have a blending bug where geometry mysteriously disappears this can confirm
if the underlying rectangles are actually being emitted but blending is
causing them to be invisible.
2009-04-17 15:25:28 +01:00
Robert Bragg
169d472d17 Use $(MAINTAINER_CFLAGS) in clutter/{x11,glx}/Makefile.am
These makefile weren't resulting in the addition of the maintainer flags while
building clutter.
2009-04-17 14:53:24 +01:00
Bastian Winkler
5c50be1bdc Prevent a possible zero division
A zero division might occur in clutter_path_get_position if the length
of a curved node is zero.

Signed-off-by: Neil Roberts <neil@linux.intel.com>
2009-04-16 17:16:31 +01:00
Chris Lord
56ac4baf17 [ClutterText] Return 1 for min width when editable
Editable ClutterText will scroll when allocated less width than is
necessary to lay out the entire layout on a single line, so return 1 for
the minimum width in this case.

Approved by Emmanuele Bassi, fixes bug #1555.
2009-04-16 16:34:15 +01:00
Emmanuele Bassi
425fa78a27 Merge branch 'text-actor-layout-height'
* text-actor-layout-height:
  [clutter-text] Fix ellipsizing
  Support pango_layout_set_height() in ClutterText

Conflicts:
	clutter/clutter-text.c
2009-04-15 18:08:14 +01:00
Emmanuele Bassi
d4b47af153 [stage] Warn if perspective's z_far - z_near is 0
Since we have to do (z_far - z_near) and use it in a division we
should check that the user is not passing a value that would
cause a division by zero.
2009-04-15 17:27:04 +01:00
Emmanuele Bassi
709bb69970 Add debug annotations for the layout process
If we need to check that the layout sequence is correct in
terms of order of execution and with respect to caching, then
having a CLUTTER_DEBUG_LAYOUT debug flag would make things
easier.
2009-04-15 17:25:50 +01:00
Emmanuele Bassi
f8256e4b23 [text] Do not ellipsize non-editable layouts
If a ClutterText is set as non-editable then its PangoLayout
will occupy as much width as its contents and ignore the
ellipsization setting.
2009-04-15 17:23:45 +01:00
Neil Roberts
fbd9c59c7c [clutter-text] Fix ellipsizing
Ellipsizing was effectively broken for two reasons. There was a typo
in the code to set the width so it always ended up being some massive
value. If no height should be set on the layout it was being set to
G_MAXINT. Setting a height greater than 0 enables wrapping which so
ellipsizing is not performed. It should be left at the default of -1
instead.
2009-04-15 14:46:45 +01:00
Emmanuele Bassi
5af99660cb [json] Avoid leaks on error code paths
Bug 1476 - JSON Parser memory leak

Static analysis of the code showed that the in-tree copy of
the JsonParser object leaks objects and arrays on parse errors.

Thanks to Gordon Williams <gordon.williams@collabora.co.uk>
2009-04-15 12:18:55 +01:00
Øyvind Kolås
269598a2cf [group] avoid double evaluation of arguments in clutter_group_add
clutter_group_add would evaluate the actor argument twice, which is
bad if this is a function call creating a new actor and not a variable.
2009-04-08 18:19:46 +01:00
Neil Roberts
a9f24351e9 Fix fullscreening when the stage is unrealized and on dual-head
If the stage is unrealized (such as will be the case if the stage was
created with clutter_stage_new) then it would set the size of the
stage display but it was not setting the fullscreen_on_map flag so it
never got the _NET_WM_STATE_FULLSCREEN property. Now it always sets
the flag regardless of whether the window is created yet.

There was also problems with dual-headed displays because in that case
DisplayWidth/Height will return the size of the combined display but
Metacity (and presumably other WMs) will sensibly try fit the window
to only one of the monitors. However we were setting the size hints so
that the minimum size is that of the combined display. Metacity tries
to honour this by setting the minimum size but then it no longer
positions the window at the top left of the screen.

The patch makes it avoid setting the minimum size when the stage is
fullscreen by checking the fullscreen_on_map flag. This also means we
can remove the static was_resizable flag which would presumably have
caused problems for multi-stage.
2009-04-07 15:24:48 +01:00
Neil Roberts
1edc19d1d3 [clutter-text] Add a separate property for the selection color
Adds a new property so that the selection color can be different from
the cursor color. If no selection color is specified it will use the
cursor color as before. If no cursor color is specified either it will
use the text color.
2009-04-06 15:22:31 +01:00
Neil Roberts
3fdacf9762 [cogl-handle] Fix the broken debug macros
The debug macros for tracking reference counting of CoglHandles had
some typos introduced in c3d9f0 which meant it failed to compile when
COGL_DEBUG is 1.
2009-04-06 12:44:15 +01:00
Robert Bragg
e464acff7a [cogl] cogl_is_*(): Don't dereference an invalid handle; just return FALSE
An invalid handle is implicitly not of any type.
2009-04-06 11:35:10 +01:00
Neil Roberts
fff5585b5f [cogl-pango-render] Fix returning to default color after a color attribute
Since the Cogl material branch merge when changing the color of a part
using pango attributes (such as using <span color="red" /> markup)
then it wouldn't return to the default color for the rest of the
layout. pango_renderer_get_color returns NULL if there is no color
override in which case it needs to revert to the color specified as
the argument to cogl_pango_render_layout. The 'color' member of
CoglPangoRenderer has been reinstated to store that default color and
now cogl_pango_render_set_color_for_part is the only place that sets
the material color.
2009-04-06 11:14:43 +01:00
Emmanuele Bassi
a1cc1f57ac [animation] Do not connect to ::completed multiple times
The clutter_actor_animate*() family of functions should only connect
to the Animation::completed signal once, during the construction of
the Animation object attached to the Actor. Otherwise, the completed
signal handler will be run multiple times, and will try to unref()
the Animation for each call -- leading to a segmentation fault.
2009-04-05 20:32:15 +01:00
Emmanuele Bassi
6bf883da6c [animation] Add the ::started signal
The Animation class is missing a ::started signal matching the
::completed one. A ::started signal is useful for debugging,
initial state set up, and checks.
2009-04-03 14:19:20 +01:00
Emmanuele Bassi
1762795990 [group] Fix compilation
A case of rebase FAIL. The sorting of the children was still
done using the now removed group function call instead of the
Container one.
2009-04-03 13:36:30 +01:00
Emmanuele Bassi
df738d0a8c [animation] Do not unref on ::complete by default
Bug 1535 - Complete animation always unrefs ClutterAnimation (even
           after g_object_ref_sink)

Animations created through clutter_animation_new() should not
automagically unref themselves by default on ::complete. We
only want that behaviour for Animations created by the
clutter_actor_animate* family of functions, since those provide
the automagic memory management.
2009-04-03 12:47:21 +01:00
Emmanuele Bassi
bd8d3f6bd8 [group] Remove long deprecated API
ClutterGroup still ships with API deprecated since 0.4. We did
promise to keep it around for a minor release cycle -- not for 3.

Since we plan on shipping 1.0 without the extra baggage of the
deprecated entry points, here's the chance to remove the accumulated
cruft.

All the removed methods and signals have a ClutterContainer
counterpart.
2009-04-03 12:47:21 +01:00
Emmanuele Bassi
9d0ce68c2f [shader] Remove deprecated set_uniform_1f()
Since we're planning to release 1.0 without any of the deprecated
API baggage, we can simply remove the set_uniform_1f() method from
ClutterShader public API and add it to the deprecated header.
2009-04-03 12:47:21 +01:00
Robert Bragg
c3d9f0bed4 [cogl-handle] Optimize how we define cogl handles
The cogl_is_* functions were showing up quite high on profiles due to
iterating through arrays of cogl handles.

This does away with all the handle arrays and implements a simple struct
inheritance scheme. All cogl objects now add a CoglHandleObject _parent;
member to their main structures. The base object includes 2 members a.t.m; a
ref_count, and a klass pointer. The klass in turn gives you a type and
virtual function for freeing objects of that type.

Each handle type has a _cogl_##handle_type##_get_type () function
automatically defined which returns a GQuark of the handle type, so now
implementing the cogl_is_* funcs is just a case of comparing with
obj->klass->type.

Another outcome of the re-work is that cogl_handle_{ref,unref} are also much
more efficient, and no longer need extending for each handle type added to
cogl. The cogl_##handle_type##_{ref,unref} functions are now deprecated and
are no longer used internally to Clutter or Cogl. Potentially we can remove
them completely before 1.0.
2009-04-02 11:58:43 +01:00
Robert Bragg
04ebd6be44 [cogl] handle_automatic_blend_enable(): consider layers with invalid textures
A layer object may be instantiated when setting a combine mode, but before a
texture is associated. (e.g. this is done by the pango renderer) if this is the
case we shouldn't call cogl_texture_get_format() with an invalid cogl handle.

This patch skips over layers without a texture handle when determining if any
textures have an alpha channel.
2009-04-02 11:50:44 +01:00
Robert Bragg
8a1b4f8326 Unifies 90% of the code in {gl,gles}/cogl.c in common/cogl.c
This code keeps on diverging and we get bugs and fixes in one version but
not the other. This should make things a bit more maintainable.
2009-04-01 13:19:35 +01:00
Robert Bragg
50c1fc6291 Removes cogl_blend_func prototype from cogl-internal.h
cogl_blend_func was removed a while ago so this was just a left over from then
2009-03-30 18:02:03 +01:00
Bastian Winkler
34467e5c6a [docs] Fix some inconsistency in Animation
For some examples of clutter_actor_animate the parameters of @mode and
@duration are swapped.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-30 17:34:07 +01:00
Havoc Pennington
077e3192fd [texture] Queue a relayout when changing :keep-aspect-ratio
Bug 1528 - queue relayout when setting ClutterTexture:keep-aspect-ratio

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-30 17:32:54 +01:00
Raymond Liu
a362a4a889 [text] Use the base class binding pool
Bug 1518 - [Patch] Widget derivied from ClutterText will crash on
           key_press_event

In clutter_text_key_press() we are using G_OBJECT_TYPE_NAME to find
out the actor's type name. However, if some widget is derived from
ClutterText, when the key press handler is called, G_OBJECT_TYPE_NAME
will return the name of the derived widget.

The default implementation should get the binding pool for the base
class.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-30 16:57:11 +01:00
Emmanuele Bassi
02ea81ce02 [text] Different selection modes with multiple clicks
ClutterText should offer multiple selection modes depending on the
number of pointer clicks.

Following the GTK+ conventions:

  - double click selects the current word
  - triple click selects the current line
2009-03-30 16:50:26 +01:00
Øyvind Kolås
f6d938a0db [animation] add varargs support for signal::completed
Added support for registering a handler for the completed signal
directly amongst the varargs making it easier to attach code
to be executed when animations complete.
2009-03-30 12:10:41 +01:00
Emmanuele Bassi
a1a8193179 [text] Check text length in ::button-press-event
Bug 1529 - Selection bound out of sync with an empty Text actor

When the user clicks on a Text actor the cursor position and the
selection bound are set using bytes_to_offset(); if the Text is
empty, this means placing them both to 0. Setting the selection
bound to 0 means that when the user inserts a character by typing
it into the Text, the selection will be [0,1]; this will select
the first character, which will then be overwritten when typing
a new character.

The Text actor should, instead, check if there are no contents
and set the cursor position and the selection bound to -1.

The clutter_text_set_selection_bound() method should also validate
the value passed, in case it's bigger than the text lenght, or
smaller than -1.
2009-03-30 07:54:42 +01:00
Emmanuele Bassi
0de0e869a9 [docs] Fix typo in the AnimationMode name 2009-03-27 14:28:08 +00:00
Chris Lord
cc21a4aa5f [ClutterTimeline] Fix clutter_timeline_set_delay
When setting a delay, timeout_add was being used with msecs. timeout_add
takes fps since the fix to bug #1495. Delay now uses g_timeout_add
instead.
2009-03-26 20:29:23 +00:00
Neil Roberts
68ab2c6024 [doc] Fix two small typos in cogl-vertex-buffer
The symbol name for cogl_vertex_buffer_draw_elements was wrong so it
ended up with no documentation. The name for the vertex attribute was
incorrect in cogl_vertex_buffer_add.
2009-03-25 14:53:58 +00:00
Robert Bragg
3d81f0c08e [build] Fixes a cogl-vertex-buffer.c warning when building for GLES
GLES 1 doesn't support GLSL so it never needs to use the generic_index
variable for generic attributes which was flagging a warning.
2009-03-23 16:32:17 +00:00
Robert Bragg
891ed53564 [cogl] Move rect and poly drawing code from cogl-texture.c to cogl-primitives.c
None of this code directly related to implementing CoglTextures, and the
code was needlessly duplicated between the GL and GLES backends. This moves
the cogl_rectangle* and cogl_polygon* code into common/cogl-primitives.c
makes which makes lot of sense since the two copies keep needlessly
diverging introducing or fixing bugs in one but not the other. For instance
I came accross one such bug regarding the enabling of texture units when
unifying the code.
2009-03-23 16:32:07 +00:00
Robert Bragg
b30bb575a1 [cogl_rectangles] A minor doc fix, and missing newline between functions
The gtk-doc had a copy and paste error, saying the float array should be 8
elements per rectangle instead of 4. There was also no newline in the gles
code before the new function.
2009-03-23 12:41:42 +00:00
Johan Bilien
13e5bd9e8b Allow using array of vertices even without textures
It's often nice to be able to draw a batch of vertices, even if these
have no texture coordinates. This add a cogl_rectangles, similar to
cogl_rectangles_with_texture_coords, only without.
2009-03-23 12:41:41 +00:00
Robert Bragg
5a06f1d1d0 Removes a hack in gles/cogl.c that was already fixed in gl/cogl.c
It removes the need to cast a CoglMatrix to a float * for transforming
a vertex manually instead of using cogl_matrix_transform_point.
2009-03-23 12:41:41 +00:00
Emmanuele Bassi
d6937b797e [doc] Update the should_pick_paint() documentation
The should_pick_paint() method of ClutterActor is not clearly
documented.
2009-03-21 20:40:22 +00:00
Neil Roberts
0a48a52ba1 [glx-texture-pixmap] Don't enable the texture target when binding the texture
There's no need to enable the texture target unless it is going to be
used for rendering. Enabling it directly with glEnable calls confuses
Cogl's state caching.

This is a replacement for the patch in bug 1483 which was reverted.
2009-03-19 17:54:17 +00:00
Neil Roberts
c4dcbb6bdb Revert "Use COGL to establish GL state for ClutterGLXTexturePixmap"
This reverts commit f9d996a460.

The change from calling glBindTexture to using the material API with
cogl_material_flush_gl_state does not always work because it doesn't
necessarily leave the active texture unit as GL_TEXTURE0. For example,
if the previously rendered texture was multi-layered then the last
thing cogl_material_flush_gl_state will do is select GL_TEXTURE1 just
to disable it.
2009-03-19 17:48:15 +00:00
Øyvind Kolås
e94e5ad65b [actor] use an epsilon whens sanity checking sizes
Clutter was complaining about netural width smaller than minimum widths
(differences around 0.0005) by using an epsilon value of 1e-4 for these
floating point comparisons, these warnings have now been silenced.
2009-03-19 14:46:23 +00:00
Emmanuele Bassi
7d8da0e830 [docs] Remove unused arguments
The documentation for some X11TexturePixmap method does not reflect
the actual API.
2009-03-18 17:07:50 +00:00
Emmanuele Bassi
ccca24ab76 Remove usage of the grave accent as quotation mark
See:

  http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

This should make Thomas happy.
2009-03-17 14:13:31 +00:00
Robert Bragg
39e2b43b22 [cogl] Apply the fix from 2c1c836417 (Flush matrix before clip planes) to GLES
glClipPlane() is affected by modelview matrix so we need to flush before
calling it.
2009-03-17 11:37:29 +00:00
Robert Bragg
bb93a98762 [clutter-color] Use a different hls->rgb algorithm + use floating point
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.
2009-03-17 11:37:29 +00:00
Emmanuele Bassi
567a96c96a [docs] More information on animation queueing
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.
2009-03-16 18:20:58 +00:00
Emmanuele Bassi
e8785fef07 [docs] Fix naming of the interval parameter
The interval parameter is now expressed in frames per second and not
in milliseconds.
2009-03-16 16:56:51 +00:00
Robert Bragg
ca3bfe2cea [cogl] Don't endlessly print the same warning regarding layer fallbacks
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.
2009-03-16 16:19:51 +00:00
Robert Bragg
71d65b629b [cogl-vertex-buffer] fix cogl_vertex_buffer_draw_elements prototype
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.
2009-03-16 16:19:39 +00:00
Robert Bragg
14e6323554 [cogl-vertex-buffer] Allow querying back the number of vertices a buffer represents
This may be convenient e.g. at draw time if you are simply drawing all vertices
2009-03-16 16:17:02 +00:00
Robert Bragg
075ae9c4a7 [cogl-vertex-buffer] Add a flush of attribute changes in the *_draw() functions
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.)
2009-03-16 16:14:17 +00:00
Neil Roberts
a93a93d007 Count timeline frames using the FPS instead of an integer interval
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.
2009-03-16 15:40:18 +00:00
Havoc Pennington
2c1c836417 [cogl] Flush matrix before clip planes
glClipPlane() is affected by modelview matrix so we need to flush
before calling it.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2009-03-16 15:10:33 +00:00
Emmanuele Bassi
9229fb6114 [docs] Bring down the undocumented symbols to 2%
The usual pre-release documentation blitzing. Most of the remaining
symbols are either COGL or X11 specific, or dummy interface typedefs.
2009-03-16 15:00:55 +00:00
Emmanuele Bassi
216373047b [animation] Enhance consistency of the Animation API
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.
2009-03-16 14:16:18 +00:00
Emmanuele Bassi
0942fac573 [docs] Add description of queue_redraw 2009-03-16 14:01:43 +00:00
Havoc Pennington
961aac3fb3 [actor] Add ::queue-redraw signal
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>
2009-03-16 12:13:55 +00:00
Havoc Pennington
5706105123 [actor] Add :clip-to-allocation property
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>
2009-03-16 12:13:55 +00:00
Colin Walters
0cb0a841cc [animation] Enhance the bind API
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>
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
156589fe3f [animation] Add Animation getter
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.
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
44d0733665 [animation] Add an emitter for ::completed
The ::completed signal requires an emitter in case we want to stop
the animation and safely dispose it inside application code without
breaking invariants.
2009-03-16 12:13:55 +00:00
Emmanuele Bassi
a5c88e62f2 [docs] Clarify Animation memory management
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.
2009-03-16 12:13:55 +00:00
Øyvind Kolås
0674fded7f Merge branch 'async-texture-thread-pool' 2009-03-16 00:40:27 +00:00
Øyvind Kolås
56568db3b0 [clutter-texture] fixed gtk-doc formatting, and init threads in test.
Fixed markup to actually work with gtk-doc, also do a g_thread_init
in the test.
2009-03-16 00:40:02 +00:00
Neil Roberts
7f2ef2f1e0 [cogl-path] Minor fix to gtk-doc
Fix the parameters in cogl_path_curve_to and cogl_path_rel_curve_to to
match the actual names otherwise they won't appear correctly in the
docs.
2009-03-13 15:43:19 +00:00
Emmanuele Bassi
89060a9bb3 [cogl] Avoid shadowing math.h symbols
As usual, y1 and y2 end up shadowing symbols exported by math.h.
2009-03-13 15:28:20 +00:00
Owen W. Taylor
e1742af368 Avoid drawing twice if relayout queues a draw
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.)
2009-03-13 15:20:50 +00:00
Emmanuele Bassi
72f9646804 Do not cause more size requisitions than necessary
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.
2009-03-13 15:20:49 +00:00
Emmanuele Bassi
786161c75f [deprecated] Add Effect deprecation
The ClutterEffect API has been deprecated during 0.9, so it should be
added to the deprecation macros.
2009-03-13 14:29:27 +00:00
Emmanuele Bassi
ed2fe41b32 Add more deprecation notices
Most of the deprecated API does not have an entry inside
clutter-deprecated.h, thus making porting a tad more difficult.
2009-03-13 14:29:27 +00:00
Neil Roberts
cde05288b7 Change cogl_path_rectangle and cogl_path_round_rectangle to take x1,y1,x2,y2
This matches the changes to cogl_rectangle to improve consistency.
2009-03-13 12:20:26 +00:00
Robert Bragg
ca2844013e Maintain the Cogl assumption that the modelview matrix is normally current
_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.
2009-03-12 18:55:41 +00:00
Robert Bragg
0580dbe015 Finish GLES{1,2} support for client side matrix stacks
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
2009-03-12 18:55:41 +00:00
Robert Bragg
3a9b18ef51 Use Cogl enum when making modelview-matrix current in cogl_{rotate,transform,etc}
My previous patch incorrectly used the GL enum with the _cogl_set_current_matrix
API.
2009-03-12 18:55:40 +00:00
Robert Bragg
2f34d14cb4 Explicitly make the modelview-matrix current in cogl_{rotate,transform,etc}
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.
2009-03-12 18:55:40 +00:00
Robert Bragg
0d88ecb459 Avoid casting CoglMatrix to a GLfloat * when calling glGetFloatv
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.
2009-03-12 18:55:40 +00:00
Robert Bragg
61b867442b 80 char fix 2009-03-12 18:55:40 +00:00
Robert Bragg
20a2f76e1f Removes need for casting (const float *) to (GLfloat *) in _cogl_set_clip_planes
This removes cogl.c:apply_matrix(), and makes cogl.c:project_vertex() use
cogl_matrix_transform_point instead.
2009-03-12 18:53:22 +00:00
Havoc Pennington
08932584b5 Virtualize GL matrix operations and use a client-side matrix when GL is indirect
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.
2009-03-12 18:32:45 +00:00
Øyvind Kolås
5895048f65 [clutter-texture] updated documentation.
Rewrote documentation, with the smallest amount of documentation for
load-data-async which is considered a special case of load-async.
2009-03-12 11:48:44 +00:00
Øyvind Kolås
25d54a650d Merge commit 'origin/async-texture-thread-pool' into async-size 2009-03-12 11:18:11 +00:00
Øyvind Kolås
93d8f62f6b [clutter-texture] remove load-size-async property
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.
2009-03-12 10:38:39 +00:00
Øyvind Kolås
d3b68298ac [clutter-texture] add option to not block on size for loaded images
Added a construct time property to indicate that we do not want
to block on loading images.
2009-03-12 10:30:09 +00:00
Øyvind Kolås
5d3d971389 [tests] Added test-texture-async 2009-03-12 10:17:08 +00:00
Geoff Gustafson
2c95b378a5 [animation] Broken fixed:: properties
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>
2009-03-11 22:09:05 +00:00
Owen W. Taylor
d88bc30b87 Allow NULL for clutter_text_set_text()
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 "".
2009-03-11 18:20:42 +00:00